mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 20:35:24 +01:00
fix(apps): delete options with emply values
This commit is contained in:
parent
fb75ab438d
commit
e44910d4a1
30
api/apps.go
30
api/apps.go
@ -174,20 +174,26 @@ func setApp(w http.ResponseWriter, r *http.Request) {
|
||||
options := structToFlatMap(app)
|
||||
|
||||
for k, v := range options {
|
||||
if v == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
t := reflect.TypeOf(v)
|
||||
switch t.Kind() {
|
||||
case reflect.Slice, reflect.Array:
|
||||
newV, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
helpers.WriteErrorStatus(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
if v != nil {
|
||||
switch t.Kind() {
|
||||
case reflect.String:
|
||||
if v == "" {
|
||||
v = nil
|
||||
}
|
||||
case reflect.Slice, reflect.Array:
|
||||
newV, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
helpers.WriteErrorStatus(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
v = string(newV)
|
||||
if v == "[]" {
|
||||
v = nil
|
||||
}
|
||||
default:
|
||||
}
|
||||
v = string(newV)
|
||||
default:
|
||||
}
|
||||
|
||||
if err := setAppOption(store, appID, k, v); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user