in internal/settings/settings.go [19:46]
func (li *SettingsCommon) UnmarshalJSON(data []byte) error {
type localItem SettingsCommon
var loc localItem
if err := json.Unmarshal(data, &loc); err != nil {
return err
}
*li = SettingsCommon(loc)
switch li.PublicSettingsRaw.(type) {
case string:
// When a string type is found, we need to attempt an extra parsing step.
// This is needed to handle the response from the VMSettings API for immediate run command
publicSettingsRawString := li.PublicSettingsRaw.(string)
var publicSettings map[string]interface{}
if publicSettingsRawString != "" {
if err := json.Unmarshal([]byte(publicSettingsRawString), &publicSettings); err != nil {
return errors.Wrapf(err, "failed to parse public settings from json")
}
}
li.PublicSettings = publicSettings
case interface{}:
// This covers the scenario to parse the settings for a normal run command request
li.PublicSettings = li.PublicSettingsRaw.(map[string]interface{})
}
return nil
}