Skip to content

Commit db8eb57

Browse files
authored
Merge pull request #40 from peterHoburg/38-some-config-vars-not-showing-up-in-ui
Fixed inconsistent naming in UI for name/template name,
2 parents 10121ec + 2dae498 commit db8eb57

File tree

5 files changed

+36
-34
lines changed

5 files changed

+36
-34
lines changed

api/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ type IndexData struct {
4747

4848
func (i *IndexData) LoadFromViper() *IndexData {
4949
i.RootDir = viper.Get("ROOT_DIR").(string)
50-
i.ComposeFileRegex = viper.Get("COMPOSE_FILE_REGEX").(string)
5150
i.ComposeCommand = viper.Get("COMPOSE_COMMAND").(string)
5251
i.ComposeFileName = viper.Get("COMPOSE_FILE_NAME").(string)
52+
i.ComposeFileRegex = viper.Get("COMPOSE_FILE_REGEX").(string)
5353
i.PreRunCommand = viper.Get("PRE_RUN_COMMAND").(string)
54+
i.EnvVarFileFormat = viper.Get("ENV_VAR_FILE_FORMAT").(string)
5455
i.EnvVarFileSetupCommand = viper.Get("ENV_VAR_FILE_SETUP_COMMAND").(string)
55-
i.EnvVarFileFormat = viper.Get("ENV_VAR_FORMAT").(string)
5656
i.VariableInterpolationOptions = viper.Get("VARIABLE_INTERPOLATION_OPTIONS").(string)
5757
return i
5858
}

api/views/index.html

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838

3939
{{ block "containerForm" . }}
4040
<form id="checked-containers" hx-post="/compose/list" hx-trigger="load" hx-target="#tbody">
41-
<label for="defaultEnvironmentSelect">Default Environment:</label>
42-
<select name="defaultEnvironmentSelect">
41+
<label for="DefaultEnvironmentSelect">Default Environment:</label>
42+
<select name="DefaultEnvironmentSelect">
4343
<option value="staging">Staging</option>
4444
<option value="production">Production</option>
4545
</select>
@@ -71,7 +71,7 @@
7171
<tr>
7272
<td> {{$val.Name}}</td>
7373
<td> {{$val.Path}}</td>
74-
<input type="hidden" name="rootComposeFile" value="{{$val.Path}}">
74+
<input type="hidden" name="RootComposeFile" value="{{$val.Path}}">
7575
</tr>
7676
{{ else }}
7777
<tr>
@@ -117,30 +117,30 @@ <h1>Error</h1>
117117

118118
{{ block "compose_run_options" . }}
119119
<div>
120-
Remove Orphans: <input type="checkbox" name="removeOrphans">
120+
Remove Orphans: <input type="checkbox" name="RemoveOrphans">
121121
<br>
122-
Always recreate deps: <input type="checkbox" name="alwaysRecreateDeps">
122+
Always recreate deps: <input type="checkbox" name="AlwaysRecreateDeps">
123123
<br>
124-
Stop all containers before running: <input type="checkbox" name="stopAllContainersBeforeRunning">
124+
Stop all containers before running: <input type="checkbox" name="StopAllContainersBeforeRunning">
125125
<br>
126-
Root Dir: <textarea cols="{{len .RootDir}}" style="height:11PX;" name="rootDir">{{.RootDir}}</textarea>
126+
Root Dir: <textarea cols="{{len .RootDir}}" style="height:11PX;" name="RootDir">{{.RootDir}}</textarea>
127127
<br>
128-
Compose Command: <textarea cols="{{len .ComposeCommand}}" style="height:11PX;" name="composeCommand">{{.ComposeCommand}}</textarea>
128+
Compose Command: <textarea cols="{{len .ComposeCommand}}" style="height:11PX;" name="ComposeCommand">{{.ComposeCommand}}</textarea>
129129
<br>
130130
<!-- TODO this should be dynamic based on the root dir?-->
131-
Generated Compose file name: <textarea cols="{{len .ComposeFileName}}" style="height:11PX;" name="composeFileName">{{.ComposeFileName}}</textarea>
131+
Compose File Name: <textarea cols="{{len .ComposeFileName}}" style="height:11PX;" name="ComposeFileName">{{.ComposeFileName}}</textarea>
132132
<br>
133-
Compose Files Regex: <textarea cols="{{len .ComposeFileRegex}}" style="height:11PX;" name="composeFileRegex">{{.ComposeFileRegex}}</textarea>
133+
Compose Files Regex: <textarea cols="{{len .ComposeFileRegex}}" style="height:11PX;" name="ComposeFileRegex">{{.ComposeFileRegex}}</textarea>
134134
<br>
135-
Pre-run command: <textarea cols="{{len .PreRunCommand}}" style="height:11PX;" name="preRunCommand">{{.PreRunCommand}}</textarea>
135+
Pre-run command: <textarea cols="{{len .PreRunCommand}}" style="height:11PX;" name="PreRunCommand">{{.PreRunCommand}}</textarea>
136136
<br>
137-
Env var file format: <textarea cols="{{len .EnvVarFileFormat}}" style="height:11PX;" name="envVarFileFormat">{{.EnvVarFileFormat}}</textarea>
137+
Env var file format: <textarea cols="{{len .EnvVarFileFormat}}" style="height:11PX;" name="EnvVarFileFormat">{{.EnvVarFileFormat}}</textarea>
138138
<br>
139-
Env var file setup command: <textarea cols="{{len .EnvVarFileSetupCommand}}" style="height:11PX;" name="envVarFileSetupCommand">{{.EnvVarFileSetupCommand}}</textarea>
139+
Env var file setup command: <textarea cols="{{len .EnvVarFileSetupCommand}}" style="height:11PX;" name="EnvVarFileSetupCommand">{{.EnvVarFileSetupCommand}}</textarea>
140140
<br>
141141
<label>Variable Interpolation Options (newline seperated):</label>
142-
<textarea rows="3" cols="{{len .VariableInterpolationOptions}}" name="variableInterpolationOptions"
142+
<textarea rows="3" cols="{{len .VariableInterpolationOptions}}" name="VariableInterpolationOptions"
143143
placeholder="KEY1=echo $UID
144-
KEY2=<bash command>"></textarea>
144+
KEY2=<bash command>">{{.VariableInterpolationOptions}}</textarea>
145145
</div>
146146
{{ end }}

config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ func LoadConfig() {
5959
viper.SetDefault("STOP_ALL_CONTAINERS_BEFORE_RUNNING", false)
6060

6161
viper.SetDefault("ROOT_DIR", rootDir)
62-
viper.SetDefault("COMPOSE_FILE_REGEX", "^docker-compose\\.ya?ml$")
6362
viper.SetDefault("COMPOSE_COMMAND", "compose -f [[COMPOSE_FILE_NAME]] up --build -d")
6463
viper.SetDefault("COMPOSE_FILE_NAME", composeFileName)
64+
viper.SetDefault("COMPOSE_FILE_REGEX", "^docker-compose\\.ya?ml$")
6565
viper.SetDefault("PRE_RUN_COMMAND", "")
66-
viper.SetDefault("ENV_VAR_FORMAT", ".env-[[ENVIRONMENT]]")
66+
viper.SetDefault("ENV_VAR_FILE_FORMAT", ".env-[[ENVIRONMENT]]")
6767
viper.SetDefault("ENV_VAR_FILE_SETUP_COMMAND", "")
6868
viper.SetDefault("VARIABLE_INTERPOLATION_OPTIONS", "")
6969

internal/compose.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,27 +58,27 @@ func (c ComposeRunData) LoadFromForm(form url.Values) (ComposeRunData, error) {
5858
}
5959

6060
for k, v := range form {
61-
if k == "defaultEnvironmentSelect" {
61+
if k == "DefaultEnvironmentSelect" {
6262
defaultEnvironmentSelect = v[0]
6363
continue
6464
}
65-
if k == "removeOrphans" {
65+
if k == "RemoveOrphans" {
6666
c.RemoveOrphans = true
6767
continue
6868
}
69-
if k == "alwaysRecreateDeps" {
69+
if k == "AlwaysRecreateDeps" {
7070
c.AlwaysRecreateDeps = true
7171
continue
7272
}
73-
if k == "stopAllContainersBeforeRunning" {
73+
if k == "StopAllContainersBeforeRunning" {
7474
c.StopAllContainersBeforeRunning = true
7575
continue
7676
}
77-
if k == "composeCommand" {
77+
if k == "ComposeCommand" {
7878
c.ComposeCommand = v[0]
7979
continue
8080
}
81-
if k == "composeFileName" {
81+
if k == "ComposeFileName" {
8282
if v[0] == "" {
8383
continue
8484
}
@@ -92,27 +92,27 @@ func (c ComposeRunData) LoadFromForm(form url.Values) (ComposeRunData, error) {
9292
continue
9393
}
9494

95-
if k == "preRunCommand" {
95+
if k == "PreRunCommand" {
9696
c.PreRunCommand = v[0]
9797
continue
9898
}
99-
if k == "envVarFileFormat" {
99+
if k == "EnvVarFileFormat" {
100100
envVarFileFormat = v[0]
101101
continue
102102
}
103-
if k == "envVarFileSetupCommand" {
103+
if k == "EnvVarFileSetupCommand" {
104104
c.EnvVarFileSetupCommand = v[0]
105105
continue
106106
}
107-
if k == "rootDir" {
107+
if k == "RootDir" {
108108
c.RootDir = v[0]
109109
continue
110110
}
111-
if k == "composeFileRegex" {
111+
if k == "ComposeFileRegex" {
112112
c.ComposeFileRegex = v[0]
113113
continue
114114
}
115-
if k == "variableInterpolationOptions" {
115+
if k == "VariableInterpolationOptions" {
116116
options := strings.Split(v[0], "\n")
117117
for _, option := range options {
118118
splitOptions := strings.SplitN(option, "=", 2)
@@ -131,13 +131,13 @@ func (c ComposeRunData) LoadFromForm(form url.Values) (ComposeRunData, error) {
131131
}
132132

133133
for k, v := range form {
134-
if (len(v) > 1 && v[1] == "on") || k == "rootComposeFile" {
135-
if v[0] == "default" || k == "rootComposeFile" {
134+
if (len(v) > 1 && v[1] == "on") || k == "RootComposeFile" {
135+
if v[0] == "default" || k == "RootComposeFile" {
136136
environment = defaultEnvironmentSelect
137137
} else {
138138
environment = v[0]
139139
}
140-
if k == "rootComposeFile" {
140+
if k == "RootComposeFile" {
141141
c.ComposeFiles = append(c.ComposeFiles, &Compose{
142142
Path: v[0],
143143
Active: true,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
PRE_RUN_COMMAND: "echo TEST_PRE_RUN_COMMAND"
2+
VARIABLE_INTERPOLATION_OPTIONS: "USER_UID=echo $UID\nEXAMPLE2=echo $PATH"
3+
ENV_VAR_FILE_SETUP_COMMAND: echo something

0 commit comments

Comments
 (0)