registry

package
v0.0.0-...-9159377 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name  = "registry"
	Usage = "Execute registry operations"
	Alias = "reg"

	PullCmdName      = "pull"
	PullCmdNameUsage = "Pull a container image from registry"

	PushCmdName      = "push"
	PushCmdNameUsage = "Push a container image to a registry"

	CopyCmdName      = "copy"
	CopyCmdNameUsage = "Copy a container image from one registry to another"

	ImageIndexCreateCmdName      = "image-index-create"
	ImageIndexCreateCmdNameUsage = "Create an image index (aka manifest list) with the referenced images (already in the target registry)"

	ServerCmdName      = "server"
	ServerCmdNameUsage = "Start a registry server"
)
View Source
const (
	FlagUseDockerCreds      = "use-docker-credentials"
	FlagUseDockerCredsUsage = "Use the registry credentials from the default Docker config file"

	FlagCredsAccount      = "account"
	FlagCredsAccountUsage = "Registry credentials account"

	FlagCredsSecret      = "secret"
	FlagCredsSecretUsage = "Registry credentials secret"

	FlagSaveToDocker      = "save-to-docker"
	FlagSaveToDockerUsage = "Save pulled image to docker"

	FlagDocker      = "docker"
	FlagDockerUsage = "Push local docker image"

	FlagTar      = "tar"
	FlagTarUsage = "Push image from a local tar file"

	FlagOCI      = "oci"
	FlagOCIUsage = "Push image from a local OCI Image Layout directory"

	FlagAs      = "as"
	FlagAsUsage = "Tag the selected image with the specified name before pushing"

	FlagImageIndexName      = "image-index-name"
	FlagImageIndexNameUsage = "Image index name to use"

	FlagImageName      = "image-name"
	FlagImageNameUsage = "Target image name to include in image index"

	FlagAsManifestList      = "as-manifest-list"
	FlagAsManifestListUsage = "Create image index with the manifest list media type instead of the default OCI image index type"

	FlagInsecureRefs      = "insecure-refs"
	FlagInsecureRefsUsage = "Allow the referenced images from insecure registry connections"

	FlagDumpRawManifest      = "dump-raw-manifest"
	FlagDumpRawManifestUsage = "Dump raw manifest for the created image index"

	FlagAddress      = "address"
	FlagAddressUsage = "Registry server address"

	FlagPort      = "port"
	FlagPortUsage = "Registry server port"

	FlagDomain      = "domain"
	FlagDomainUsage = "Domain to use for registry server (to get certs)"

	FlagHTTPS      = "https"
	FlagHTTPSUsage = "Use HTTPS"

	FlagCertPath      = "cert-path"
	FlagCertPathUsage = "Cert path for use with HTTPS"

	FlagKeyPath      = "key-path"
	FlagKeyPathUsage = "Key path for use with HTTPS"

	FlagReferrersAPI      = "referrers-api"
	FlagReferrersAPIUsage = "Enables the referrers API endpoint (OCI 1.1+) for the registry server"

	FlagStorePath      = "store-path"
	FlagStorePathUsage = "Directory to store registry blobs"

	FlagMemStore      = "mem-store"
	FlagMemStoreUsage = "Use memory registry blob store"
)

Registry command flag names

Variables

View Source
var CLI = &cli.Command{
	Name:    Name,
	Aliases: []string{Alias},
	Usage:   Usage,
	Flags: []cli.Flag{
		cflag(FlagUseDockerCreds),
		cflag(FlagCredsAccount),
		cflag(FlagCredsSecret),
	},
	Subcommands: []*cli.Command{
		{
			Name:  PullCmdName,
			Usage: PullCmdNameUsage,
			Flags: []cli.Flag{
				command.Cflag(command.FlagTarget),
				cflag(FlagSaveToDocker),
			},
			Action: func(ctx *cli.Context) error {
				gcvalues := command.GlobalFlagValues(ctx)
				xc := app.NewExecutionContext(
					fullCmdName(PullCmdName),
					gcvalues.QuietCLIMode,
					gcvalues.OutputFormat)

				cparams, err := PullCommandFlagValues(ctx)
				if err != nil {
					return err
				}

				if cparams.TargetRef == "" {
					if ctx.Args().Len() < 1 {
						xc.Out.Error("param.target", "missing target")
						cli.ShowCommandHelp(ctx, Name)
						return nil
					} else {
						cparams.TargetRef = ctx.Args().First()
					}
				}

				OnPullCommand(xc, gcvalues, cparams)
				return nil
			},
		},
		{
			Name:  PushCmdName,
			Usage: PushCmdNameUsage,
			Flags: []cli.Flag{
				cflag(FlagAs),
				cflag(FlagDocker),
				cflag(FlagTar),
				cflag(FlagOCI),
			},
			Action: func(ctx *cli.Context) error {
				gcvalues := command.GlobalFlagValues(ctx)
				xc := app.NewExecutionContext(
					fullCmdName(PushCmdName),
					gcvalues.QuietCLIMode,
					gcvalues.OutputFormat)

				cparams, err := PushCommandFlagValues(ctx)
				if err != nil {
					xc.Out.Error("params", err.Error())
					return err
				}

				if cparams.TargetType == "" {
					if ctx.Args().Len() < 1 {
						xc.Out.Error("params.target", "missing pull target")
						return fmt.Errorf("no target selected")
					}

					cparams.TargetRef = ctx.Args().First()
					cparams.TargetType = ttDocker
				}

				OnPushCommand(xc, gcvalues, cparams)
				return nil
			},
		},
		{
			Name:  CopyCmdName,
			Usage: CopyCmdNameUsage,
			Action: func(ctx *cli.Context) error {
				gcvalues := command.GlobalFlagValues(ctx)
				xc := app.NewExecutionContext(
					fullCmdName(CopyCmdName),
					gcvalues.QuietCLIMode,
					gcvalues.OutputFormat)

				OnCopyCommand(xc, gcvalues)
				return nil
			},
		},
		{
			Name:  ImageIndexCreateCmdName,
			Usage: ImageIndexCreateCmdNameUsage,
			Flags: []cli.Flag{
				cflag(FlagImageIndexName),
				cflag(FlagImageName),
				cflag(FlagAsManifestList),
				cflag(FlagInsecureRefs),
				cflag(FlagDumpRawManifest),
			},
			Action: func(ctx *cli.Context) error {
				gcvalues := command.GlobalFlagValues(ctx)
				xc := app.NewExecutionContext(
					fullCmdName(ImageIndexCreateCmdName),
					gcvalues.QuietCLIMode,
					gcvalues.OutputFormat)

				cparams, err := ImageIndexCreateCommandFlagValues(ctx)
				if err != nil {
					return err
				}

				OnImageIndexCreateCommand(xc, gcvalues, cparams)
				return nil
			},
		},
		{
			Name:  ServerCmdName,
			Usage: ServerCmdNameUsage,
			Flags: []cli.Flag{
				cflag(FlagDomain),
				cflag(FlagAddress),
				cflag(FlagPort),
				cflag(FlagHTTPS),
				cflag(FlagCertPath),
				cflag(FlagKeyPath),
				cflag(FlagReferrersAPI),
			},
			Action: func(ctx *cli.Context) error {
				gcvalues := command.GlobalFlagValues(ctx)
				xc := app.NewExecutionContext(
					fullCmdName(ServerCmdName),
					gcvalues.QuietCLIMode,
					gcvalues.OutputFormat)

				cparams, err := ServerCommandFlagValues(ctx)
				if err != nil {
					return err
				}

				OnServerCommand(xc, gcvalues, cparams)
				return nil
			},
		},
	},
}
View Source
var CommandFlagSuggestions = &command.FlagSuggestions{
	Names: []prompt.Suggest{
		{Text: command.FullFlagName(FlagUseDockerCreds), Description: FlagUseDockerCredsUsage},
		{Text: command.FullFlagName(FlagCredsAccount), Description: FlagCredsAccountUsage},
		{Text: command.FullFlagName(FlagCredsSecret), Description: FlagCredsSecretUsage},

		{Text: PullCmdName, Description: PullCmdNameUsage},
		{Text: PushCmdName, Description: PushCmdNameUsage},
		{Text: ImageIndexCreateCmdName, Description: ImageIndexCreateCmdNameUsage},
		{Text: ServerCmdName, Description: ServerCmdNameUsage},
	},
	Values: map[string]command.CompleteValue{},
}
View Source
var CommandSuggestion = prompt.Suggest{
	Text:        Name,
	Description: Usage,
}
View Source
var Flags = map[string]cli.Flag{
	FlagUseDockerCreds: &cli.BoolFlag{
		Name:    FlagUseDockerCreds,
		Value:   false,
		Usage:   FlagUseDockerCredsUsage,
		EnvVars: []string{"DSLIM_REG_DOCKER_CREDS"},
	},
	FlagCredsAccount: &cli.StringFlag{
		Name:    FlagCredsAccount,
		Value:   "",
		Usage:   FlagCredsAccountUsage,
		EnvVars: []string{"DSLIM_REG_ACCOUNT"},
	},
	FlagCredsSecret: &cli.StringFlag{
		Name:    FlagCredsSecret,
		Value:   "",
		Usage:   FlagCredsSecretUsage,
		EnvVars: []string{"DSLIM_REG_SECRET"},
	},

	FlagSaveToDocker: &cli.BoolFlag{
		Name:    FlagSaveToDocker,
		Value:   true,
		Usage:   FlagSaveToDockerUsage,
		EnvVars: []string{"DSLIM_REG_PULL_SAVE_TO_DOCKER"},
	},

	FlagDocker: &cli.StringFlag{
		Name:    FlagDocker,
		Value:   "",
		Usage:   FlagDockerUsage,
		EnvVars: []string{"DSLIM_REG_PUSH_DOCKER"},
	},
	FlagTar: &cli.StringFlag{
		Name:    FlagTar,
		Value:   "",
		Usage:   FlagTarUsage,
		EnvVars: []string{"DSLIM_REG_PUSH_TAR"},
	},
	FlagOCI: &cli.StringFlag{
		Name:    FlagOCI,
		Value:   "",
		Usage:   FlagOCIUsage,
		EnvVars: []string{"DSLIM_REG_PUSH_OCI"},
	},
	FlagAs: &cli.StringFlag{
		Name:    FlagAs,
		Value:   "",
		Usage:   FlagAsUsage,
		EnvVars: []string{"DSLIM_REG_PUSH_AS"},
	},

	FlagImageIndexName: &cli.StringFlag{
		Name:    FlagImageIndexName,
		Value:   "",
		Usage:   FlagImageIndexNameUsage,
		EnvVars: []string{"DSLIM_REG_IIC_INDEX_NAME"},
	},
	FlagImageName: &cli.StringSliceFlag{
		Name:    FlagImageName,
		Value:   cli.NewStringSlice(),
		Usage:   FlagImageNameUsage,
		EnvVars: []string{"DSLIM_REG_IIC_IMAGE_NAME"},
	},
	FlagAsManifestList: &cli.BoolFlag{
		Name:    FlagAsManifestList,
		Value:   false,
		Usage:   FlagAsManifestListUsage,
		EnvVars: []string{"DSLIM_REG_IIC_AS_MLIST"},
	},
	FlagInsecureRefs: &cli.BoolFlag{
		Name:    FlagInsecureRefs,
		Value:   false,
		Usage:   FlagInsecureRefsUsage,
		EnvVars: []string{"DSLIM_REG_IIC_INSECURE_REFS"},
	},
	FlagDumpRawManifest: &cli.BoolFlag{
		Name:    FlagDumpRawManifest,
		Value:   false,
		Usage:   FlagDumpRawManifestUsage,
		EnvVars: []string{"DSLIM_REG_IIC_DUMP_MANIFEST"},
	},

	FlagReferrersAPI: &cli.BoolFlag{
		Name:    FlagReferrersAPI,
		Value:   true,
		Usage:   FlagReferrersAPIUsage,
		EnvVars: []string{"DSLIM_REG_SRV_REFERRERS_API"},
	},
	FlagDomain: &cli.StringFlag{
		Name:    FlagDomain,
		Value:   "",
		Usage:   FlagDomainUsage,
		EnvVars: []string{"DSLIM_REG_SRV_DOMAIN"},
	},
	FlagAddress: &cli.StringFlag{
		Name:    FlagAddress,
		Value:   "0.0.0.0",
		Usage:   FlagAddressUsage,
		EnvVars: []string{"DSLIM_REG_SRV_ADDR"},
	},
	FlagPort: &cli.UintFlag{
		Name:    FlagPort,
		Value:   5000,
		Usage:   FlagPortUsage,
		EnvVars: []string{"DSLIM_REG_SRV_PORT"},
	},
	FlagHTTPS: &cli.BoolFlag{
		Name:    FlagHTTPS,
		Value:   false,
		Usage:   FlagHTTPSUsage,
		EnvVars: []string{"DSLIM_REG_SRV_HTTPS"},
	},
	FlagCertPath: &cli.StringFlag{
		Name:    FlagCertPath,
		Value:   "",
		Usage:   FlagCertPathUsage,
		EnvVars: []string{"DSLIM_REG_SRV_CERT"},
	},
	FlagKeyPath: &cli.StringFlag{
		Name:    FlagKeyPath,
		Value:   "",
		Usage:   FlagKeyPathUsage,
		EnvVars: []string{"DSLIM_REG_SRV_KEY"},
	},
	FlagStorePath: &cli.StringFlag{
		Name:    FlagStorePath,
		Value:   "registry_server_data",
		Usage:   FlagStorePathUsage,
		EnvVars: []string{"DSLIM_REG_SRV_STORE_PATH"},
	},
	FlagMemStore: &cli.BoolFlag{
		Name:    FlagMemStore,
		Value:   false,
		Usage:   FlagMemStoreUsage,
		EnvVars: []string{"DSLIM_REG_SRV_MEM_STORE"},
	},
}

Functions

func ConfigureAuth

func ConfigureAuth(cparams *CommonCommandParams, remoteOpts []remote.Option) ([]remote.Option, error)

func OnCopyCommand

func OnCopyCommand(
	xc *app.ExecutionContext,
	gparams *command.GenericParams)

OnCopyCommand implements the 'registry copy' command

func OnImageIndexCreateCommand

func OnImageIndexCreateCommand(
	xc *app.ExecutionContext,
	gparams *command.GenericParams,
	cparams *ImageIndexCreateCommandParams)

OnImageIndexCreateCommand implements the 'registry image-index-create' command

func OnPullCommand

func OnPullCommand(
	xc *app.ExecutionContext,
	gparams *command.GenericParams,
	cparams *PullCommandParams)

OnPullCommand implements the 'registry pull' command

func OnPushCommand

func OnPushCommand(
	xc *app.ExecutionContext,
	gparams *command.GenericParams,
	cparams *PushCommandParams)

OnPushCommand implements the 'registry push' command

func OnServerCommand

func OnServerCommand(
	xc *app.ExecutionContext,
	gparams *command.GenericParams,
	cparams *ServerCommandParams)

OnServerCommand implements the 'registry server' command

func RegisterCommand

func RegisterCommand()

Types

type CommonCommandParams

type CommonCommandParams struct {
	UseDockerCreds bool
	CredsAccount   string
	CredsSecret    string
}

func CommonCommandFlagValues

func CommonCommandFlagValues(ctx *cli.Context) (*CommonCommandParams, error)

type ImageIndexCreateCommandParams

type ImageIndexCreateCommandParams struct {
	*CommonCommandParams
	ImageIndexName  string
	ImageNames      []string
	AsManifestList  bool
	InsecureRefs    bool
	DumpRawManifest bool
}

func ImageIndexCreateCommandFlagValues

func ImageIndexCreateCommandFlagValues(ctx *cli.Context) (*ImageIndexCreateCommandParams, error)

type PullCommandParams

type PullCommandParams struct {
	*CommonCommandParams
	TargetRef    string
	SaveToDocker bool
}

func PullCommandFlagValues

func PullCommandFlagValues(ctx *cli.Context) (*PullCommandParams, error)

type PushCommandParams

type PushCommandParams struct {
	*CommonCommandParams
	TargetRef  string
	TargetType string
	AsTag      string
}

func PushCommandFlagValues

func PushCommandFlagValues(ctx *cli.Context) (*PushCommandParams, error)

type ServerCommandParams

type ServerCommandParams struct {
	*CommonCommandParams
	Domain       string
	Address      string
	Port         uint
	UseHTTPS     bool
	CertPath     string
	KeyPath      string
	ReferrersAPI bool
	StorePath    string
	UseMemStore  bool
}

func ServerCommandFlagValues

func ServerCommandFlagValues(ctx *cli.Context) (*ServerCommandParams, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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