ResourceRef fields accept name-only or partial/full self_link (#1366)

This commit is contained in:
The Magician 2018-04-23 16:19:26 -07:00 committed by Vincent Roseberry
parent de9363502b
commit 0544ef468f
3 changed files with 270 additions and 88 deletions

View File

@ -85,11 +85,28 @@ func resourceComputeBackendBucketCreate(d *schema.ResourceData, meta interface{}
return err return err
} }
bucketNameProp, err := expandComputeBackendBucketBucketName(d.Get("bucket_name"), d, config)
if err != nil {
return err
}
descriptionProp, err := expandComputeBackendBucketDescription(d.Get("description"), d, config)
if err != nil {
return err
}
enableCdnProp, err := expandComputeBackendBucketEnableCdn(d.Get("enable_cdn"), d, config)
if err != nil {
return err
}
nameProp, err := expandComputeBackendBucketName(d.Get("name"), d, config)
if err != nil {
return err
}
obj := map[string]interface{}{ obj := map[string]interface{}{
"bucketName": expandComputeBackendBucketBucketName(d.Get("bucket_name")), "bucketName": bucketNameProp,
"description": expandComputeBackendBucketDescription(d.Get("description")), "description": descriptionProp,
"enableCdn": expandComputeBackendBucketEnableCdn(d.Get("enable_cdn")), "enableCdn": enableCdnProp,
"name": expandComputeBackendBucketName(d.Get("name")), "name": nameProp,
} }
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/backendBuckets") url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/backendBuckets")
@ -166,11 +183,28 @@ func resourceComputeBackendBucketUpdate(d *schema.ResourceData, meta interface{}
return err return err
} }
bucketNameProp, err := expandComputeBackendBucketBucketName(d.Get("bucket_name"), d, config)
if err != nil {
return err
}
descriptionProp, err := expandComputeBackendBucketDescription(d.Get("description"), d, config)
if err != nil {
return err
}
enableCdnProp, err := expandComputeBackendBucketEnableCdn(d.Get("enable_cdn"), d, config)
if err != nil {
return err
}
nameProp, err := expandComputeBackendBucketName(d.Get("name"), d, config)
if err != nil {
return err
}
obj := map[string]interface{}{ obj := map[string]interface{}{
"bucketName": expandComputeBackendBucketBucketName(d.Get("bucket_name")), "bucketName": bucketNameProp,
"description": expandComputeBackendBucketDescription(d.Get("description")), "description": descriptionProp,
"enableCdn": expandComputeBackendBucketEnableCdn(d.Get("enable_cdn")), "enableCdn": enableCdnProp,
"name": expandComputeBackendBucketName(d.Get("name")), "name": nameProp,
} }
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/backendBuckets/{{name}}") url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/backendBuckets/{{name}}")
@ -272,18 +306,18 @@ func flattenComputeBackendBucketName(v interface{}) interface{} {
return v return v
} }
func expandComputeBackendBucketBucketName(v interface{}) interface{} { func expandComputeBackendBucketBucketName(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeBackendBucketDescription(v interface{}) interface{} { func expandComputeBackendBucketDescription(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeBackendBucketEnableCdn(v interface{}) interface{} { func expandComputeBackendBucketEnableCdn(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeBackendBucketName(v interface{}) interface{} { func expandComputeBackendBucketName(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }

View File

@ -110,16 +110,53 @@ func resourceComputeHttpHealthCheckCreate(d *schema.ResourceData, meta interface
return err return err
} }
checkIntervalSecProp, err := expandComputeHttpHealthCheckCheckIntervalSec(d.Get("check_interval_sec"), d, config)
if err != nil {
return err
}
descriptionProp, err := expandComputeHttpHealthCheckDescription(d.Get("description"), d, config)
if err != nil {
return err
}
healthyThresholdProp, err := expandComputeHttpHealthCheckHealthyThreshold(d.Get("healthy_threshold"), d, config)
if err != nil {
return err
}
hostProp, err := expandComputeHttpHealthCheckHost(d.Get("host"), d, config)
if err != nil {
return err
}
nameProp, err := expandComputeHttpHealthCheckName(d.Get("name"), d, config)
if err != nil {
return err
}
portProp, err := expandComputeHttpHealthCheckPort(d.Get("port"), d, config)
if err != nil {
return err
}
requestPathProp, err := expandComputeHttpHealthCheckRequestPath(d.Get("request_path"), d, config)
if err != nil {
return err
}
timeoutSecProp, err := expandComputeHttpHealthCheckTimeoutSec(d.Get("timeout_sec"), d, config)
if err != nil {
return err
}
unhealthyThresholdProp, err := expandComputeHttpHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold"), d, config)
if err != nil {
return err
}
obj := map[string]interface{}{ obj := map[string]interface{}{
"checkIntervalSec": expandComputeHttpHealthCheckCheckIntervalSec(d.Get("check_interval_sec")), "checkIntervalSec": checkIntervalSecProp,
"description": expandComputeHttpHealthCheckDescription(d.Get("description")), "description": descriptionProp,
"healthyThreshold": expandComputeHttpHealthCheckHealthyThreshold(d.Get("healthy_threshold")), "healthyThreshold": healthyThresholdProp,
"host": expandComputeHttpHealthCheckHost(d.Get("host")), "host": hostProp,
"name": expandComputeHttpHealthCheckName(d.Get("name")), "name": nameProp,
"port": expandComputeHttpHealthCheckPort(d.Get("port")), "port": portProp,
"requestPath": expandComputeHttpHealthCheckRequestPath(d.Get("request_path")), "requestPath": requestPathProp,
"timeoutSec": expandComputeHttpHealthCheckTimeoutSec(d.Get("timeout_sec")), "timeoutSec": timeoutSecProp,
"unhealthyThreshold": expandComputeHttpHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold")), "unhealthyThreshold": unhealthyThresholdProp,
} }
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpHealthChecks") url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpHealthChecks")
@ -201,16 +238,53 @@ func resourceComputeHttpHealthCheckUpdate(d *schema.ResourceData, meta interface
return err return err
} }
checkIntervalSecProp, err := expandComputeHttpHealthCheckCheckIntervalSec(d.Get("check_interval_sec"), d, config)
if err != nil {
return err
}
descriptionProp, err := expandComputeHttpHealthCheckDescription(d.Get("description"), d, config)
if err != nil {
return err
}
healthyThresholdProp, err := expandComputeHttpHealthCheckHealthyThreshold(d.Get("healthy_threshold"), d, config)
if err != nil {
return err
}
hostProp, err := expandComputeHttpHealthCheckHost(d.Get("host"), d, config)
if err != nil {
return err
}
nameProp, err := expandComputeHttpHealthCheckName(d.Get("name"), d, config)
if err != nil {
return err
}
portProp, err := expandComputeHttpHealthCheckPort(d.Get("port"), d, config)
if err != nil {
return err
}
requestPathProp, err := expandComputeHttpHealthCheckRequestPath(d.Get("request_path"), d, config)
if err != nil {
return err
}
timeoutSecProp, err := expandComputeHttpHealthCheckTimeoutSec(d.Get("timeout_sec"), d, config)
if err != nil {
return err
}
unhealthyThresholdProp, err := expandComputeHttpHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold"), d, config)
if err != nil {
return err
}
obj := map[string]interface{}{ obj := map[string]interface{}{
"checkIntervalSec": expandComputeHttpHealthCheckCheckIntervalSec(d.Get("check_interval_sec")), "checkIntervalSec": checkIntervalSecProp,
"description": expandComputeHttpHealthCheckDescription(d.Get("description")), "description": descriptionProp,
"healthyThreshold": expandComputeHttpHealthCheckHealthyThreshold(d.Get("healthy_threshold")), "healthyThreshold": healthyThresholdProp,
"host": expandComputeHttpHealthCheckHost(d.Get("host")), "host": hostProp,
"name": expandComputeHttpHealthCheckName(d.Get("name")), "name": nameProp,
"port": expandComputeHttpHealthCheckPort(d.Get("port")), "port": portProp,
"requestPath": expandComputeHttpHealthCheckRequestPath(d.Get("request_path")), "requestPath": requestPathProp,
"timeoutSec": expandComputeHttpHealthCheckTimeoutSec(d.Get("timeout_sec")), "timeoutSec": timeoutSecProp,
"unhealthyThreshold": expandComputeHttpHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold")), "unhealthyThreshold": unhealthyThresholdProp,
} }
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpHealthChecks/{{name}}") url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpHealthChecks/{{name}}")
@ -332,38 +406,38 @@ func flattenComputeHttpHealthCheckUnhealthyThreshold(v interface{}) interface{}
return v return v
} }
func expandComputeHttpHealthCheckCheckIntervalSec(v interface{}) interface{} { func expandComputeHttpHealthCheckCheckIntervalSec(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpHealthCheckDescription(v interface{}) interface{} { func expandComputeHttpHealthCheckDescription(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpHealthCheckHealthyThreshold(v interface{}) interface{} { func expandComputeHttpHealthCheckHealthyThreshold(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpHealthCheckHost(v interface{}) interface{} { func expandComputeHttpHealthCheckHost(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpHealthCheckName(v interface{}) interface{} { func expandComputeHttpHealthCheckName(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpHealthCheckPort(v interface{}) interface{} { func expandComputeHttpHealthCheckPort(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpHealthCheckRequestPath(v interface{}) interface{} { func expandComputeHttpHealthCheckRequestPath(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpHealthCheckTimeoutSec(v interface{}) interface{} { func expandComputeHttpHealthCheckTimeoutSec(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpHealthCheckUnhealthyThreshold(v interface{}) interface{} { func expandComputeHttpHealthCheckUnhealthyThreshold(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }

View File

@ -110,16 +110,53 @@ func resourceComputeHttpsHealthCheckCreate(d *schema.ResourceData, meta interfac
return err return err
} }
checkIntervalSecProp, err := expandComputeHttpsHealthCheckCheckIntervalSec(d.Get("check_interval_sec"), d, config)
if err != nil {
return err
}
descriptionProp, err := expandComputeHttpsHealthCheckDescription(d.Get("description"), d, config)
if err != nil {
return err
}
healthyThresholdProp, err := expandComputeHttpsHealthCheckHealthyThreshold(d.Get("healthy_threshold"), d, config)
if err != nil {
return err
}
hostProp, err := expandComputeHttpsHealthCheckHost(d.Get("host"), d, config)
if err != nil {
return err
}
nameProp, err := expandComputeHttpsHealthCheckName(d.Get("name"), d, config)
if err != nil {
return err
}
portProp, err := expandComputeHttpsHealthCheckPort(d.Get("port"), d, config)
if err != nil {
return err
}
requestPathProp, err := expandComputeHttpsHealthCheckRequestPath(d.Get("request_path"), d, config)
if err != nil {
return err
}
timeoutSecProp, err := expandComputeHttpsHealthCheckTimeoutSec(d.Get("timeout_sec"), d, config)
if err != nil {
return err
}
unhealthyThresholdProp, err := expandComputeHttpsHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold"), d, config)
if err != nil {
return err
}
obj := map[string]interface{}{ obj := map[string]interface{}{
"checkIntervalSec": expandComputeHttpsHealthCheckCheckIntervalSec(d.Get("check_interval_sec")), "checkIntervalSec": checkIntervalSecProp,
"description": expandComputeHttpsHealthCheckDescription(d.Get("description")), "description": descriptionProp,
"healthyThreshold": expandComputeHttpsHealthCheckHealthyThreshold(d.Get("healthy_threshold")), "healthyThreshold": healthyThresholdProp,
"host": expandComputeHttpsHealthCheckHost(d.Get("host")), "host": hostProp,
"name": expandComputeHttpsHealthCheckName(d.Get("name")), "name": nameProp,
"port": expandComputeHttpsHealthCheckPort(d.Get("port")), "port": portProp,
"requestPath": expandComputeHttpsHealthCheckRequestPath(d.Get("request_path")), "requestPath": requestPathProp,
"timeoutSec": expandComputeHttpsHealthCheckTimeoutSec(d.Get("timeout_sec")), "timeoutSec": timeoutSecProp,
"unhealthyThreshold": expandComputeHttpsHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold")), "unhealthyThreshold": unhealthyThresholdProp,
} }
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpsHealthChecks") url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpsHealthChecks")
@ -201,16 +238,53 @@ func resourceComputeHttpsHealthCheckUpdate(d *schema.ResourceData, meta interfac
return err return err
} }
checkIntervalSecProp, err := expandComputeHttpsHealthCheckCheckIntervalSec(d.Get("check_interval_sec"), d, config)
if err != nil {
return err
}
descriptionProp, err := expandComputeHttpsHealthCheckDescription(d.Get("description"), d, config)
if err != nil {
return err
}
healthyThresholdProp, err := expandComputeHttpsHealthCheckHealthyThreshold(d.Get("healthy_threshold"), d, config)
if err != nil {
return err
}
hostProp, err := expandComputeHttpsHealthCheckHost(d.Get("host"), d, config)
if err != nil {
return err
}
nameProp, err := expandComputeHttpsHealthCheckName(d.Get("name"), d, config)
if err != nil {
return err
}
portProp, err := expandComputeHttpsHealthCheckPort(d.Get("port"), d, config)
if err != nil {
return err
}
requestPathProp, err := expandComputeHttpsHealthCheckRequestPath(d.Get("request_path"), d, config)
if err != nil {
return err
}
timeoutSecProp, err := expandComputeHttpsHealthCheckTimeoutSec(d.Get("timeout_sec"), d, config)
if err != nil {
return err
}
unhealthyThresholdProp, err := expandComputeHttpsHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold"), d, config)
if err != nil {
return err
}
obj := map[string]interface{}{ obj := map[string]interface{}{
"checkIntervalSec": expandComputeHttpsHealthCheckCheckIntervalSec(d.Get("check_interval_sec")), "checkIntervalSec": checkIntervalSecProp,
"description": expandComputeHttpsHealthCheckDescription(d.Get("description")), "description": descriptionProp,
"healthyThreshold": expandComputeHttpsHealthCheckHealthyThreshold(d.Get("healthy_threshold")), "healthyThreshold": healthyThresholdProp,
"host": expandComputeHttpsHealthCheckHost(d.Get("host")), "host": hostProp,
"name": expandComputeHttpsHealthCheckName(d.Get("name")), "name": nameProp,
"port": expandComputeHttpsHealthCheckPort(d.Get("port")), "port": portProp,
"requestPath": expandComputeHttpsHealthCheckRequestPath(d.Get("request_path")), "requestPath": requestPathProp,
"timeoutSec": expandComputeHttpsHealthCheckTimeoutSec(d.Get("timeout_sec")), "timeoutSec": timeoutSecProp,
"unhealthyThreshold": expandComputeHttpsHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold")), "unhealthyThreshold": unhealthyThresholdProp,
} }
url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpsHealthChecks/{{name}}") url, err := replaceVars(d, config, "https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpsHealthChecks/{{name}}")
@ -332,38 +406,38 @@ func flattenComputeHttpsHealthCheckUnhealthyThreshold(v interface{}) interface{}
return v return v
} }
func expandComputeHttpsHealthCheckCheckIntervalSec(v interface{}) interface{} { func expandComputeHttpsHealthCheckCheckIntervalSec(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpsHealthCheckDescription(v interface{}) interface{} { func expandComputeHttpsHealthCheckDescription(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpsHealthCheckHealthyThreshold(v interface{}) interface{} { func expandComputeHttpsHealthCheckHealthyThreshold(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpsHealthCheckHost(v interface{}) interface{} { func expandComputeHttpsHealthCheckHost(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpsHealthCheckName(v interface{}) interface{} { func expandComputeHttpsHealthCheckName(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpsHealthCheckPort(v interface{}) interface{} { func expandComputeHttpsHealthCheckPort(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpsHealthCheckRequestPath(v interface{}) interface{} { func expandComputeHttpsHealthCheckRequestPath(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpsHealthCheckTimeoutSec(v interface{}) interface{} { func expandComputeHttpsHealthCheckTimeoutSec(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }
func expandComputeHttpsHealthCheckUnhealthyThreshold(v interface{}) interface{} { func expandComputeHttpsHealthCheckUnhealthyThreshold(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v return v, nil
} }