Skip to content

Commit

Permalink
Adding the namespace_labels field to the GKE Hub Scope resource (#997…
Browse files Browse the repository at this point in the history
…2) (#1992)

* initial commit for scope-level namespace labels

* Add validation exceptions for the  field of the GKEHub Scope and Namespace resources to be of type

* Undoing unnecessary changes

* Fixing the type of Scope namespace_labels field

[upstream:3e13564ac5d3ac814949b399e0fd56058445a717]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Feb 26, 2024
1 parent 4629e8e commit 8f5a507
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ func GetGKEHub2ScopeCaiObject(d tpgresource.TerraformResourceData, config *trans

func GetGKEHub2ScopeApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) {
obj := make(map[string]interface{})
namespaceLabelsProp, err := expandGKEHub2ScopeNamespaceLabels(d.Get("namespace_labels"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("namespace_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(namespaceLabelsProp)) && (ok || !reflect.DeepEqual(v, namespaceLabelsProp)) {
obj["namespaceLabels"] = namespaceLabelsProp
}
labelsProp, err := expandGKEHub2ScopeEffectiveLabels(d.Get("effective_labels"), d, config)
if err != nil {
return nil, err
Expand All @@ -64,6 +70,17 @@ func GetGKEHub2ScopeApiObject(d tpgresource.TerraformResourceData, config *trans
return obj, nil
}

func expandGKEHub2ScopeNamespaceLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
if v == nil {
return map[string]string{}, nil
}
m := make(map[string]string)
for k, val := range v.(map[string]interface{}) {
m[k] = val.(string)
}
return m, nil
}

func expandGKEHub2ScopeEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
if v == nil {
return map[string]string{}, nil
Expand Down

0 comments on commit 8f5a507

Please sign in to comment.