diff --git a/apis/lagoon/v1beta2/lagoontask_types.go b/apis/lagoon/v1beta2/lagoontask_types.go index 8e9e4d6f..9f5b0024 100644 --- a/apis/lagoon/v1beta2/lagoontask_types.go +++ b/apis/lagoon/v1beta2/lagoontask_types.go @@ -159,6 +159,40 @@ func init() { SchemeBuilder.Register(&LagoonTask{}, &LagoonTaskList{}) } +// convert to string as required for environment ID for backwards compatability +func (a *LagoonTaskEnvironment) UnmarshalJSON(data []byte) error { + tmpMap := map[string]interface{}{} + json.Unmarshal(data, &tmpMap) + if value, ok := tmpMap["id"]; ok { + if reflect.TypeOf(value).Kind() == reflect.String { + id, _ := strconv.Atoi(value.(string)) + idUint := uint(id) + a.ID = &idUint + } else { + aid := value.(uint) + a.ID = &aid + } + } + return nil +} + +// convert to string as required for project ID for backwards compatability +func (a *LagoonTaskProject) UnmarshalJSON(data []byte) error { + tmpMap := map[string]interface{}{} + json.Unmarshal(data, &tmpMap) + if value, ok := tmpMap["id"]; ok { + if reflect.TypeOf(value).Kind() == reflect.String { + id, _ := strconv.Atoi(value.(string)) + idUint := uint(id) + a.ID = &idUint + } else { + aid := value.(uint) + a.ID = &aid + } + } + return nil +} + // this is a custom unmarshal function that will check deployerToken and sshKey which come from Lagoon as `1|0` booleans because javascript // this converts them from floats to bools func (a *LagoonAdvancedTaskInfo) UnmarshalJSON(data []byte) error {