Skip to content

Commit

Permalink
registry command placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
kcq committed Jan 10, 2022
1 parent 2bccb49 commit f24f35d
Show file tree
Hide file tree
Showing 246 changed files with 12,741 additions and 5,480 deletions.
25 changes: 18 additions & 7 deletions go.mod
Expand Up @@ -3,7 +3,7 @@ module github.com/docker-slim/docker-slim
go 1.13

require (
github.com/Microsoft/hcsshim v0.8.22 // indirect
github.com/Microsoft/go-winio v0.5.1 // indirect
github.com/PuerkitoBio/goquery v1.5.1 // indirect
github.com/andybalholm/cascadia v1.2.0 // indirect
github.com/antchfx/htmlquery v1.2.3 // indirect
Expand All @@ -16,38 +16,49 @@ require (
github.com/c-bata/go-prompt v0.2.3
github.com/c4milo/unpackit v0.0.0-20170704181138-4ed373e9ef1c
github.com/compose-spec/compose-go v0.0.0-20210916141509-a7e1bc322970
github.com/containerd/containerd v1.5.8 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/docker-slim/go-update v0.0.0-20190422071557-ed40247aff59
github.com/docker-slim/uilive v0.0.2 // indirect
github.com/docker-slim/uiprogress v0.0.0-20190505193231-9d4396e6d40b
github.com/docker/docker v20.10.8+incompatible
github.com/docker/docker v20.10.12+incompatible
github.com/docker/go-connections v0.4.0
github.com/dsnet/compress v0.0.1 // indirect
github.com/dustin/go-humanize v1.0.0
github.com/fatih/color v1.10.0
github.com/fatih/color v1.13.0
github.com/fsouza/go-dockerclient v1.7.4
github.com/getkin/kin-openapi v0.19.0
github.com/ghodss/yaml v1.0.0
github.com/gocolly/colly/v2 v2.0.1
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/gorilla/websocket v1.4.2
github.com/gosuri/uilive v0.0.3 // indirect
github.com/hooklift/assert v0.0.0-20170704181755-9d1defd6d214 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/klauspost/pgzip v1.2.4 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mattn/go-tty v0.0.3 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6
github.com/opencontainers/runc v1.0.2 // indirect
github.com/opencontainers/image-spec v1.0.2-0.20211117181255-693428a734f5 // indirect
github.com/pkg/errors v0.9.1
github.com/pkg/term v0.0.0-20200520122047-c3ffed290a03 // indirect
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.0 // indirect
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
github.com/ulikunitz/xz v0.5.7 // indirect
github.com/urfave/cli/v2 v2.3.0
go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
golang.org/x/sys v0.0.0-20210921065528-437939a70204
google.golang.org/appengine v1.6.6 // indirect
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

replace github.com/compose-spec/compose-go => ./pkg/third_party/compose-go
62 changes: 52 additions & 10 deletions go.sum

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pkg/app/master/cli.go
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/docker-slim/docker-slim/pkg/app/master/commands/lint"
"github.com/docker-slim/docker-slim/pkg/app/master/commands/probe"
"github.com/docker-slim/docker-slim/pkg/app/master/commands/profile"
"github.com/docker-slim/docker-slim/pkg/app/master/commands/registry"
"github.com/docker-slim/docker-slim/pkg/app/master/commands/run"
"github.com/docker-slim/docker-slim/pkg/app/master/commands/server"
"github.com/docker-slim/docker-slim/pkg/app/master/commands/update"
Expand All @@ -43,6 +44,7 @@ func registerCommands() {
xray.RegisterCommand()
lint.RegisterCommand()
build.RegisterCommand()
registry.RegisterCommand()
profile.RegisterCommand()
version.RegisterCommand()
help.RegisterCommand()
Expand Down
97 changes: 97 additions & 0 deletions pkg/app/master/commands/registry/cli.go
@@ -0,0 +1,97 @@
package registry

import (
"fmt"

"github.com/docker-slim/docker-slim/pkg/app"
"github.com/docker-slim/docker-slim/pkg/app/master/commands"

"github.com/urfave/cli/v2"
)

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"
)

func fullCmdName(subCmdName string) string {
return fmt.Sprintf("%s.%s", Name, subCmdName)
}

type PullCommandParams struct {
SaveToDocker bool
}

func PullCommandFlagValues(ctx *cli.Context) (*PullCommandParams, error) {
values := &PullCommandParams{
SaveToDocker: ctx.Bool(FlagSaveToDocker),
}

return values, nil
}

var CLI = &cli.Command{
Name: Name,
Aliases: []string{Alias},
Usage: Usage,
Subcommands: []*cli.Command{
{
Name: PullCmdName,
Usage: PullCmdNameUsage,
Flags: []cli.Flag{
cflag(FlagSaveToDocker),
},
Action: func(ctx *cli.Context) error {
gcvalues, err := commands.GlobalFlagValues(ctx)
if err != nil {
return err
}

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

xc := app.NewExecutionContext(fullCmdName(PullCmdName))
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))
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))
OnCopyCommand(xc, gcvalues)
return nil
},
},
},
}
34 changes: 34 additions & 0 deletions pkg/app/master/commands/registry/flags.go
@@ -0,0 +1,34 @@
package registry

import (
log "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)

// Registry command flag names
const (
FlagSaveToDocker = "save-to-docker"
)

// Registry command flag usage info
const (
FlagSaveToDockerUsage = "Save pulled image to docker"
)

var Flags = map[string]cli.Flag{
FlagSaveToDocker: &cli.BoolFlag{
Name: FlagSaveToDocker,
Value: true, //defaults to true
Usage: FlagSaveToDockerUsage,
EnvVars: []string{"DSLIM_REG_PULL_SAVE_TO_DOCKER"},
},
}

func cflag(name string) cli.Flag {
cf, ok := Flags[name]
if !ok {
log.Fatalf("unknown flag='%s'", name)
}

return cf
}

0 comments on commit f24f35d

Please sign in to comment.