Skip to content

Commit

Permalink
ResourceRef fields accept name-only or partial/full self_link (#1366)
Browse files Browse the repository at this point in the history
  • Loading branch information
modular-magician authored and rosbo committed Apr 23, 2018
1 parent de93635 commit 0544ef4
Show file tree
Hide file tree
Showing 3 changed files with 270 additions and 88 deletions.
66 changes: 50 additions & 16 deletions google/resource_compute_backend_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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}}")
Expand Down Expand Up @@ -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
}
146 changes: 110 additions & 36 deletions google/resource_compute_http_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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}}")
Expand Down Expand Up @@ -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
}
Loading

0 comments on commit 0544ef4

Please sign in to comment.