Skip to content

Commit

Permalink
Runtime patch (#6137)
Browse files Browse the repository at this point in the history
Co-authored-by: Shuya Ma <[email protected]>
  • Loading branch information
m-mayran and shuyama1 authored Jul 15, 2022
1 parent d022009 commit b720f35
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 1 deletion.
17 changes: 16 additions & 1 deletion mmv1/products/notebooks/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ objects:
create_url: projects/{{project}}/locations/{{location}}/runtimes?runtimeId={{name}}
self_link: projects/{{project}}/locations/{{location}}/runtimes/{{name}}
create_verb: :POST
update_verb: :PATCH
update_mask: true
# When set, if any parameter change, they will get recreated.
# Use wisely because any `update_url:` in the hierarchy below this will get ignored.
# input: true
Expand Down Expand Up @@ -503,7 +505,7 @@ objects:
- !ruby/object:Api::Type::String
name: 'name'
description: |
The name specified for the Notebook instance.
The name specified for the Notebook runtime.
required: true
input: true
url_param_only: true
Expand Down Expand Up @@ -673,6 +675,7 @@ objects:
name: "containerImages"
description: |
Use a list of container images to start the notebook instance.
input: true
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
Expand All @@ -689,6 +692,7 @@ objects:
name: "encryptionConfig"
description: |
Encryption settings for virtual machine data disk.
input: true
properties:
- !ruby/object:Api::Type::String
name: "kmsKey"
Expand All @@ -702,6 +706,7 @@ objects:
name: "shieldedInstanceConfig"
description: |
Shielded VM Instance configuration settings.
input: true
properties:
- !ruby/object:Api::Type::Boolean
name: "enableSecureBoot"
Expand Down Expand Up @@ -757,6 +762,7 @@ objects:
configuring Private Service Access.
* Shared VPC (network & subnet are required). Requires
configuring Private Service Access.
input: true
- !ruby/object:Api::Type::String
name: "subnet"
description: |
Expand All @@ -766,6 +772,7 @@ objects:
* `https://www.googleapis.com/compute/v1/projects/[project_id]/
regions/us-east1/subnetworks/sub0`
* `projects/[project_id]/regions/us-east1/subnetworks/sub0`
input: true
- !ruby/object:Api::Type::Boolean
name: "internalIpOnly"
description: |
Expand All @@ -775,6 +782,7 @@ objects:
`internal_ip_only` restriction can only be enabled for subnetwork
enabled networks, and all dependencies must be configured to be
accessible without external IP addresses.
input: true
- !ruby/object:Api::Type::Array
name: "tags"
description: |
Expand Down Expand Up @@ -810,10 +818,17 @@ objects:
description: |
The type of vNIC to be used on this interface. This may be gVNIC
or VirtioNet.
input: true
values:
- UNSPECIFIED_NIC_TYPE
- VIRTIO_NET
- GVNIC
- !ruby/object:Api::Type::String
name: "reservedIpRange"
description: |
Reserved IP Range name is used for VPC Peering. The
subnetwork allocation will use the range *name* if it's assigned.
input: true
- !ruby/object:Api::Type::Enum
name: 'state'
values:
Expand Down
5 changes: 5 additions & 0 deletions mmv1/products/notebooks/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ overrides: !ruby/object:Overrides::ResourceOverrides
softwareConfig: !ruby/object:Overrides::Terraform::PropertyOverride
# API returns default idleShutdown (true) and default idleShutdownTimeout (180).
default_from_api: true
update_mask_fields:
- "softwareConfig.idleShutdown"
- "softwareConfig.idleShutdownTimeout"
- "softwareConfig.customGpuDriverPath"
- "softwareConfig.postStartupScript"
Location: !ruby/object:Overrides::Terraform::ResourceOverride
properties:
name: !ruby/object:Overrides::Terraform::PropertyOverride
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<% autogen_exception -%>
package google

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccNotebooksRuntime_update(t *testing.T) {
context := map[string]interface{}{
"random_suffix": randString(t, 10),
}

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckNotebooksRuntimeDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccNotebooksRuntime_basic(context),
},
{
ResourceName: "google_notebooks_runtime.runtime",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccNotebooksRuntime_update(context),
},
{
ResourceName: "google_notebooks_runtime.runtime",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccNotebooksRuntime_basic(context),
},
{
ResourceName: "google_notebooks_runtime.runtime",
ImportState: true,
ImportStateVerify: true,
},
},
})
}


func testAccNotebooksRuntime_basic(context map[string]interface{}) string {
return Nprintf(`
resource "google_notebooks_runtime" "runtime" {
name = "tf-test-notebooks-runtime%{random_suffix}"
location = "us-central1"
access_config {
access_type = "SINGLE_USER"
runtime_owner = "[email protected]"
}
software_config {}
virtual_machine {
virtual_machine_config {
machine_type = "n1-standard-4"
data_disk {
initialize_params {
disk_size_gb = "100"
disk_type = "PD_STANDARD"
}
}
reserved_ip_range = "192.168.255.0/24"
}
}
}
`, context)
}

func testAccNotebooksRuntime_update(context map[string]interface{}) string {
return Nprintf(`
resource "google_notebooks_runtime" "runtime" {
name = "tf-test-notebooks-runtime%{random_suffix}"
location = "us-central1"
access_config {
access_type = "SINGLE_USER"
runtime_owner = "[email protected]"
}
software_config {
idle_shutdown_timeout = "80"
}
virtual_machine {
virtual_machine_config {
machine_type = "n1-standard-4"
data_disk {
initialize_params {
disk_size_gb = "100"
disk_type = "PD_STANDARD"
}
}
reserved_ip_range = "192.168.255.0/24"
}
}
}
`, context)
}

0 comments on commit b720f35

Please sign in to comment.