Skip to content

Commit 24e141e

Browse files
committed
Fix volume handling for prod apps
1 parent a8b8457 commit 24e141e

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

cmd/clace/app_cmds.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const (
2626
In the glob, * matches any number of characters, ** matches any number of characters including /.
2727
all is a shortcut for "*:**", which matches all apps across all domains, including no domain.
2828
To prevent shell expansion for *, placing the path in quotes is recommended.
29+
"all" matches all apps across all domains, same as "*:**".
2930
`
3031
PROMOTE_FLAG = "promote"
3132
PROMOTE_ARG = "promote"
@@ -92,7 +93,13 @@ func appCreateCommand(commonFlags []cli.Flag, clientConfig *types.ClientConfig)
9293
&cli.StringSliceFlag{
9394
Name: "app-config",
9495
Aliases: []string{"conf"},
95-
Usage: "Set an default config option for the app. Format is configKey=configValue",
96+
Usage: "Set an default config option for the app. Format is configKey=configValue, where value has to be encoded in toml formal",
97+
})
98+
99+
flags = append(flags,
100+
&cli.StringSliceFlag{
101+
Name: "conf-str",
102+
Usage: "Set an default config string value for the app. Format is configKey=configValue",
96103
})
97104

98105
flags = append(flags, dryRunFlag())
@@ -169,6 +176,15 @@ Examples:
169176
confMap[key] = value
170177
}
171178

179+
appConfigStr := cCtx.StringSlice("conf-str")
180+
for _, def := range appConfigStr {
181+
key, value, ok := strings.Cut(def, "=")
182+
if !ok {
183+
return fmt.Errorf("invalid app config format: %s", def)
184+
}
185+
confMap[key] = "\"" + value + "\""
186+
}
187+
172188
body := types.CreateAppRequest{
173189
Path: cCtx.Args().Get(1),
174190
SourceUrl: cCtx.Args().Get(0),

cmd/clace/apply_cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func initApplyCommand(commonFlags []cli.Flag, clientConfig *types.ClientConfig)
3737
UsageText: `args: <filePath> [<appPathGlob>]
3838
3939
<filePath> is the path to the file containing the app configuration.
40-
<appPathGlob> is an optional second argument.
40+
<appPathGlob> is an optional second argument, which default to "all".
4141
` + PATH_SPEC_HELP +
4242
`
4343
Examples:

internal/app/container_manager.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,14 @@ func NewContainerManager(logger *types.Logger, app *App, containerFile string,
107107
}
108108
}
109109

110-
logger.Debug().Msgf("Found volumes %v in container file %s", volumes, containerFile)
111-
112110
if configPort == 0 {
113111
// No port configured in app config, use the one from the container file
114112
configPort = filePort
115113
}
116114
}
117115

118116
volumes = dedupVolumes(append(volumes, containerVolumes...))
117+
logger.Debug().Msgf("volumes %v %s", volumes, containerFile)
119118

120119
if configPort == 0 && lifetime != types.CONTAINER_LIFETIME_COMMAND {
121120
return nil, fmt.Errorf("port not specified in app config and in container file %s. Either "+
@@ -805,7 +804,7 @@ func (m *ContainerManager) ProdReload(dryRun bool) error {
805804
defer m.stateLock.Unlock()
806805
// Start the container with newly built image
807806

808-
mountArgs, err := m.genMountArgs(sourceDir)
807+
m.mountArgs, err = m.genMountArgs(sourceDir)
809808
if err != nil {
810809
return err
811810
}
@@ -823,7 +822,7 @@ func (m *ContainerManager) ProdReload(dryRun bool) error {
823822
envMap, _ := m.GetEnvMap()
824823

825824
err = m.command.RunContainer(m.systemConfig, m.app.AppEntry, containerName,
826-
m.GenImageName, m.port, envMap, mountArgs, m.app.Metadata.ContainerOptions)
825+
m.GenImageName, m.port, envMap, m.mountArgs, m.app.Metadata.ContainerOptions)
827826
if err != nil {
828827
return fmt.Errorf("error starting container: %w", err)
829828
}

0 commit comments

Comments
 (0)