TEMPLATE for prune command
parent
9d25a0e5d5
commit
6273a2932a
@ -1,27 +0,0 @@
|
|||||||
package commands
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/docker/buildx/version"
|
|
||||||
"github.com/docker/cli/cli"
|
|
||||||
"github.com/docker/cli/cli/command"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
func runHelloWorld(dockerCli command.Cli) error {
|
|
||||||
fmt.Println("hello world")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func helloCmd(dockerCli command.Cli) *cobra.Command {
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "hello",
|
|
||||||
Short: "I think this is how cmds are added ",
|
|
||||||
Args: cli.ExactArgs(0),
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
|
||||||
return runHelloWorld(dockerCli)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return cmd
|
|
||||||
}
|
|
@ -1,51 +1,28 @@
|
|||||||
// Command used for prune
|
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
import "github.com/docker/cli/cli/command"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/docker/cli/cli"
|
||||||
|
"github.com/docker/cli/cli/command"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func runPrune(dockerCli command.Cli) error {
|
||||||
|
fmt.Println("ASDF run prune")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func pruneCmd(dockerCli command.Cli) *cobra.Command {
|
func pruneCmd(dockerCli command.Cli) *cobra.Command {
|
||||||
fmt.Println("ASDF - pruneCmd")
|
fmt.Println("ASDF prune command added")
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "docker buildx prune"
|
Use: "prune",
|
||||||
Short: "Cleans up the build cache"
|
Short: "clear the buildx build cache ",
|
||||||
Args: cli.NoArgs
|
Args: cli.ExactArgs(0),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
spaceReclaimed, output, err := runPrune(dockerCli, options)
|
return runPrune(dockerCli)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if output != "" {
|
|
||||||
fmt.Fprintln(dockerCli.Out(), output)
|
|
||||||
}
|
|
||||||
fmt.Fprintln(dockerCli.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed)))
|
|
||||||
return nil
|
|
||||||
|
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{"version": "1.00"},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToDo: Uncomment and test this out once we get the base feature working
|
|
||||||
//flags := cmd.Flags()
|
|
||||||
//flags.BoolVarP(&options.force, "force", "f", false, "Do not prompt for confirmation")
|
|
||||||
//flags.Var(&options.filter, "filter", "Provide filter values (e.g. 'until=<timestamp>')")
|
|
||||||
|
|
||||||
const (
|
|
||||||
normalWarning = `WARNING! This will remove all dangling build cache. Are you sure you want to continue?`
|
|
||||||
allCacheWarning = `WARNING! This will remove all build cache. Are you sure you want to continue?`
|
|
||||||
)
|
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func runPrune(dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, err error) {
|
|
||||||
fmt.Println("ASDF runPrune - Hello world")
|
|
||||||
|
|
||||||
// ToDo: Implement this function
|
|
||||||
|
|
||||||
return 0, "Not implemented", nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue