fix docker deploy with registry + skip confirmation with optional arg

This commit is contained in:
rmanach 2025-04-10 10:04:59 +02:00
parent dbda7784fa
commit d90048a69d
3 changed files with 13 additions and 4 deletions

View File

@ -118,6 +118,8 @@ The binary is then installed in your **$GOPATH/bin**.
```bash ```bash
hmdeploy --help hmdeploy --help
Usage of hmdeploy: Usage of hmdeploy:
-confirm
do not ask for confirmation, you're the best, you don't need confirmation
-debug -debug
show debug logs show debug logs
-destroy -destroy
@ -143,7 +145,7 @@ hmdeploy --path /path/my-project --destroy
## Next steps ## Next steps
* ~~Improve the CLI arguments~~ * ~~Improve the CLI arguments~~
* ~~Destroy~~ * ~~Destroy~~
* Post-install script * Check deployment/undeployment state
* Deals with bugs * Deals with bugs
* Tests 😮‍💨 * Tests 😮‍💨

View File

@ -184,7 +184,7 @@ func (sd *SwarmDeployer) Deploy() error {
log.Info().Str("project", sd.project.Name).Msg("deploying swarm project...") log.Info().Str("project", sd.project.Name).Msg("deploying swarm project...")
composeFileBase := filepath.Base(sd.project.Deps.ComposeFile) 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) sd.setDone(err)
return err return err
} }

11
main.go
View File

@ -251,6 +251,11 @@ func main() { //nolint: all //hjf
destroy := flag.Bool("destroy", false, "delete the deployed project") destroy := flag.Bool("destroy", false, "delete the deployed project")
noNginx := flag.Bool("no-nginx", false, "no Nginx deployment") noNginx := flag.Bool("no-nginx", false, "no Nginx deployment")
debug := flag.Bool("debug", false, "show debug logs") 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() flag.Parse()
initLogger(*debug) initLogger(*debug)
@ -286,8 +291,10 @@ func main() { //nolint: all //hjf
tasks := deps.generateTasksTree() tasks := deps.generateTasksTree()
tasks.Display() tasks.Display()
if err := utils.Confirm(ctx, *destroy); err != nil { if !*confirm {
log.Fatal().Err(err).Msg("error while confirming execution") if err := utils.Confirm(ctx, *destroy); err != nil {
log.Fatal().Err(err).Msg("error while confirming execution")
}
} }
s := scheduler.NewScheduler( s := scheduler.NewScheduler(