Skip to content

Commit

Permalink
Merge pull request #2735 from maqiuyujoyce/202409-default-immutable-o…
Browse files Browse the repository at this point in the history
…ptional-fields

Set default values to immutable and optional spec fields for certain kinds
  • Loading branch information
google-oss-prow[bot] authored Sep 19, 2024
2 parents 177c0b9 + 59ac05c commit 8f1482d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/krmtotf/krmtotf.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,25 @@ func KRMResourceToTFResourceConfigFull(r *Resource, c client.Client, smLoader *s
if err != nil {
return nil, nil, fmt.Errorf("error running custom flatteners: %w", err)
}
// Set desired state with default values.
defaultingMap := map[string]map[string]string{
"CloudBuildTrigger": {
"location": "global",
},
"CloudIdentityGroup": {
"initialGroupConfig": "EMPTY",
},
"FirestoreIndex": {
"database": "(default)",
},
}
if defaults, ok := defaultingMap[r.Kind]; ok {
for field, value := range defaults {
if v, ok := config[field]; !ok || v == "" {
config[field] = value
}
}
}
state := InstanceStateToMap(r.TFResource, liveState)
config, err = withResourceCustomResolvers(config, state, r.Kind, r.TFResource)
if err != nil {
Expand Down

0 comments on commit 8f1482d

Please sign in to comment.