-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ty Larrabee
committed
Nov 13, 2019
1 parent
35cba66
commit 56fe3fd
Showing
6 changed files
with
252 additions
and
2 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
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,63 @@ | ||
# Copyright 2019 Google Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
--- !ruby/object:Provider::Terraform::Config | ||
overrides: !ruby/object:Overrides::ResourceOverrides | ||
Queue: !ruby/object:Overrides::Terraform::ResourceOverride | ||
id_format: "projects/{{project}}/locations/{{location}}/queues/{{name}}" | ||
parameters: | ||
status: !ruby/object:Overrides::Terraform::PropertyOverride | ||
output: true | ||
properties: | ||
appEngineRoutingOverride: !ruby/object:Overrides::Terraform::PropertyOverride | ||
custom_flatten: templates/terraform/custom_flatten/cloudtasks_queue_appenginerouting.go.erb | ||
location: !ruby/object:Overrides::Terraform::PropertyOverride | ||
url_param_only: true | ||
name: !ruby/object:Overrides::Terraform::PropertyOverride | ||
custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb | ||
custom_expand: templates/terraform/custom_expand/qualify_queue_name.go.erb | ||
rateLimits: !ruby/object:Overrides::Terraform::PropertyOverride | ||
default_from_api: true | ||
rateLimits.maxConcurrentDispatches: !ruby/object:Overrides::Terraform::PropertyOverride | ||
default_from_api: true | ||
rateLimits.maxDispatchesPerSecond: !ruby/object:Overrides::Terraform::PropertyOverride | ||
default_from_api: true | ||
retryConfig: !ruby/object:Overrides::Terraform::PropertyOverride | ||
default_from_api: true | ||
retryConfig.maxAttempts: !ruby/object:Overrides::Terraform::PropertyOverride | ||
default_from_api: true | ||
retryConfig.maxRetryDuration: !ruby/object:Overrides::Terraform::PropertyOverride | ||
default_from_api: true | ||
retryConfig.minBackoff: !ruby/object:Overrides::Terraform::PropertyOverride | ||
default_from_api: true | ||
retryConfig.maxBackoff: !ruby/object:Overrides::Terraform::PropertyOverride | ||
default_from_api: true | ||
retryConfig.maxDoublings: !ruby/object:Overrides::Terraform::PropertyOverride | ||
default_from_api: true | ||
retryConfig.purgeTime: !ruby/object:Overrides::Terraform::PropertyOverride | ||
exclude: true | ||
status: !ruby/object:Overrides::Terraform::PropertyOverride | ||
exclude: true | ||
examples: | ||
- !ruby/object:Provider::Terraform::Examples | ||
name: "queue_basic" | ||
primary_resource_id: "default" | ||
vars: | ||
name: "cloud-tasks-queue-test" | ||
|
||
# This is for copying files over | ||
files: !ruby/object:Provider::Config::Files | ||
# These files have templating (ERB) code that will be run. | ||
# This is usually to add licensing info, autogeneration notices, etc. | ||
compile: | ||
<%= lines(indent(compile('provider/terraform/product~compile.yaml'), 4)) -%> |
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,3 @@ | ||
func expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { | ||
return replaceVars(d, config, "projects/{{project}}/locations/{{location}}/queues/{{name}}") | ||
} |
32 changes: 32 additions & 0 deletions
32
templates/terraform/custom_flatten/cloudtasks_queue_appenginerouting.go.erb
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,32 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2019 Google Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
-%> | ||
// service, version, and instance are input-only. host is output-only. | ||
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData) interface{} { | ||
if v == nil { | ||
return nil | ||
} | ||
original := v.(map[string]interface{}) | ||
if len(original) == 0 { | ||
return nil | ||
} | ||
transformed := make(map[string]interface{}) | ||
transformed["host"] = original["host"] | ||
if override, ok := d.GetOk("app_engine_routing_override"); ok && len(override.([]interface{})) > 0 { | ||
transformed["service"] = d.Get("app_engine_routing_override.0.service") | ||
transformed["version"] = d.Get("app_engine_routing_override.0.version") | ||
transformed["instance"] = d.Get("app_engine_routing_override.0.instance") | ||
} | ||
return []interface{}{transformed} | ||
} |
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,4 @@ | ||
resource "google_cloud_tasks_queue" "default" { | ||
name = "<%= ctx[:vars]['name'] %>" | ||
location = "us-central1" | ||
} |
144 changes: 144 additions & 0 deletions
144
third_party/terraform/tests/resource_cloud_tasks_queue_test.go.erb
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,144 @@ | ||
<% autogen_exception -%> | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest" | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
) | ||
|
||
func TestAccCloudTasksQueue_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
name := "cloudtasksqueuetest-" + acctest.RandString(10) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCloudTasksQueue_full(name), | ||
}, | ||
{ | ||
ResourceName: "google_cloud_tasks_queue.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"app_engine_routing_override.0.service", "app_engine_routing_override.0.version", "app_engine_routing_override.0.instance"}, | ||
}, | ||
{ | ||
Config: testAccCloudTasksQueue_update(name), | ||
}, | ||
{ | ||
ResourceName: "google_cloud_tasks_queue.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"app_engine_routing_override.0.service", "app_engine_routing_override.0.version", "app_engine_routing_override.0.instance"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccCloudTasksQueue_update2Basic(t *testing.T) { | ||
t.Parallel() | ||
|
||
name := "cloudtasksqueuetest-" + acctest.RandString(10) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCloudTasksQueue_full(name), | ||
}, | ||
{ | ||
ResourceName: "google_cloud_tasks_queue.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"app_engine_routing_override.0.service", "app_engine_routing_override.0.version", "app_engine_routing_override.0.instance"}, | ||
}, | ||
{ | ||
Config: testAccCloudTasksQueue_basic(name), | ||
}, | ||
{ | ||
ResourceName: "google_cloud_tasks_queue.default", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"app_engine_routing_override.0.service", "app_engine_routing_override.0.version", "app_engine_routing_override.0.instance"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCloudTasksQueue_basic(name string) string { | ||
return fmt.Sprintf(` | ||
resource "google_cloud_tasks_queue" "default" { | ||
name = "%s" | ||
location = "us-central1" | ||
|
||
retry_config { | ||
max_attempts = 5 | ||
} | ||
|
||
} | ||
`, name) | ||
} | ||
|
||
func testAccCloudTasksQueue_full(name string) string { | ||
return fmt.Sprintf(` | ||
resource "google_cloud_tasks_queue" "default" { | ||
name = "%s" | ||
location = "us-central1" | ||
|
||
app_engine_routing_override { | ||
service = "worker" | ||
version = "1.0" | ||
instance = "test" | ||
} | ||
|
||
rate_limits { | ||
max_concurrent_dispatches = 3 | ||
max_dispatches_per_second = 2 | ||
} | ||
|
||
retry_config { | ||
max_attempts = 5 | ||
max_retry_duration = "4s" | ||
max_backoff = "3s" | ||
min_backoff = "2s" | ||
max_doublings = 1 | ||
} | ||
|
||
} | ||
`, name) | ||
} | ||
|
||
func testAccCloudTasksQueue_update(name string) string { | ||
return fmt.Sprintf(` | ||
resource "google_cloud_tasks_queue" "default" { | ||
name = "%s" | ||
location = "us-central1" | ||
|
||
app_engine_routing_override { | ||
service = "main" | ||
version = "2.0" | ||
instance = "beta" | ||
} | ||
|
||
rate_limits { | ||
max_concurrent_dispatches = 4 | ||
max_dispatches_per_second = 3 | ||
} | ||
|
||
retry_config { | ||
max_attempts = 6 | ||
max_retry_duration = "5s" | ||
max_backoff = "4s" | ||
min_backoff = "3s" | ||
max_doublings = 2 | ||
} | ||
|
||
} | ||
`, name) | ||
} |