Skip to content

Commit

Permalink
fix: add -v flag parser
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarzhou-portainer committed Dec 26, 2024
1 parent 28b985e commit b09a0bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
9 changes: 5 additions & 4 deletions undeploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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")
Expand All @@ -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")

Expand Down

0 comments on commit b09a0bd

Please sign in to comment.