Skip to content

Commit 9a2241b

Browse files
committed
chore: removing daemon param
1 parent 76de24f commit 9a2241b

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

command/deploy.go

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ type DeployCommandParameters struct {
2929
OutPath string
3030
RemoteComposePaths []string
3131
Force bool
32-
Daemon bool
3332
}
3433

3534
type deployCommand struct {
@@ -73,38 +72,31 @@ func (d *deployCommand) Handle() {
7372
return
7473
}
7574

76-
if len(updatedSubDirs) > 0 || d.params.Force {
77-
if len(updatedSubDirs) > 0 {
78-
log.Info("Running docker-compose up for updated subdirectories", "updatedSubDirs", updatedSubDirs)
79-
80-
// Deploy compose files for updated subdirectories
81-
for _, updatedSubDir := range updatedSubDirs {
82-
composePaths := subDirToComposePaths[updatedSubDir]
83-
for _, composePath := range composePaths {
84-
log.Info("Deploying compose file", "composePath", composePath, "subDir", updatedSubDir)
85-
err := docker.DeployCompose(filepath.Join(d.params.OutPath, composePath), d.params.Daemon)
86-
if err != nil {
87-
log.Fatal("Error running docker-compose up", "error", err, "composePath", composePath)
88-
return
89-
}
90-
}
91-
}
92-
} else if d.params.Force {
93-
log.Info("Force flag set, running docker-compose up for all compose files")
94-
95-
// Deploy all compose files when force flag is set
96-
for _, composePath := range d.params.RemoteComposePaths {
97-
log.Info("Deploying compose file", "composePath", composePath)
98-
err := docker.DeployCompose(filepath.Join(d.params.OutPath, composePath), d.params.Daemon)
99-
if err != nil {
100-
log.Fatal("Error running docker-compose up", "error", err, "composePath", composePath)
101-
return
102-
}
103-
}
75+
var composePathsToDeploy []string
76+
77+
if len(updatedSubDirs) > 0 {
78+
log.Info("Running docker-compose up for updated subdirectories", "updatedSubDirs", updatedSubDirs)
79+
// Collect compose files for updated subdirectories
80+
for _, updatedSubDir := range updatedSubDirs {
81+
composePaths := subDirToComposePaths[updatedSubDir]
82+
composePathsToDeploy = append(composePathsToDeploy, composePaths...)
10483
}
84+
} else if d.params.Force {
85+
log.Info("Force flag set, running docker-compose up for all compose files")
86+
composePathsToDeploy = d.params.RemoteComposePaths
10587
} else {
10688
log.Info("No changes detected, skipping docker-compose up")
10789
}
90+
91+
// Deploy all collected compose files
92+
for _, composePath := range composePathsToDeploy {
93+
log.Info("Deploying compose file", "composePath", composePath)
94+
err := docker.DeployCompose(filepath.Join(d.params.OutPath, composePath), true)
95+
if err != nil {
96+
log.Fatal("Error running docker-compose up", "error", err, "composePath", composePath)
97+
return
98+
}
99+
}
108100
}
109101

110102
func createDeployCommand() *Command {
@@ -129,7 +121,6 @@ func deployCommandParametersParser() DeployCommandParameters {
129121
flag.StringVar(&params.Branch, "b", "", "branch name")
130122
flag.StringVar(&params.OutPath, "o", "", "out path")
131123
flag.BoolVar(&params.Force, "f", false, "force deployment even if no changes detected")
132-
flag.BoolVar(&params.Daemon, "d", true, "run docker compose in daemon mode")
133124
flag.StringVar(&params.LogLevel, "l", "info", "log level (debug, info, error, fatal)")
134125
flag.Parse()
135126

0 commit comments

Comments
 (0)