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
}
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{}{
"bucketName": expandComputeBackendBucketBucketName(d.Get("bucket_name")),
"description": expandComputeBackendBucketDescription(d.Get("description")),
"enableCdn": expandComputeBackendBucketEnableCdn(d.Get("enable_cdn")),
"name": expandComputeBackendBucketName(d.Get("name")),
"bucketName": bucketNameProp,
"description": descriptionProp,
"enableCdn": enableCdnProp,
"name": nameProp,
}
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
}
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{}{
"bucketName": expandComputeBackendBucketBucketName(d.Get("bucket_name")),
"description": expandComputeBackendBucketDescription(d.Get("description")),
"enableCdn": expandComputeBackendBucketEnableCdn(d.Get("enable_cdn")),
"name": expandComputeBackendBucketName(d.Get("name")),
"bucketName": bucketNameProp,
"description": descriptionProp,
"enableCdn": enableCdnProp,
"name": nameProp,
}
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
}
func expandComputeBackendBucketBucketName(v interface{}) interface{} {
return v
func expandComputeBackendBucketBucketName(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeBackendBucketDescription(v interface{}) interface{} {
return v
func expandComputeBackendBucketDescription(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeBackendBucketEnableCdn(v interface{}) interface{} {
return v
func expandComputeBackendBucketEnableCdn(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeBackendBucketName(v interface{}) interface{} {
return v
func expandComputeBackendBucketName(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}

View File

@ -110,16 +110,53 @@ func resourceComputeHttpHealthCheckCreate(d *schema.ResourceData, meta interface
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{}{
"checkIntervalSec": expandComputeHttpHealthCheckCheckIntervalSec(d.Get("check_interval_sec")),
"description": expandComputeHttpHealthCheckDescription(d.Get("description")),
"healthyThreshold": expandComputeHttpHealthCheckHealthyThreshold(d.Get("healthy_threshold")),
"host": expandComputeHttpHealthCheckHost(d.Get("host")),
"name": expandComputeHttpHealthCheckName(d.Get("name")),
"port": expandComputeHttpHealthCheckPort(d.Get("port")),
"requestPath": expandComputeHttpHealthCheckRequestPath(d.Get("request_path")),
"timeoutSec": expandComputeHttpHealthCheckTimeoutSec(d.Get("timeout_sec")),
"unhealthyThreshold": expandComputeHttpHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold")),
"checkIntervalSec": checkIntervalSecProp,
"description": descriptionProp,
"healthyThreshold": healthyThresholdProp,
"host": hostProp,
"name": nameProp,
"port": portProp,
"requestPath": requestPathProp,
"timeoutSec": timeoutSecProp,
"unhealthyThreshold": unhealthyThresholdProp,
}
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
}
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{}{
"checkIntervalSec": expandComputeHttpHealthCheckCheckIntervalSec(d.Get("check_interval_sec")),
"description": expandComputeHttpHealthCheckDescription(d.Get("description")),
"healthyThreshold": expandComputeHttpHealthCheckHealthyThreshold(d.Get("healthy_threshold")),
"host": expandComputeHttpHealthCheckHost(d.Get("host")),
"name": expandComputeHttpHealthCheckName(d.Get("name")),
"port": expandComputeHttpHealthCheckPort(d.Get("port")),
"requestPath": expandComputeHttpHealthCheckRequestPath(d.Get("request_path")),
"timeoutSec": expandComputeHttpHealthCheckTimeoutSec(d.Get("timeout_sec")),
"unhealthyThreshold": expandComputeHttpHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold")),
"checkIntervalSec": checkIntervalSecProp,
"description": descriptionProp,
"healthyThreshold": healthyThresholdProp,
"host": hostProp,
"name": nameProp,
"port": portProp,
"requestPath": requestPathProp,
"timeoutSec": timeoutSecProp,
"unhealthyThreshold": unhealthyThresholdProp,
}
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
}
func expandComputeHttpHealthCheckCheckIntervalSec(v interface{}) interface{} {
return v
func expandComputeHttpHealthCheckCheckIntervalSec(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpHealthCheckDescription(v interface{}) interface{} {
return v
func expandComputeHttpHealthCheckDescription(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpHealthCheckHealthyThreshold(v interface{}) interface{} {
return v
func expandComputeHttpHealthCheckHealthyThreshold(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpHealthCheckHost(v interface{}) interface{} {
return v
func expandComputeHttpHealthCheckHost(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpHealthCheckName(v interface{}) interface{} {
return v
func expandComputeHttpHealthCheckName(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpHealthCheckPort(v interface{}) interface{} {
return v
func expandComputeHttpHealthCheckPort(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpHealthCheckRequestPath(v interface{}) interface{} {
return v
func expandComputeHttpHealthCheckRequestPath(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpHealthCheckTimeoutSec(v interface{}) interface{} {
return v
func expandComputeHttpHealthCheckTimeoutSec(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpHealthCheckUnhealthyThreshold(v interface{}) interface{} {
return v
func expandComputeHttpHealthCheckUnhealthyThreshold(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}

View File

@ -110,16 +110,53 @@ func resourceComputeHttpsHealthCheckCreate(d *schema.ResourceData, meta interfac
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{}{
"checkIntervalSec": expandComputeHttpsHealthCheckCheckIntervalSec(d.Get("check_interval_sec")),
"description": expandComputeHttpsHealthCheckDescription(d.Get("description")),
"healthyThreshold": expandComputeHttpsHealthCheckHealthyThreshold(d.Get("healthy_threshold")),
"host": expandComputeHttpsHealthCheckHost(d.Get("host")),
"name": expandComputeHttpsHealthCheckName(d.Get("name")),
"port": expandComputeHttpsHealthCheckPort(d.Get("port")),
"requestPath": expandComputeHttpsHealthCheckRequestPath(d.Get("request_path")),
"timeoutSec": expandComputeHttpsHealthCheckTimeoutSec(d.Get("timeout_sec")),
"unhealthyThreshold": expandComputeHttpsHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold")),
"checkIntervalSec": checkIntervalSecProp,
"description": descriptionProp,
"healthyThreshold": healthyThresholdProp,
"host": hostProp,
"name": nameProp,
"port": portProp,
"requestPath": requestPathProp,
"timeoutSec": timeoutSecProp,
"unhealthyThreshold": unhealthyThresholdProp,
}
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
}
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{}{
"checkIntervalSec": expandComputeHttpsHealthCheckCheckIntervalSec(d.Get("check_interval_sec")),
"description": expandComputeHttpsHealthCheckDescription(d.Get("description")),
"healthyThreshold": expandComputeHttpsHealthCheckHealthyThreshold(d.Get("healthy_threshold")),
"host": expandComputeHttpsHealthCheckHost(d.Get("host")),
"name": expandComputeHttpsHealthCheckName(d.Get("name")),
"port": expandComputeHttpsHealthCheckPort(d.Get("port")),
"requestPath": expandComputeHttpsHealthCheckRequestPath(d.Get("request_path")),
"timeoutSec": expandComputeHttpsHealthCheckTimeoutSec(d.Get("timeout_sec")),
"unhealthyThreshold": expandComputeHttpsHealthCheckUnhealthyThreshold(d.Get("unhealthy_threshold")),
"checkIntervalSec": checkIntervalSecProp,
"description": descriptionProp,
"healthyThreshold": healthyThresholdProp,
"host": hostProp,
"name": nameProp,
"port": portProp,
"requestPath": requestPathProp,
"timeoutSec": timeoutSecProp,
"unhealthyThreshold": unhealthyThresholdProp,
}
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
}
func expandComputeHttpsHealthCheckCheckIntervalSec(v interface{}) interface{} {
return v
func expandComputeHttpsHealthCheckCheckIntervalSec(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpsHealthCheckDescription(v interface{}) interface{} {
return v
func expandComputeHttpsHealthCheckDescription(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpsHealthCheckHealthyThreshold(v interface{}) interface{} {
return v
func expandComputeHttpsHealthCheckHealthyThreshold(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpsHealthCheckHost(v interface{}) interface{} {
return v
func expandComputeHttpsHealthCheckHost(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpsHealthCheckName(v interface{}) interface{} {
return v
func expandComputeHttpsHealthCheckName(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpsHealthCheckPort(v interface{}) interface{} {
return v
func expandComputeHttpsHealthCheckPort(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpsHealthCheckRequestPath(v interface{}) interface{} {
return v
func expandComputeHttpsHealthCheckRequestPath(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpsHealthCheckTimeoutSec(v interface{}) interface{} {
return v
func expandComputeHttpsHealthCheckTimeoutSec(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
func expandComputeHttpsHealthCheckUnhealthyThreshold(v interface{}) interface{} {
return v
func expandComputeHttpsHealthCheckUnhealthyThreshold(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}