mirror of
https://github.com/semaphoreui/semaphore.git
synced 2025-01-20 15:29:28 +01:00
fix(backup): marshaling
This commit is contained in:
parent
e47ff5ecfc
commit
540b88a779
@ -136,7 +136,7 @@ definitions:
|
||||
|
||||
ProjectBackup:
|
||||
type: object
|
||||
example: {"meta":{"name":"homelab","alert":true,"alert_chat":"Test","max_parallel_tasks":0},"templates":[{"inventory":"Build","repository":"Demo","environment":"Empty","name":"Build","playbook":"build.yml","arguments":"[]","allow_override_args_in_task":false,"description":"Build Job","vault_key":null,"type":"build","start_version":"1.0.0","build_template":null,"view":"Build","autorun":false,"survey_vars":"null","suppress_success_alerts":false,"cron":"* * * * *"}],"repositories":[{"name":"Demo","git_url":"https://github.com/semaphoreui/demo-project.git","git_branch":"main","ssh_key":"None"}],"keys":[{"name":"None","type":"none"},{"name":"Vault Password","type":"login_password"}],"views":[{"name":"Build","position":0}],"inventories":[{"name":"Build","inventory":"","ssh_key":"None","become_key":"None","type":"static"},{"name":"Dev","inventory":"","ssh_key":"None","become_key":"None","type":"file"},{"name":"Prod","inventory":"","ssh_key":"None","become_key":"None","type":"file"}],"environments":[{"name":"Empty","password":null,"json":"{}","env":null}]}
|
||||
example: {"meta":{"name":"homelab","alert":true,"alert_chat":"Test","max_parallel_tasks":0},"templates":[{"inventory":"Build","repository":"Demo","environment":"Empty","name":"Build","playbook":"build.yml","arguments":"[]","allow_override_args_in_task":false,"description":"Build Job","vault_key":null,"type":"build","start_version":"1.0.0","build_template":null,"view":"Build","autorun":false,"survey_vars":"null","suppress_success_alerts":false,"cron":"* * * * *"}],"repositories":[{"name":"Demo","git_url":"https://github.com/semaphoreui/demo-project.git","git_branch":"main","ssh_key":"None"}],"keys":[{"name":"None","type":"none"},{"name":"Vault Password","type":"login_password"}],"views":[{"title":"Build","position":0}],"inventories":[{"name":"Build","inventory":"","ssh_key":"None","become_key":"None","type":"static"},{"name":"Dev","inventory":"","ssh_key":"None","become_key":"None","type":"file"},{"name":"Prod","inventory":"","ssh_key":"None","become_key":"None","type":"file"}],"environments":[{"name":"Empty","password":null,"json":"{}","env":null}]}
|
||||
properties:
|
||||
meta:
|
||||
type: object
|
||||
|
@ -70,9 +70,9 @@ func marshalValue(v reflect.Value) (interface{}, error) {
|
||||
// Handle slices and arrays
|
||||
if v.Kind() == reflect.Slice || v.Kind() == reflect.Array {
|
||||
if v.IsNil() {
|
||||
return nil, nil
|
||||
return make([]interface{}, 0), nil
|
||||
}
|
||||
var result []interface{}
|
||||
var result []interface{} = make([]interface{}, 0)
|
||||
for i := 0; i < v.Len(); i++ {
|
||||
elemValue, err := marshalValue(v.Index(i))
|
||||
if err != nil {
|
||||
@ -86,7 +86,7 @@ func marshalValue(v reflect.Value) (interface{}, error) {
|
||||
// Handle maps
|
||||
if v.Kind() == reflect.Map {
|
||||
if v.IsNil() {
|
||||
return nil, nil
|
||||
return make(map[string]interface{}), nil
|
||||
}
|
||||
result := make(map[string]interface{})
|
||||
for _, key := range v.MapKeys() {
|
||||
|
Loading…
Reference in New Issue
Block a user