option

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2024 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnnotationManifest = "$manifest"
	AnnotationConfig   = "$config"
)

Pre-defined annotation keys for annotation file

View Source
const (
	ImageSpecV1_1 = "v1.1"
	ImageSpecV1_0 = "v1.0"
)
View Source
const (
	DistributionSpecReferrersTagV1_1 = "v1.1-referrers-tag"
	DistributionSpecReferrersAPIV1_1 = "v1.1-referrers-api"
)
View Source
const (
	TargetTypeRemote    = "registry"
	TargetTypeOCILayout = "oci-layout"
)
View Source
const NoTTYFlag = "no-tty"

Variables

View Source
var (
	FormatTypeJSON = &FormatType{
		Name:  "json",
		Usage: "Print in JSON format",
	}
	FormatTypeGoTemplate = &FormatType{
		Name:      "go-template",
		Usage:     "Print output using the given Go template",
		HasParams: true,
	}
	FormatTypeTable = &FormatType{
		Name:  "table",
		Usage: "Get direct referrers and output in table format",
	}
	FormatTypeTree = &FormatType{
		Name:  "tree",
		Usage: "Get referrers recursively and print in tree format",
	}
)

format types

Functions

func ApplyFlags

func ApplyFlags(optsPtr interface{}, target *pflag.FlagSet)

ApplyFlags applies applicable fields of the passed-in option pointer to the target flag set. NOTE: The option argument need to be a pointer to the options, so its value becomes addressable.

func CheckStdinConflict added in v1.2.0

func CheckStdinConflict(flags *pflag.FlagSet) error

CheckStdinConflict checks if PasswordFromStdin or IdentityTokenFromStdin of a *pflag.FlagSet conflicts with read file from input.

func Parse added in v1.0.0

func Parse(cmd *cobra.Command, optsPtr interface{}) error

Parse parses applicable fields of the passed-in option pointer and returns error during parsing.

Types

type BinaryTarget added in v1.0.0

type BinaryTarget struct {
	From Target
	To   Target
	// contains filtered or unexported fields
}

BinaryTarget struct contains flags and arguments specifying two registries or image layouts. BinaryTarget implements errors.Handler interface.

func (*BinaryTarget) ApplyFlags added in v1.0.0

func (opts *BinaryTarget) ApplyFlags(fs *pflag.FlagSet)

ApplyFlags applies flags to a command flag set fs.

func (*BinaryTarget) EnableDistributionSpecFlag added in v1.0.0

func (opts *BinaryTarget) EnableDistributionSpecFlag()

EnableDistributionSpecFlag set distribution specification flag as applicable.

func (*BinaryTarget) EnsureSourceTargetReferenceNotEmpty added in v1.2.0

func (opts *BinaryTarget) EnsureSourceTargetReferenceNotEmpty(cmd *cobra.Command) error

EnsureSourceTargetReferenceNotEmpty ensures that the from target reference is not empty.

func (*BinaryTarget) Modify added in v1.2.0

func (opts *BinaryTarget) Modify(cmd *cobra.Command, err error) (error, bool)

Modify handles error during cmd execution.

func (*BinaryTarget) Parse added in v1.0.0

func (opts *BinaryTarget) Parse(cmd *cobra.Command) error

Parse parses user-provided flags and arguments into option struct.

type Cache added in v0.15.0

type Cache struct {
	Root string
}

func (*Cache) CachedTarget added in v0.15.0

func (opts *Cache) CachedTarget(src oras.ReadOnlyTarget) (oras.ReadOnlyTarget, error)

CachedTarget gets the target storage with caching if cache root is specified.

type Common

type Common struct {
	Debug   bool
	Verbose bool
	TTY     *os.File
	// contains filtered or unexported fields
}

Common option struct.

func (*Common) ApplyFlags

func (opts *Common) ApplyFlags(fs *pflag.FlagSet)

ApplyFlags applies flags to a command flag set.

func (*Common) Parse added in v1.2.0

func (opts *Common) Parse(*cobra.Command) error

Parse gets target options from user input.

func (*Common) UpdateTTY added in v1.2.0

func (opts *Common) UpdateTTY(flagPresent bool, toSTDOUT bool)

UpdateTTY updates the TTY value, given the status of --no-tty flag and output path value.

type Confirmation added in v0.15.0

type Confirmation struct {
	Force bool
}

Confirmation option struct.

func (*Confirmation) ApplyFlags added in v0.15.0

func (opts *Confirmation) ApplyFlags(fs *pflag.FlagSet)

ApplyFlags applies flags to a command flag set.

func (*Confirmation) AskForConfirmation added in v0.15.0

func (opts *Confirmation) AskForConfirmation(r io.Reader, prompt string) (bool, error)

AskForConfirmation prints a propmt to ask for confirmation before doing an action and takes user input as response.

type Descriptor added in v0.15.0

type Descriptor struct {
	OutputDescriptor bool
}

Descriptor option struct.

func (*Descriptor) ApplyFlags added in v0.15.0

func (opts *Descriptor) ApplyFlags(fs *pflag.FlagSet)

ApplyFlags applies flags to a command flag set.

func (*Descriptor) Marshal added in v0.15.0

func (opts *Descriptor) Marshal(desc ocispec.Descriptor) ([]byte, error)

Marshal returns the JSON encoding of descriptor.

type DistributionSpec added in v1.2.0

type DistributionSpec struct {
	// ReferrersAPI indicates the preference of the implementation of the Referrers API.
	// Set to true for referrers API, false for referrers tag scheme, and nil for auto fallback.
	ReferrersAPI *bool
	// contains filtered or unexported fields
}

DistributionSpec option struct which implements pflag.Value interface.

func (*DistributionSpec) ApplyFlagsWithPrefix added in v1.2.0

func (ds *DistributionSpec) ApplyFlagsWithPrefix(fs *pflag.FlagSet, prefix, description string)

ApplyFlagsWithPrefix applies flags to a command flag set with a prefix string.

func (*DistributionSpec) Options added in v1.2.0

func (ds *DistributionSpec) Options() string

Options returns the string of usable options for the flag.

func (*DistributionSpec) Set added in v1.2.0

func (ds *DistributionSpec) Set(value string) error

Set validates and sets the flag value from a string argument.

func (*DistributionSpec) String added in v1.2.0

func (ds *DistributionSpec) String() string

String returns the string representation of the flag.

func (*DistributionSpec) Type added in v1.2.0

func (ds *DistributionSpec) Type() string

Type returns the string value of the inner flag.

type FlagApplier

type FlagApplier interface {
	ApplyFlags(*pflag.FlagSet)
}

FlagApplier applies flags to a command flag set.

type FlagParser added in v1.0.0

type FlagParser interface {
	Parse(cmd *cobra.Command) error
}

FlagParser parses flags in an option.

type Format added in v1.2.0

type Format struct {
	FormatFlag   string
	Type         string
	Template     string
	AllowedTypes []*FormatType
}

Format contains input and parsed options for formatted output flags.

func (*Format) ApplyFlags added in v1.2.0

func (opts *Format) ApplyFlags(fs *pflag.FlagSet)

ApplyFlag implements FlagProvider.ApplyFlag.

func (*Format) Parse added in v1.2.0

func (opts *Format) Parse(_ *cobra.Command) error

Parse parses the input format flag.

type FormatType added in v1.2.0

type FormatType struct {
	// Name is the format type name.
	Name string
	// Usage is the usage string in help doc.
	Usage string
	// HasParams indicates whether the format type has parameters.
	HasParams bool
}

FormatType represents a format type.

func (*FormatType) WithUsage added in v1.2.0

func (ft *FormatType) WithUsage(usage string) *FormatType

WithUsage returns a new format type with provided usage string.

type ImageSpec added in v1.0.0

type ImageSpec struct {
	Flag        string
	PackVersion oras.PackManifestVersion
}

ImageSpec option struct which implements pflag.Value interface.

func (*ImageSpec) ApplyFlags added in v1.0.0

func (is *ImageSpec) ApplyFlags(fs *pflag.FlagSet)

ApplyFlags applies flags to a command flag set.

func (*ImageSpec) Options added in v1.2.0

func (is *ImageSpec) Options() string

Options returns the string of usable options for the flag.

func (*ImageSpec) Set added in v1.2.0

func (is *ImageSpec) Set(value string) error

Set validates and sets the flag value from a string argument.

func (*ImageSpec) String added in v1.2.0

func (is *ImageSpec) String() string

String returns the string representation of the flag.

func (*ImageSpec) Type added in v1.2.0

func (is *ImageSpec) Type() string

Type returns the string value of the inner flag.

type Packer added in v0.14.0

type Packer struct {
	ManifestExportPath     string
	PathValidationDisabled bool
	AnnotationFilePath     string
	ManifestAnnotations    []string

	FileRefs []string
}

Packer option struct.

func (*Packer) ApplyFlags added in v0.14.0

func (opts *Packer) ApplyFlags(fs *pflag.FlagSet)

ApplyFlags applies flags to a command flag set.

func (*Packer) ExportManifest added in v0.14.0

func (opts *Packer) ExportManifest(ctx context.Context, fetcher content.Fetcher, desc ocispec.Descriptor) error

ExportManifest saves the pushed manifest to a local file.

func (*Packer) LoadManifestAnnotations added in v0.14.0

func (opts *Packer) LoadManifestAnnotations() (annotations map[string]map[string]string, err error)

LoadManifestAnnotations loads the manifest annotation map.

func (*Packer) Parse added in v1.0.1

func (opts *Packer) Parse(*cobra.Command) error

type Platform added in v0.14.0

type Platform struct {
	Platform        *ocispec.Platform
	FlagDescription string
	// contains filtered or unexported fields
}

Platform option struct.

func (*Platform) ApplyFlags added in v0.14.0

func (opts *Platform) ApplyFlags(fs *pflag.FlagSet)

ApplyFlags applies flags to a command flag set.

func (*Platform) Parse added in v0.14.0

func (opts *Platform) Parse(*cobra.Command) error

parse parses the input platform flag to an oci platform type.

type Pretty added in v0.15.0

type Pretty struct {
	Pretty bool
}

Pretty option struct.

func (*Pretty) ApplyFlags added in v0.15.0

func (opts *Pretty) ApplyFlags(fs *pflag.FlagSet)

ApplyFlags applies flags to a command flag set.

func (*Pretty) Output added in v0.15.0

func (opts *Pretty) Output(w io.Writer, content []byte) error

Output outputs the prettified content if `--pretty` flag is used. Otherwise outputs the original content.

type ReadOnlyGraphTagFinderTarget added in v1.0.0

type ReadOnlyGraphTagFinderTarget interface {
	oras.ReadOnlyGraphTarget
	registry.TagLister
}

ReadOnlyGraphTagFinderTarget represents a read-only graph target with tag finder capability.

type Remote

type Remote struct {
	DistributionSpec
	CACertFilePath string
	CertFilePath   string
	KeyFilePath    string
	Insecure       bool
	Configs        []string
	Username       string

	Secret string
	// contains filtered or unexported fields
}

Remote options struct contains flags and arguments specifying one registry. Remote implements oerrors.Handler and interface.

func (*Remote) ApplyFlags

func (opts *Remote) ApplyFlags(fs *pflag.FlagSet)

ApplyFlags applies flags to a command flag set.

func (*Remote) ApplyFlagsWithPrefix added in v0.14.0

func (opts *Remote) ApplyFlagsWithPrefix(fs *pflag.FlagSet, prefix, description string)

ApplyFlagsWithPrefix applies flags to a command flag set with a prefix string. Commonly used for non-unary remote targets.

func (*Remote) ConfigPath added in v1.2.0

func (opts *Remote) ConfigPath() (string, error)

ConfigPath returns the config path of the credential store.

func (*Remote) Credential

func (opts *Remote) Credential() auth.Credential

Credential returns a credential based on the remote options.

func (*Remote) DecorateCredentialError added in v1.2.0

func (opts *Remote) DecorateCredentialError(err error) *oerrors.Error

DecorateCredentialError decorate error with recommendation.

func (*Remote) EnableDistributionSpecFlag added in v1.0.0

func (opts *Remote) EnableDistributionSpecFlag()

EnableDistributionSpecFlag set distribution specification flag as applicable.

func (*Remote) Modify added in v1.2.0

func (opts *Remote) Modify(cmd *cobra.Command, err error) (error, bool)

Modify modifies error during cmd execution.

func (*Remote) NewRegistry

func (opts *Remote) NewRegistry(registry string, common Common, logger logrus.FieldLogger) (reg *remote.Registry, err error)

NewRegistry assembles a oras remote registry.

func (*Remote) NewRepository

func (opts *Remote) NewRepository(reference string, common Common, logger logrus.FieldLogger) (repo *remote.Repository, err error)

NewRepository assembles a oras remote repository.

func (*Remote) Parse added in v1.0.0

func (opts *Remote) Parse(cmd *cobra.Command) error

Parse tries to read password with optional cmd prompt.

type ResolvableDeleter added in v1.2.0

type ResolvableDeleter interface {
	content.Resolver
	content.Deleter
}

type Target added in v1.0.0

type Target struct {
	Remote
	RawReference string
	Type         string
	Reference    string //contains tag or digest
	// Path contains
	//  - path to the OCI image layout target, or
	//  - registry and repository for the remote target
	Path string

	IsOCILayout bool
}

Target struct contains flags and arguments specifying one registry or image layout. Target implements oerrors.Handler interface.

func (*Target) AnnotatedReference added in v1.0.0

func (opts *Target) AnnotatedReference() string

AnnotatedReference returns full printable reference.

func (*Target) ApplyFlags added in v1.0.0

func (opts *Target) ApplyFlags(fs *pflag.FlagSet)

ApplyFlags applies flags to a command flag set for unary target

func (*Target) ApplyFlagsWithPrefix added in v1.0.0

func (opts *Target) ApplyFlagsWithPrefix(fs *pflag.FlagSet, prefix, description string)

ApplyFlagsWithPrefix applies flags to a command flag set with a prefix string. Commonly used for non-unary remote targets.

func (*Target) EnsureReferenceNotEmpty added in v1.0.0

func (opts *Target) EnsureReferenceNotEmpty(cmd *cobra.Command, needsTag bool) error

EnsureReferenceNotEmpty returns formalized error when the reference is empty.

func (*Target) Modify added in v1.2.0

func (opts *Target) Modify(cmd *cobra.Command, err error) (error, bool)

Modify handles error during cmd execution.

func (*Target) NewBlobDeleter added in v1.2.0

func (opts *Target) NewBlobDeleter(common Common, logger logrus.FieldLogger) (ResolvableDeleter, error)

NewBlobDeleter generates a new blob deleter based on opts.

func (*Target) NewManifestDeleter added in v1.2.0

func (opts *Target) NewManifestDeleter(common Common, logger logrus.FieldLogger) (ResolvableDeleter, error)

NewManifestDeleter generates a new blob deleter based on opts.

func (*Target) NewReadonlyTarget added in v1.0.0

func (opts *Target) NewReadonlyTarget(ctx context.Context, common Common, logger logrus.FieldLogger) (ReadOnlyGraphTagFinderTarget, error)

NewReadonlyTargets generates a new read only target based on opts.

func (*Target) NewTarget added in v1.0.0

func (opts *Target) NewTarget(common Common, logger logrus.FieldLogger) (oras.GraphTarget, error)

NewTarget generates a new target based on opts.

func (*Target) Parse added in v1.0.0

func (opts *Target) Parse(cmd *cobra.Command) error

Parse gets target options from user input.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL