Skip to content

Commit

Permalink
Merge c0ecd69 into 078067a
Browse files Browse the repository at this point in the history
  • Loading branch information
emilymye authored Oct 16, 2018
2 parents 078067a + c0ecd69 commit 6861934
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions provider/terraform/resources/resource_composer_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,10 +677,34 @@ func expandComposerEnvironmentZone(v interface{}, d *schema.ResourceData, config
return getRelativePath(zone)
}

func expandComposerEnvironmentMachineType(v interface{}, d *schema.ResourceData, config *Config, nodeCfgZone interface{}) (string, error) {
func expandComposerEnvironmentMachineType(v interface{}, d *schema.ResourceData, config *Config, nodeCfgZone string) (string, error) {
machineType := v.(string)
requiredZone := GetResourceNameFromSelfLink(nodeCfgZone)

fv, err := ParseMachineTypesFieldValue(v.(string), d, config)
if err != nil {
return "", nil
if requiredZone == "" {
return "", err
}

// Try to construct machine type with zone/project given in config.
project, err := getProject(d, config)
if err != nil {
return "", err
}

fv = &ZonalFieldValue{
Project: project,
Zone: requiredZone,
Name: GetResourceNameFromSelfLink(machineType),
resourceType: "machineTypes",
}
}

// Make sure zone in node_config.machineType matches node_config.zone if
// given.
if requiredZone != "" && fv.Zone != requiredZone {
return "", fmt.Errorf("node_config machine_type %q must be in node_config zone %q", machineType, requiredZone)
}
return fv.RelativeLink(), nil
}
Expand Down

0 comments on commit 6861934

Please sign in to comment.