Skip to content

Commit 226fb55

Browse files
committed
add multi-target + configurable sslmode
1 parent 2412125 commit 226fb55

File tree

5 files changed

+49
-29
lines changed

5 files changed

+49
-29
lines changed

.goreleaser.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ before:
66
- go mod tidy
77

88
builds:
9-
# - id: nonlinux
10-
# env:
11-
# - CGO_ENABLED=0
12-
# goos:
13-
# - windows
14-
# - darwin
15-
# goarch:
16-
# - amd64
17-
# - arm64
18-
# dir: app
9+
- id: nonlinux
10+
env:
11+
- CGO_ENABLED=0
12+
goos:
13+
- windows
14+
- darwin
15+
goarch:
16+
- amd64
17+
- arm64
18+
dir: app
1919

2020
- id: linux
2121
env:
@@ -24,9 +24,9 @@ builds:
2424
- linux
2525
goarch:
2626
- amd64
27-
# - arm64
28-
# - arm
29-
# - "386"
27+
- arm64
28+
- arm
29+
- "386"
3030
dir: app
3131

3232

modules/api/controllers/sources.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ func deleteSource(w http.ResponseWriter, r *http.Request) {
8383
id := r.PathValue("id")
8484
helpers.CheckErr(thunder.Sources.Delete(id))
8585
helpers.CheckErr(thunder.SaveConfig())
86-
fmt.Println(thunder.Sources.All())
8786
helpers.WriteJsonResponse(w, http.StatusOK, struct {
8887
Success bool `json:"success"`
8988
Message string `json:"message"`

modules/frontend/src/components/Form/DynamicFields.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
:required="field.required"
66
:label="field.label"
77
:name="`${field.name}`"
8-
:help="field.help">
8+
:help="field.help"
9+
>
910

1011
<UInput
12+
class="w-full"
1113
autocomplete="off"
1214
type="number"
1315
v-if="['number'].includes(field.type)"
@@ -18,10 +20,19 @@
1820
/>
1921
<UInput
2022
autocomplete="off"
23+
class="w-full"
2124
:type="field.type"
2225
v-else-if="['url','text','password'].includes(field.type)"
2326
v-model="state[field.name]"/>
24-
<span v-else>{{ field.type }} not supported!</span>
27+
28+
<USelect
29+
autocomplete="off"
30+
class="w-full"
31+
v-else-if="field.type==='select'"
32+
:items="field.options"
33+
v-model="state[field.name]"
34+
/>
35+
<DevOnly v-else>{{ field.type }} not supported!</DevOnly>
2536
</UFormField>
2637
</UForm>
2738
</template>

source-drivers/postgresql_flash/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type DriverConfig struct {
1313
Password string `required:"true" type:"password"`
1414
Database string `required:"true"`
1515
Schema string `default:"public"`
16-
SslMode string `default:"prefer"`
16+
SslMode string `default:"prefer" label:"SSL Mode" help:"Try disabling if you encounter a TLS error." type:"select" options:"disable,allow,prefer,require,verify-ca,verify-full"`
1717
}
1818

1919
func (cfg DriverConfig) Excerpt() string {

utils/dynamic_config.go

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package utils
22

33
import (
4+
"cmp"
45
"encoding/json"
56
"github.com/creasty/defaults"
67
"reflect"
@@ -18,7 +19,10 @@ type DynamicConfigField struct {
1819
Required bool `json:"required"`
1920
Help *string `json:"help,omitempty"`
2021
Min string `json:"min,omitempty"`
22+
Max string `json:"max,omitempty"`
2123
Default *string `json:"default,omitempty"`
24+
25+
Options []string `json:"options,omitempty"`
2226
}
2327

2428
func ParseDynamicConfigFields(config *DynamicConfig) DynamicConfigFields {
@@ -34,43 +38,49 @@ func ParseDynamicConfigFields(config *DynamicConfig) DynamicConfigFields {
3438
for i := 0; i < configType.NumField(); i++ {
3539
field := configType.Field(i)
3640

37-
label := field.Tag.Get("label")
38-
inputType := field.Tag.Get("type")
39-
helpTag := field.Tag.Get("help")
40-
defaultTag := field.Tag.Get("default")
41-
requiredTag := field.Tag.Get("required")
42-
minTag := field.Tag.Get("min")
41+
label := cmp.Or(field.Tag.Get("label"), field.Name)
42+
inputType := cmp.Or(field.Tag.Get("type"), "text")
4343

44-
if label == "" {
45-
label = field.Name
46-
}
47-
if inputType == "" {
48-
inputType = "text"
49-
}
44+
helpTag := field.Tag.Get("help")
5045
var helpText *string = nil
5146
if helpTag != "" {
5247
helpText = &helpTag
5348
}
5449

50+
defaultTag := field.Tag.Get("default")
5551
var defaultValue *string = nil
5652
if defaultTag != "" {
5753
defaultValue = &defaultTag
5854
}
5955

56+
var options []string
57+
if inputType == "select" {
58+
optionsTag := cmp.Or(field.Tag.Get("options"), defaultTag)
59+
if optionsTag != "" {
60+
options = strings.Split(optionsTag, ",")
61+
}
62+
}
63+
6064
inputName := field.Name
6165

6266
jsonTag := field.Tag.Get("json")
6367
if jsonTag != "" {
6468
inputName = strings.Split(jsonTag, ",")[0]
6569
}
6670

71+
minTag := field.Tag.Get("min")
72+
maxTag := field.Tag.Get("max")
73+
requiredTag := field.Tag.Get("required")
74+
6775
fields = append(fields, DynamicConfigField{
6876
Name: inputName,
6977
Label: label,
7078
Type: inputType,
7179
Help: helpText,
7280
Required: requiredTag == "true",
7381
Min: minTag,
82+
Max: maxTag,
83+
Options: options,
7484
Default: defaultValue,
7585
})
7686
}

0 commit comments

Comments
 (0)