mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
commands: imagetools stubs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
41
commands/imagetools/create.go
Normal file
41
commands/imagetools/create.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/docker/cli/cli/command"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
type createOptions struct {
|
||||||
|
files []string
|
||||||
|
tags []string
|
||||||
|
dryrun bool
|
||||||
|
append bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func runCreate(dockerCli command.Cli, in createOptions, args []string) error {
|
||||||
|
return errors.Errorf("not-implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func createCmd(dockerCli command.Cli) *cobra.Command {
|
||||||
|
var options createOptions
|
||||||
|
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "create [OPTIONS] [SOURCE...]",
|
||||||
|
Short: "Create a new image based on source images",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
return runCreate(dockerCli, options, args)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
flags := cmd.Flags()
|
||||||
|
|
||||||
|
flags.StringArrayVarP(&options.files, "file", "f", []string{}, "Read source descriptor from file")
|
||||||
|
flags.StringArrayVarP(&options.tags, "tag", "t", []string{}, "Set reference for new image")
|
||||||
|
flags.BoolVar(&options.dryrun, "dry-run", false, "Show final image instead of pushing")
|
||||||
|
flags.BoolVar(&options.append, "append", false, "Append to existing manifest")
|
||||||
|
|
||||||
|
_ = flags
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
37
commands/imagetools/inspect.go
Normal file
37
commands/imagetools/inspect.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/docker/cli/cli"
|
||||||
|
"github.com/docker/cli/cli/command"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
type inspectOptions struct {
|
||||||
|
raw bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func runInspect(dockerCli command.Cli, in inspectOptions, name string) error {
|
||||||
|
return errors.Errorf("not-implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func inspectCmd(dockerCli command.Cli) *cobra.Command {
|
||||||
|
var options inspectOptions
|
||||||
|
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "inspect [OPTIONS] NAME",
|
||||||
|
Short: "Show details of image in the registry",
|
||||||
|
Args: cli.ExactArgs(1),
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
return runInspect(dockerCli, options, args[0])
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
flags := cmd.Flags()
|
||||||
|
|
||||||
|
flags.BoolVar(&options.raw, "raw", false, "Show original JSON manifest")
|
||||||
|
|
||||||
|
_ = flags
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
20
commands/imagetools/root.go
Normal file
20
commands/imagetools/root.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/docker/cli/cli/command"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RootCmd(dockerCli command.Cli) *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "imagetools",
|
||||||
|
Short: "Commands to work on images in registry",
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.AddCommand(
|
||||||
|
inspectCmd(dockerCli),
|
||||||
|
createCmd(dockerCli),
|
||||||
|
)
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/docker/cli/cli-plugins/plugin"
|
"github.com/docker/cli/cli-plugins/plugin"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
imagetoolscmd "github.com/tonistiigi/buildx/commands/imagetools"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewRootCmd(name string, isPlugin bool, dockerCli command.Cli) *cobra.Command {
|
func NewRootCmd(name string, isPlugin bool, dockerCli command.Cli) *cobra.Command {
|
||||||
@ -31,5 +32,6 @@ func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
|
|||||||
useCmd(dockerCli),
|
useCmd(dockerCli),
|
||||||
inspectCmd(dockerCli),
|
inspectCmd(dockerCli),
|
||||||
stopCmd(dockerCli),
|
stopCmd(dockerCli),
|
||||||
|
imagetoolscmd.RootCmd(dockerCli),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user