From d90048a69d963e0f04759acbffa0b6a1be14679a Mon Sep 17 00:00:00 2001 From: rmanach Date: Thu, 10 Apr 2025 10:04:59 +0200 Subject: [PATCH] fix docker deploy with registry + skip confirmation with optional arg --- README.md | 4 +++- deployers/swarm.go | 2 +- main.go | 11 +++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1c5a262..21e1e03 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,8 @@ The binary is then installed in your **$GOPATH/bin**. ```bash hmdeploy --help Usage of hmdeploy: + -confirm + do not ask for confirmation, you're the best, you don't need confirmation -debug show debug logs -destroy @@ -143,7 +145,7 @@ hmdeploy --path /path/my-project --destroy ## Next steps * ~~Improve the CLI arguments~~ * ~~Destroy~~ -* Post-install script +* Check deployment/undeployment state * Deals with bugs * Tests 😮‍💨 diff --git a/deployers/swarm.go b/deployers/swarm.go index 63ff346..8d9cccd 100644 --- a/deployers/swarm.go +++ b/deployers/swarm.go @@ -184,7 +184,7 @@ func (sd *SwarmDeployer) Deploy() error { log.Info().Str("project", sd.project.Name).Msg("deploying swarm project...") composeFileBase := filepath.Base(sd.project.Deps.ComposeFile) - if _, err := sd.conn.Execute(fmt.Sprintf("docker stack deploy -c %s %s", composeFileBase, sd.project.Name)); err != nil { + if _, err := sd.conn.Execute(fmt.Sprintf("docker stack deploy -c %s %s --with-registry-auth", composeFileBase, sd.project.Name)); err != nil { sd.setDone(err) return err } diff --git a/main.go b/main.go index 1abcf6a..7733462 100644 --- a/main.go +++ b/main.go @@ -251,6 +251,11 @@ func main() { //nolint: all //hjf destroy := flag.Bool("destroy", false, "delete the deployed project") noNginx := flag.Bool("no-nginx", false, "no Nginx deployment") debug := flag.Bool("debug", false, "show debug logs") + confirm := flag.Bool( + "confirm", + false, + "do not ask for confirmation, you're the best, you don't need confirmation", + ) flag.Parse() initLogger(*debug) @@ -286,8 +291,10 @@ func main() { //nolint: all //hjf tasks := deps.generateTasksTree() tasks.Display() - if err := utils.Confirm(ctx, *destroy); err != nil { - log.Fatal().Err(err).Msg("error while confirming execution") + if !*confirm { + if err := utils.Confirm(ctx, *destroy); err != nil { + log.Fatal().Err(err).Msg("error while confirming execution") + } } s := scheduler.NewScheduler(