registry

package
v0.0.0-...-5f60744 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

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

	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"
)
View Source
const (
	FlagSaveToDocker = "save-to-docker"
)

Registry command flag names

View Source
const (
	FlagSaveToDockerUsage = "Save pulled image to docker"
)

Registry command flag usage info

Variables

View Source
var CLI = &cli.Command{
	Name:    Name,
	Aliases: []string{Alias},
	Usage:   Usage,
	Subcommands: []*cli.Command{
		{
			Name:  PullCmdName,
			Usage: PullCmdNameUsage,
			Flags: []cli.Flag{
				commands.Cflag(commands.FlagTarget),
				cflag(FlagSaveToDocker),
			},
			Action: func(ctx *cli.Context) error {
				xc := app.NewExecutionContext(fullCmdName(PullCmdName), ctx.String(commands.FlagConsoleFormat))

				gcvalues, err := commands.GlobalFlagValues(ctx)
				if err != nil {
					return err
				}

				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,
			Action: func(ctx *cli.Context) error {
				gcvalues, err := commands.GlobalFlagValues(ctx)
				if err != nil {
					return err
				}

				xc := app.NewExecutionContext(fullCmdName(PushCmdName), ctx.String(commands.FlagConsoleFormat))
				OnPushCommand(xc, gcvalues)
				return nil
			},
		},
		{
			Name:  CopyCmdName,
			Usage: CopyCmdNameUsage,
			Action: func(ctx *cli.Context) error {
				gcvalues, err := commands.GlobalFlagValues(ctx)
				if err != nil {
					return err
				}

				xc := app.NewExecutionContext(fullCmdName(CopyCmdName), ctx.String(commands.FlagConsoleFormat))
				OnCopyCommand(xc, gcvalues)
				return nil
			},
		},
	},
}
View Source
var CommandSuggestion = prompt.Suggest{
	Text:        Name,
	Description: Usage,
}
View Source
var Flags = map[string]cli.Flag{
	FlagSaveToDocker: &cli.BoolFlag{
		Name:    FlagSaveToDocker,
		Value:   true,
		Usage:   FlagSaveToDockerUsage,
		EnvVars: []string{"DSLIM_REG_PULL_SAVE_TO_DOCKER"},
	},
}

Functions

func OnCopyCommand

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

OnCopyCommand implements the 'registry copy' docker-slim command

func OnPullCommand

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

OnPullCommand implements the 'registry pull' command

func OnPushCommand

func OnPushCommand(
	xc *app.ExecutionContext,
	gparams *commands.GenericParams)

OnPushCommand implements the 'registry push' docker-slim command

func RegisterCommand

func RegisterCommand()

Types

type PullCommandParams

type PullCommandParams struct {
	TargetRef    string
	SaveToDocker bool
}

func PullCommandFlagValues

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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