Skip to content

Commit

Permalink
Merge pull request #40 from peterHoburg/38-some-config-vars-not-showi…
Browse files Browse the repository at this point in the history
…ng-up-in-ui

Fixed inconsistent naming in UI for name/template name,
  • Loading branch information
peterHoburg authored Dec 7, 2024
2 parents 10121ec + 2dae498 commit db8eb57
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 34 deletions.
4 changes: 2 additions & 2 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ type IndexData struct {

func (i *IndexData) LoadFromViper() *IndexData {
i.RootDir = viper.Get("ROOT_DIR").(string)
i.ComposeFileRegex = viper.Get("COMPOSE_FILE_REGEX").(string)
i.ComposeCommand = viper.Get("COMPOSE_COMMAND").(string)
i.ComposeFileName = viper.Get("COMPOSE_FILE_NAME").(string)
i.ComposeFileRegex = viper.Get("COMPOSE_FILE_REGEX").(string)
i.PreRunCommand = viper.Get("PRE_RUN_COMMAND").(string)
i.EnvVarFileFormat = viper.Get("ENV_VAR_FILE_FORMAT").(string)
i.EnvVarFileSetupCommand = viper.Get("ENV_VAR_FILE_SETUP_COMMAND").(string)
i.EnvVarFileFormat = viper.Get("ENV_VAR_FORMAT").(string)
i.VariableInterpolationOptions = viper.Get("VARIABLE_INTERPOLATION_OPTIONS").(string)
return i
}
Expand Down
30 changes: 15 additions & 15 deletions api/views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

{{ block "containerForm" . }}
<form id="checked-containers" hx-post="/compose/list" hx-trigger="load" hx-target="#tbody">
<label for="defaultEnvironmentSelect">Default Environment:</label>
<select name="defaultEnvironmentSelect">
<label for="DefaultEnvironmentSelect">Default Environment:</label>
<select name="DefaultEnvironmentSelect">
<option value="staging">Staging</option>
<option value="production">Production</option>
</select>
Expand Down Expand Up @@ -71,7 +71,7 @@
<tr>
<td> {{$val.Name}}</td>
<td> {{$val.Path}}</td>
<input type="hidden" name="rootComposeFile" value="{{$val.Path}}">
<input type="hidden" name="RootComposeFile" value="{{$val.Path}}">
</tr>
{{ else }}
<tr>
Expand Down Expand Up @@ -117,30 +117,30 @@ <h1>Error</h1>

{{ block "compose_run_options" . }}
<div>
Remove Orphans: <input type="checkbox" name="removeOrphans">
Remove Orphans: <input type="checkbox" name="RemoveOrphans">
<br>
Always recreate deps: <input type="checkbox" name="alwaysRecreateDeps">
Always recreate deps: <input type="checkbox" name="AlwaysRecreateDeps">
<br>
Stop all containers before running: <input type="checkbox" name="stopAllContainersBeforeRunning">
Stop all containers before running: <input type="checkbox" name="StopAllContainersBeforeRunning">
<br>
Root Dir: <textarea cols="{{len .RootDir}}" style="height:11PX;" name="rootDir">{{.RootDir}}</textarea>
Root Dir: <textarea cols="{{len .RootDir}}" style="height:11PX;" name="RootDir">{{.RootDir}}</textarea>
<br>
Compose Command: <textarea cols="{{len .ComposeCommand}}" style="height:11PX;" name="composeCommand">{{.ComposeCommand}}</textarea>
Compose Command: <textarea cols="{{len .ComposeCommand}}" style="height:11PX;" name="ComposeCommand">{{.ComposeCommand}}</textarea>
<br>
<!-- TODO this should be dynamic based on the root dir?-->
Generated Compose file name: <textarea cols="{{len .ComposeFileName}}" style="height:11PX;" name="composeFileName">{{.ComposeFileName}}</textarea>
Compose File Name: <textarea cols="{{len .ComposeFileName}}" style="height:11PX;" name="ComposeFileName">{{.ComposeFileName}}</textarea>
<br>
Compose Files Regex: <textarea cols="{{len .ComposeFileRegex}}" style="height:11PX;" name="composeFileRegex">{{.ComposeFileRegex}}</textarea>
Compose Files Regex: <textarea cols="{{len .ComposeFileRegex}}" style="height:11PX;" name="ComposeFileRegex">{{.ComposeFileRegex}}</textarea>
<br>
Pre-run command: <textarea cols="{{len .PreRunCommand}}" style="height:11PX;" name="preRunCommand">{{.PreRunCommand}}</textarea>
Pre-run command: <textarea cols="{{len .PreRunCommand}}" style="height:11PX;" name="PreRunCommand">{{.PreRunCommand}}</textarea>
<br>
Env var file format: <textarea cols="{{len .EnvVarFileFormat}}" style="height:11PX;" name="envVarFileFormat">{{.EnvVarFileFormat}}</textarea>
Env var file format: <textarea cols="{{len .EnvVarFileFormat}}" style="height:11PX;" name="EnvVarFileFormat">{{.EnvVarFileFormat}}</textarea>
<br>
Env var file setup command: <textarea cols="{{len .EnvVarFileSetupCommand}}" style="height:11PX;" name="envVarFileSetupCommand">{{.EnvVarFileSetupCommand}}</textarea>
Env var file setup command: <textarea cols="{{len .EnvVarFileSetupCommand}}" style="height:11PX;" name="EnvVarFileSetupCommand">{{.EnvVarFileSetupCommand}}</textarea>
<br>
<label>Variable Interpolation Options (newline seperated):</label>
<textarea rows="3" cols="{{len .VariableInterpolationOptions}}" name="variableInterpolationOptions"
<textarea rows="3" cols="{{len .VariableInterpolationOptions}}" name="VariableInterpolationOptions"
placeholder="KEY1=echo $UID
KEY2=<bash command>"></textarea>
KEY2=<bash command>">{{.VariableInterpolationOptions}}</textarea>
</div>
{{ end }}
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ func LoadConfig() {
viper.SetDefault("STOP_ALL_CONTAINERS_BEFORE_RUNNING", false)

viper.SetDefault("ROOT_DIR", rootDir)
viper.SetDefault("COMPOSE_FILE_REGEX", "^docker-compose\\.ya?ml$")
viper.SetDefault("COMPOSE_COMMAND", "compose -f [[COMPOSE_FILE_NAME]] up --build -d")
viper.SetDefault("COMPOSE_FILE_NAME", composeFileName)
viper.SetDefault("COMPOSE_FILE_REGEX", "^docker-compose\\.ya?ml$")
viper.SetDefault("PRE_RUN_COMMAND", "")
viper.SetDefault("ENV_VAR_FORMAT", ".env-[[ENVIRONMENT]]")
viper.SetDefault("ENV_VAR_FILE_FORMAT", ".env-[[ENVIRONMENT]]")
viper.SetDefault("ENV_VAR_FILE_SETUP_COMMAND", "")
viper.SetDefault("VARIABLE_INTERPOLATION_OPTIONS", "")

Expand Down
30 changes: 15 additions & 15 deletions internal/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,27 @@ func (c ComposeRunData) LoadFromForm(form url.Values) (ComposeRunData, error) {
}

for k, v := range form {
if k == "defaultEnvironmentSelect" {
if k == "DefaultEnvironmentSelect" {
defaultEnvironmentSelect = v[0]
continue
}
if k == "removeOrphans" {
if k == "RemoveOrphans" {
c.RemoveOrphans = true
continue
}
if k == "alwaysRecreateDeps" {
if k == "AlwaysRecreateDeps" {
c.AlwaysRecreateDeps = true
continue
}
if k == "stopAllContainersBeforeRunning" {
if k == "StopAllContainersBeforeRunning" {
c.StopAllContainersBeforeRunning = true
continue
}
if k == "composeCommand" {
if k == "ComposeCommand" {
c.ComposeCommand = v[0]
continue
}
if k == "composeFileName" {
if k == "ComposeFileName" {
if v[0] == "" {
continue
}
Expand All @@ -92,27 +92,27 @@ func (c ComposeRunData) LoadFromForm(form url.Values) (ComposeRunData, error) {
continue
}

if k == "preRunCommand" {
if k == "PreRunCommand" {
c.PreRunCommand = v[0]
continue
}
if k == "envVarFileFormat" {
if k == "EnvVarFileFormat" {
envVarFileFormat = v[0]
continue
}
if k == "envVarFileSetupCommand" {
if k == "EnvVarFileSetupCommand" {
c.EnvVarFileSetupCommand = v[0]
continue
}
if k == "rootDir" {
if k == "RootDir" {
c.RootDir = v[0]
continue
}
if k == "composeFileRegex" {
if k == "ComposeFileRegex" {
c.ComposeFileRegex = v[0]
continue
}
if k == "variableInterpolationOptions" {
if k == "VariableInterpolationOptions" {
options := strings.Split(v[0], "\n")
for _, option := range options {
splitOptions := strings.SplitN(option, "=", 2)
Expand All @@ -131,13 +131,13 @@ func (c ComposeRunData) LoadFromForm(form url.Values) (ComposeRunData, error) {
}

for k, v := range form {
if (len(v) > 1 && v[1] == "on") || k == "rootComposeFile" {
if v[0] == "default" || k == "rootComposeFile" {
if (len(v) > 1 && v[1] == "on") || k == "RootComposeFile" {
if v[0] == "default" || k == "RootComposeFile" {
environment = defaultEnvironmentSelect
} else {
environment = v[0]
}
if k == "rootComposeFile" {
if k == "RootComposeFile" {
c.ComposeFiles = append(c.ComposeFiles, &Compose{
Path: v[0],
Active: true,
Expand Down
2 changes: 2 additions & 0 deletions testdata/example-repo-setup/drydock.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
PRE_RUN_COMMAND: "echo TEST_PRE_RUN_COMMAND"
VARIABLE_INTERPOLATION_OPTIONS: "USER_UID=echo $UID\nEXAMPLE2=echo $PATH"
ENV_VAR_FILE_SETUP_COMMAND: echo something

0 comments on commit db8eb57

Please sign in to comment.