diff --git a/types/db.go b/types/db.go index 148c316e..989fd8f0 100644 --- a/types/db.go +++ b/types/db.go @@ -109,7 +109,7 @@ type PlanModel struct { PlanStateValueID sql.NullInt64 `gorm:"index" json:"-"` // The variables set in the root module when creating the plan. - Variables []PlanModelVariable `json:"variables,omitempty"` + Variables planVariableList `json:"variables,omitempty"` // The change operations for resources and data sources within this // plan. @@ -204,7 +204,7 @@ type PlanStateResource struct { // empty. // // This value can be either an integer (int) or a string. - Index string `json:"index,omitempty"` + Index rawJSON `json:"index,omitempty"` // The name of the provider this resource belongs to. This allows // the provider to be interpreted unambiguously in the unusual @@ -224,7 +224,7 @@ type PlanStateResource struct { PlanStateResourceAttributes planStateResourceAttributeList `json:"values,omitempty"` // The addresses of the resources that this resource depends on. - DependsOn string `json:"depends_on,omitempty"` + DependsOn rawJSON `json:"depends_on,omitempty"` // If true, the resource has been marked as tainted and will be // re-created on the next update. @@ -270,7 +270,7 @@ type PlanResourceChange struct { // empty. // // This value can be either an integer (int) or a string. - Index string `json:"index,omitempty"` + Index rawJSON `json:"index,omitempty"` // The name of the provider this resource belongs to. This allows // the provider to be interpreted unambiguously in the unusual diff --git a/types/json.go b/types/json.go index df4edd33..97b337a9 100644 --- a/types/json.go +++ b/types/json.go @@ -11,6 +11,7 @@ import ( *********************************************/ type planOutputList []PlanOutput +type planVariableList []PlanModelVariable type planStateOutputList []PlanStateOutput type planStateResourceAttributeList []PlanStateResourceAttribute type rawJSON string @@ -35,6 +36,25 @@ func (p *planOutputList) UnmarshalJSON(b []byte) error { return nil } +func (p *planVariableList) UnmarshalJSON(b []byte) error { + var tmp map[string]interface{} + err := json.Unmarshal(b, &tmp) + if err != nil { + return err + } + + var list planVariableList + for key, value := range tmp { + list = append(list, PlanModelVariable{ + Key: key, + Value: fmt.Sprintf("%v", value), + }) + } + + *p = list + return nil +} + func (p *planStateOutputList) UnmarshalJSON(b []byte) error { tmp := map[string]PlanStateOutput{} err := json.Unmarshal(b, &tmp)