-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Modular Magician <magic-modules@google.com>
- Loading branch information
1 parent
42f0ee8
commit a12e9e9
Showing
1 changed file
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// This file is automatically generated by Magic Modules and manual | ||
// changes will be clobbered when the file is regenerated. | ||
// | ||
// Please read more about how to change this file in | ||
// .github/CONTRIBUTING.md. | ||
// | ||
// ---------------------------------------------------------------------------- | ||
|
||
package google | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
) | ||
|
||
func GetComputeNodeGroupCaiObject(d TerraformResourceData, config *Config) (Asset, error) { | ||
name, err := assetName(d, config, "//compute.googleapis.com/projects/{{project}}/zones/{{zone}}/nodeGroups/{{name}}") | ||
if err != nil { | ||
return Asset{}, err | ||
} | ||
if obj, err := GetComputeNodeGroupApiObject(d, config); err == nil { | ||
return Asset{ | ||
Name: name, | ||
Type: "compute.googleapis.com/NodeGroup", | ||
Resource: &AssetResource{ | ||
Version: "v1", | ||
DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/compute/v1/rest", | ||
DiscoveryName: "NodeGroup", | ||
Data: obj, | ||
}, | ||
}, nil | ||
} else { | ||
return Asset{}, err | ||
} | ||
} | ||
|
||
func GetComputeNodeGroupApiObject(d TerraformResourceData, config *Config) (map[string]interface{}, error) { | ||
obj := make(map[string]interface{}) | ||
descriptionProp, err := expandComputeNodeGroupDescription(d.Get("description"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { | ||
obj["description"] = descriptionProp | ||
} | ||
nameProp, err := expandComputeNodeGroupName(d.Get("name"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("name"); !isEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { | ||
obj["name"] = nameProp | ||
} | ||
nodeTemplateProp, err := expandComputeNodeGroupNodeTemplate(d.Get("node_template"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("node_template"); !isEmptyValue(reflect.ValueOf(nodeTemplateProp)) && (ok || !reflect.DeepEqual(v, nodeTemplateProp)) { | ||
obj["nodeTemplate"] = nodeTemplateProp | ||
} | ||
sizeProp, err := expandComputeNodeGroupSize(d.Get("size"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("size"); !isEmptyValue(reflect.ValueOf(sizeProp)) && (ok || !reflect.DeepEqual(v, sizeProp)) { | ||
obj["size"] = sizeProp | ||
} | ||
zoneProp, err := expandComputeNodeGroupZone(d.Get("zone"), d, config) | ||
if err != nil { | ||
return nil, err | ||
} else if v, ok := d.GetOkExists("zone"); !isEmptyValue(reflect.ValueOf(zoneProp)) && (ok || !reflect.DeepEqual(v, zoneProp)) { | ||
obj["zone"] = zoneProp | ||
} | ||
|
||
return obj, nil | ||
} | ||
|
||
func expandComputeNodeGroupDescription(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { | ||
return v, nil | ||
} | ||
|
||
func expandComputeNodeGroupName(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { | ||
return v, nil | ||
} | ||
|
||
func expandComputeNodeGroupNodeTemplate(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { | ||
f, err := parseRegionalFieldValue("nodeTemplates", v.(string), "project", "region", "zone", d, config, true) | ||
if err != nil { | ||
return nil, fmt.Errorf("Invalid value for node_template: %s", err) | ||
} | ||
return f.RelativeLink(), nil | ||
} | ||
|
||
func expandComputeNodeGroupSize(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { | ||
return v, nil | ||
} | ||
|
||
func expandComputeNodeGroupZone(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { | ||
f, err := parseGlobalFieldValue("zones", v.(string), "project", d, config, true) | ||
if err != nil { | ||
return nil, fmt.Errorf("Invalid value for zone: %s", err) | ||
} | ||
return f.RelativeLink(), nil | ||
} |