Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1 #4253

Merged
merged 6 commits into from
Dec 4, 2020
Merged

V1 #4253

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions products/notebooks/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ versions:
- !ruby/object:Api::Product::Version
name: beta
base_url: https://notebooks.googleapis.com/v1beta1/
- !ruby/object:Api::Product::Version
name: ga
base_url: https://notebooks.googleapis.com/v1/
scopes:
- https://www.googleapis.com/auth/cloud-platform
apis_required:
Expand Down Expand Up @@ -47,7 +50,6 @@ objects:
name: 'Environment'
description: |
A Cloud AI Platform Notebook environment.
min_version: beta
base_url: projects/{{project}}/locations/{{location}}/environments
create_url: projects/{{project}}/locations/{{location}}/environments?environmentId={{name}}
self_link: projects/{{project}}/locations/{{location}}/environments/{{name}}
Expand Down Expand Up @@ -136,7 +138,6 @@ objects:
name: 'Instance'
description: |
A Cloud AI Platform Notebook instance.
min_version: beta
base_url: projects/{{project}}/locations/{{location}}/instances
create_url: projects/{{project}}/locations/{{location}}/instances?instanceId={{name}}
self_link: projects/{{project}}/locations/{{location}}/instances/{{name}}
Expand Down
17 changes: 10 additions & 7 deletions products/notebooks/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides
custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb
examples:
- !ruby/object:Provider::Terraform::Examples
min_version: beta
name: "notebook_environment_basic"
primary_resource_id: "environment"
vars:
Expand All @@ -34,27 +33,31 @@ overrides: !ruby/object:Overrides::ResourceOverrides
autogen_async: true
examples:
- !ruby/object:Provider::Terraform::Examples
min_version: beta
name: "notebook_instance_basic"
primary_resource_id: "instance"
primary_resource_name: "fmt.Sprintf(\"tf-test-notebooks-instance%s\", context[\"random_suffix\"])"
region_override: "us-west1-a"
vars:
instance_name: "notebooks-instance"
- !ruby/object:Provider::Terraform::Examples
min_version: beta
name: "notebook_instance_basic_container"
primary_resource_id: "instance"
primary_resource_name: "fmt.Sprintf(\"tf-test-notebooks-instance%s\", context[\"random_suffix\"])"
region_override: "us-west1-a"
vars:
instance_name: "notebooks-instance"
- !ruby/object:Provider::Terraform::Examples
min_version: beta
name: "notebook_instance_basic_gpu"
primary_resource_id: "instance"
primary_resource_name: "fmt.Sprintf(\"tf-test-notebooks-instance%s\", context[\"random_suffix\"])"
region_override: "us-west1-a"
vars:
instance_name: "notebooks-instance"
- !ruby/object:Provider::Terraform::Examples
min_version: beta
name: "notebook_instance_full"
primary_resource_id: "instance"
primary_resource_name: "fmt.Sprintf(\"tf-test-notebooks-instance%s\", context[\"random_suffix\"])"
region_override: "us-west1-a"
vars:
instance_name: "notebooks-instance"
test_env_vars:
Expand Down Expand Up @@ -90,11 +93,11 @@ overrides: !ruby/object:Overrides::ResourceOverrides
# but it gets merged with metadata that the server sets. This prevents us
# from detecting drift.
ignore_read: true
name: !ruby/object:Overrides::Terraform::PropertyOverride
name: !ruby/object:Overrides::Terraform::PropertyOverride
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb'
network: !ruby/object:Overrides::Terraform::PropertyOverride
diff_suppress_func: compareSelfLinkOrResourceName
default_from_api: true
default_from_api: true
serviceAccount: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
subnet: !ruby/object:Overrides::Terraform::PropertyOverride
Expand Down
5 changes: 5 additions & 0 deletions provider/terraform/examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ class Examples < Api::Object
# a reference to the primary resource to create IAM policies for
attr_reader :primary_resource_name

# The name of the location/region override for use in IAM tests. IAM
# tests may need this if the location is not inherited on the resource
# for one reason or another
attr_reader :region_override

# The path to this example's Terraform config.
# Defaults to `templates/terraform/examples/{{name}}.tf.erb`
attr_reader :config_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ import_url = import_format.gsub(/({{)(\w+)(}})/, '%s').gsub(object.__product.bas
<% elsif param == 'zone' -%>
<% import_qualifiers.push('getTestZoneFromEnv()') -%>
<% elsif param == 'region' || param == 'location' -%>
<% import_qualifiers.push('getTestRegionFromEnv()') -%>
<% if example.region_override.nil? -%>
<% import_qualifiers.push('getTestRegionFromEnv()') -%>
<% else -%>
<% import_qualifiers.push("\"#{example.region_override}\"") -%>
<% end -%>
<% end -%>
<% end -%>
func TestAcc<%= resource_name -%>IamBindingGenerated(t *testing.T) {
Expand Down Expand Up @@ -404,7 +408,7 @@ func testAcc<%= resource_name -%>IamBinding_basicGenerated(context map[string]in
<%= example.config_test_body(pwd) -%>

resource "<%= resource_ns_iam -%>_binding" "foo" {
<% unless object.min_version.name == "ga" -%>
<% unless object.min_version.name == "ga" -%>
provider = google-beta
<% end -%>
<%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
resource "google_notebooks_instance" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
name = "<%= ctx[:vars]["instance_name"] %>"
location = "us-west1-a"
machine_type = "e2-medium"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
resource "google_notebooks_instance" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
name = "<%= ctx[:vars]["instance_name"] %>"
location = "us-west1-a"
machine_type = "e2-medium"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
resource "google_notebooks_instance" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
name = "<%= ctx[:vars]["instance_name"] %>"
location = "us-west1-a"
machine_type = "n1-standard-1" // can't be e2 because of accelerator
Expand Down
1 change: 0 additions & 1 deletion templates/terraform/examples/notebook_instance_full.tf.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
resource "google_notebooks_instance" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
name = "<%= ctx[:vars]["instance_name"] %>"
location = "us-central1-a"
machine_type = "e2-medium"
Expand Down