Skip to content

Commit

Permalink
rename debug flags to cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tejal29 committed Apr 26, 2019
1 parent 0d92d62 commit 9213f18
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 37 deletions.
10 changes: 5 additions & 5 deletions cmd/skaffold/app/cmd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ func NewCmdDebug(out io.Writer) *cobra.Command {
return debug(out)
},
Annotations: map[string]string{
BuildAnnotation: "true",
DeployAnnotation: "true",
TestAnnotation: "true",
DebugAnnotation: "true",
EventsAnnotation: "true",
BuildAnnotation: "true",
DeployAnnotation: "true",
TestAnnotation: "true",
CleanupAnnotation: "true",
EventsAnnotation: "true",
},
}
overrideTailFlag(cmd)
Expand Down
10 changes: 5 additions & 5 deletions cmd/skaffold/app/cmd/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ func NewCmdDev(out io.Writer) *cobra.Command {
return dev(out)
},
Annotations: map[string]string{
BuildAnnotation: "true",
DeployAnnotation: "true",
TestAnnotation: "true",
EventsAnnotation: "true",
DebugAnnotation: "true",
BuildAnnotation: "true",
DeployAnnotation: "true",
TestAnnotation: "true",
EventsAnnotation: "true",
CleanupAnnotation: "true",
},
}
overrideTailFlag(cmd)
Expand Down
41 changes: 20 additions & 21 deletions cmd/skaffold/app/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@ import (
)

const (
BuildAnnotation = "build"
DeployAnnotation = "deploy"
TestAnnotation = "test"
DeleteAnnotation = "delete"
DebugAnnotation = "debug"
EventsAnnotation = "events"
BuildAnnotation = "build"
DeployAnnotation = "deploy"
TestAnnotation = "test"
DeleteAnnotation = "delete"
CleanupAnnotation = "cleanup"
EventsAnnotation = "events"
)

var (
CommandFlags = commandFlagSet("common")
CommonFlagSet = commonFlagSet("common")

AnnotationToFlag = map[string]*flag.FlagSet{
BuildAnnotation: buildFlagSet(BuildAnnotation),
EventsAnnotation: eventsAPIFlagSet(EventsAnnotation),
DeployAnnotation: deployFlagSet(DeployAnnotation),
TestAnnotation: testFlagSet(TestAnnotation),
DebugAnnotation: debugFlagSet(DebugAnnotation),
BuildAnnotation: buildFlagSet(BuildAnnotation),
EventsAnnotation: eventsAPIFlagSet(EventsAnnotation),
DeployAnnotation: deployFlagSet(DeployAnnotation),
TestAnnotation: testFlagSet(TestAnnotation),
CleanupAnnotation: cleanupFlagSet(CleanupAnnotation),
}
)

func commandFlagSet(name string) *flag.FlagSet {
func commonFlagSet(name string) *flag.FlagSet {
commonFlags := flag.NewFlagSet(name, flag.ContinueOnError)
commonFlags.StringVarP(&opts.ConfigurationFile, "filename", "f", "skaffold.yaml", "Filename or URL to the pipeline file")
commonFlags.StringArrayVarP(&opts.Profiles, "profile", "p", nil, "Activate profiles by name")
Expand Down Expand Up @@ -83,16 +83,16 @@ func testFlagSet(name string) *flag.FlagSet {
return testFlags
}

func debugFlagSet(name string) *flag.FlagSet {
debugFlags := flag.NewFlagSet(name, flag.ContinueOnError)
debugFlags.BoolVar(&opts.Cleanup, "cleanup", true, "Delete deployments after dev or debug mode is interrupted")
debugFlags.BoolVar(&opts.PortForward, "port-forward", true, "Port-forward exposed container ports within pods")
debugFlags.BoolVar(&opts.NoPrune, "no-prune", false, "Skip removing images and containers built by Skaffold")
return debugFlags
func cleanupFlagSet(name string) *flag.FlagSet {
cleanupFlags := flag.NewFlagSet(name, flag.ContinueOnError)
cleanupFlags.BoolVar(&opts.Cleanup, "cleanup", true, "Delete deployments after dev or debug mode is interrupted")
cleanupFlags.BoolVar(&opts.PortForward, "port-forward", true, "Port-forward exposed container ports within pods")
cleanupFlags.BoolVar(&opts.NoPrune, "no-prune", false, "Skip removing images and containers built by Skaffold")
return cleanupFlags
}

func AddFlags(cmd *cobra.Command) {
cmd.Flags().AddFlagSet(CommandFlags)
cmd.Flags().AddFlagSet(CommonFlagSet)
cmd.Flags().AddFlagSet(getAnnotatedFlags(cmd.Use, cmd.Annotations))
}

Expand All @@ -109,5 +109,4 @@ func getAnnotatedFlags(name string, annotations map[string]string) *flag.FlagSet

func overrideTailFlag(cmd *cobra.Command) {
cmd.Flags().BoolVar(&opts.Tail, "tail", true, "Stream logs from deployed objects")

}
2 changes: 1 addition & 1 deletion cmd/skaffold/app/cmd/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestAddFlags(t *testing.T) {
},
{
description: "union of anotations",
annotations: map[string]string{"debug": "true", "test": "true"},
annotations: map[string]string{"cleanup": "true", "test": "true"},
expectedFlags: []string{"skip-tests", "cleanup", "port-forward", "no-prune"},
},
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/skaffold/app/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ func NewCmdRun(out io.Writer) *cobra.Command {
return err
},
Annotations: map[string]string{
BuildAnnotation: "true",
TestAnnotation: "true",
EventsAnnotation: "true",
DebugAnnotation: "true",
DeployAnnotation: "true",
BuildAnnotation: "true",
TestAnnotation: "true",
EventsAnnotation: "true",
CleanupAnnotation: "true",
DeployAnnotation: "true",
},
}
AddFlags(cmd)
Expand Down

0 comments on commit 9213f18

Please sign in to comment.