From b09a0bdd4a6022e3591b2f529355b4bc60142716 Mon Sep 17 00:00:00 2001 From: oscarzhou Date: Fri, 27 Dec 2024 09:21:46 +1300 Subject: [PATCH] fix: add -v flag parser --- types.go | 7 ++++--- undeploy.go | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/types.go b/types.go index a2662f2..e0af3de 100644 --- a/types.go +++ b/types.go @@ -52,9 +52,10 @@ type SwarmDeployCommand struct { } type UndeployCommand struct { - User string `help:"Username for Git authentication." short:"u"` - Password string `help:"Password or PAT for Git authentication" short:"p"` - Keep bool `help:"Keep stack folder" short:"k"` + User string `help:"Username for Git authentication." short:"u"` + Password string `help:"Password or PAT for Git authentication" short:"p"` + Keep bool `help:"Keep stack folder" short:"k"` + RemoveVolumes bool `help:"Remove volumes" short:"v"` GitRepository string `arg:"" help:"Git repository to deploy from." name:"git-repo"` ProjectName string `arg:"" help:"Name of the Compose stack." name:"project-name"` diff --git a/undeploy.go b/undeploy.go index 28fa384..a8b7fac 100644 --- a/undeploy.go +++ b/undeploy.go @@ -14,7 +14,7 @@ import ( func (cmd *UndeployCommand) Run(cmdCtx *CommandExecutionContext) error { log.Info(). Str("repository", cmd.GitRepository). - Strs("composePath", cmd.ComposeRelativeFilePaths). + Strs("compose_path", cmd.ComposeRelativeFilePaths). Msg("Undeploying Compose stack from Git repository") if strings.LastIndex(cmd.GitRepository, "/") == -1 { @@ -30,10 +30,11 @@ func (cmd *UndeployCommand) Run(cmdCtx *CommandExecutionContext) error { deployer := compose.NewComposeDeployer() log.Debug(). - Str("projectName", cmd.ProjectName). + Str("project_name", cmd.ProjectName). + Bool("remove_volumes", cmd.RemoveVolumes). Msg("Undeploying Compose stack") - if err := deployer.Remove(cmdCtx.context, cmd.ProjectName, nil, libstack.RemoveOptions{}); err != nil { + if err := deployer.Remove(cmdCtx.context, cmd.ProjectName, nil, libstack.RemoveOptions{Volumes: cmd.RemoveVolumes}); err != nil { log.Error(). Err(err). Msg("Failed to remove Compose stack") @@ -55,7 +56,7 @@ func (cmd *UndeployCommand) Run(cmdCtx *CommandExecutionContext) error { func (cmd *SwarmUndeployCommand) Run(cmdCtx *CommandExecutionContext) error { log.Info(). - Str("stack name", cmd.ProjectName). + Str("stack_name", cmd.ProjectName). Str("destination", cmd.Destination). Msg("Undeploying Swarm stack from Git repository")