Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compose): add -v flag into undeploy command [BE-11345] #60

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading