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

Add Gemini Release Channel Setting Binding resource #12895

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e89495c
Add Gemini Release Channel Setting Binding resource
PerlMonker303 Jan 28, 2025
373d035
Remove extra line
PerlMonker303 Jan 28, 2025
203554c
Remove project declaration
PerlMonker303 Jan 29, 2025
24ceadf
Update mmv1/products/gemini/ReleaseChannelSettingBinding.yaml
melinath Jan 29, 2025
94894a0
Remove errors field
PerlMonker303 Jan 29, 2025
909e835
Mark resources as beta
PerlMonker303 Feb 3, 2025
61dbb2c
Remove resource dependency
PerlMonker303 Feb 3, 2025
30b0376
Add product specification
PerlMonker303 Feb 3, 2025
6e726f9
Add missing comma
PerlMonker303 Feb 3, 2025
9ce8003
Merge remote-tracking branch 'upstream/main' into mm-separate-release…
PerlMonker303 Feb 3, 2025
184ef67
Exclude tests
PerlMonker303 Feb 4, 2025
c2e0f6e
Remove required field from location
PerlMonker303 Feb 5, 2025
53cc693
Add test project
PerlMonker303 Feb 5, 2025
5ab11bf
Add random suffix to setting id
PerlMonker303 Feb 5, 2025
8be1621
Added beta provider to google project
PerlMonker303 Feb 5, 2025
2308239
Remove product from tests
PerlMonker303 Feb 5, 2025
b9c2956
Add different projects for testing
PerlMonker303 Feb 5, 2025
7fd365c
Add project id to project declarations
PerlMonker303 Feb 5, 2025
af0d85e
Remove hardcoded project ids
PerlMonker303 Feb 5, 2025
3a9bd1e
Create new project from Terraform for update
PerlMonker303 Feb 6, 2025
1cf2481
Add labels update
PerlMonker303 Feb 6, 2025
6805db1
Remove new_project_id variable
PerlMonker303 Feb 6, 2025
4fa20d2
Remove extra project
PerlMonker303 Feb 6, 2025
96608c4
Change product to enum
PerlMonker303 Feb 7, 2025
8810d28
Remove new_project
PerlMonker303 Feb 7, 2025
94bca4c
Change name of settings
PerlMonker303 Feb 7, 2025
7b0aa11
Add label to tests
PerlMonker303 Feb 7, 2025
e1b0cf8
Consistency changes
PerlMonker303 Feb 7, 2025
ef36e5b
Modify random string length
PerlMonker303 Feb 7, 2025
0083d11
Change product in acctest
PerlMonker303 Feb 7, 2025
912b97a
Remove product altogether from acc tests
PerlMonker303 Feb 7, 2025
845108b
Add tf-test prefix to resource names
PerlMonker303 Feb 7, 2025
a4d4d76
Add tf-test prefix to logging setting tests
PerlMonker303 Feb 7, 2025
1755f5a
Undo enum
PerlMonker303 Feb 7, 2025
d705867
Remove extra descriptions
PerlMonker303 Feb 7, 2025
75326e8
Remove product from test
PerlMonker303 Feb 7, 2025
7ccfeb9
Simplify test names
PerlMonker303 Feb 7, 2025
6b50639
Update labels map format
PerlMonker303 Feb 7, 2025
7081b34
Change random suffix length back to 10
PerlMonker303 Feb 7, 2025
ef17209
Add new project
PerlMonker303 Feb 7, 2025
08fd5fc
Use new project everywhere
PerlMonker303 Feb 7, 2025
88a313e
Add beta-provider to new project
PerlMonker303 Feb 7, 2025
7523c4e
Fix reference to new project
PerlMonker303 Feb 7, 2025
cf59a57
Take org and billing account from env var
PerlMonker303 Feb 7, 2025
fc67df8
Add test_env_var
PerlMonker303 Feb 7, 2025
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
8 changes: 4 additions & 4 deletions mmv1/products/gemini/ReleaseChannelSetting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ parameters:
properties:
- name: createTime
type: String
description: Output only. [Output only] Create time stamp.
description: Create time stamp.
output: true
- name: updateTime
type: String
description: Output only. [Output only] Update time stamp.
description: Update time stamp.
output: true
- name: labels
type: KeyValueLabels
description: Optional. Labels as key value pairs.
description: Labels as key value pairs.
- name: releaseChannel
type: String
description: |-
Optional. Release channel to be used.
Release channel to be used.
Possible values:
STABLE
EXPERIMENTAL
Expand Down
105 changes: 105 additions & 0 deletions mmv1/products/gemini/ReleaseChannelSettingBinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Copyright 2025 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.

---
name: ReleaseChannelSettingBinding
description: The resource for managing ReleaseChannel setting bindings for Admin Control.
min_version: 'beta'
base_url: projects/{{project}}/locations/{{location}}/releaseChannelSettings/{{release_channel_setting_id}}/settingBindings
self_link: projects/{{project}}/locations/{{location}}/releaseChannelSettings/{{release_channel_setting_id}}/settingBindings/{{setting_binding_id}}
create_url: projects/{{project}}/locations/{{location}}/releaseChannelSettings/{{release_channel_setting_id}}/settingBindings?settingBindingId={{setting_binding_id}}
id_format: projects/{{project}}/locations/{{location}}/releaseChannelSettings/{{release_channel_setting_id}}/settingBindings/{{setting_binding_id}}
update_verb: PATCH
update_mask: true
import_format:
- projects/{{project}}/locations/{{location}}/releaseChannelSettings/{{release_channel_setting_id}}/settingBindings/{{setting_binding_id}}
mutex: projects/{{project}}/locations/{{location}}/releaseChannelSettings/{{release_channel_setting_id}}
examples:
- name: gemini_release_channel_setting_binding_basic
min_version: 'beta'
primary_resource_id: example
exclude_test: true
vars:
release_channel_setting_id: ls-tf1
setting_binding_id: ls-tf1b1
target: projects/980109375338
test_env_vars:
org_id: "ORG_ID"
billing_account: "BILLING_ACCT"
autogen_async: true
async:
operation:
timeouts:
insert_minutes: 90
update_minutes: 90
delete_minutes: 90
base_url: '{{op_id}}'
actions:
- create
- delete
- update
type: OpAsync
result:
resource_inside_response: true
include_project: false
autogen_status: U2V0dGluZ0JpbmRpbmdCeVByb2plY3RBbmRMb2NhdGlvbkFuZFJlbGVhc2VjaGFubmVsc2V0dGluZw==
parameters:
- name: location
type: String
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
immutable: true
url_param_only: true
- name: releaseChannelSettingId
type: String
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
immutable: true
url_param_only: true
required: true
- name: settingBindingId
type: String
description: |-
Id of the requesting object.
If auto-generating Id server-side, remove this field and
setting_id from the method_signature of Create RPC.
immutable: true
url_param_only: true
required: true
properties:
- name: name
type: String
description: |-
Identifier. Name of the resource.
Format:projects/{project}/locations/{location}/{settingType}/{setting}/settingBindings/{setting_binding}
output: true
- name: createTime
type: String
description: Create time stamp.
output: true
- name: updateTime
type: String
description: Update time stamp.
output: true
- name: labels
type: KeyValueLabels
description: Labels as key value pairs.
- name: target
type: String
description: Target of the binding.
required: true
- name: product
type: Enum
description: |-
Product type of the setting binding.
enum_values:
- 'GEMINI_CLOUD_ASSIST'
- 'GEMINI_CODE_ASSIST'
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ resource "google_gemini_release_channel_setting" "{{$.PrimaryResourceId}}" {
provider = google-beta
release_channel_setting_id = "{{index $.Vars "release_channel_setting_id"}}"
location = "global"
labels = {"my_key": "my_value"}
release_channel = "EXPERIMENTAL"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "google_gemini_release_channel_setting" "basic" {
provider = google-beta
release_channel_setting_id = "{{index $.Vars "release_channel_setting_id"}}"
location = "global"
labels = {"my_key": "my_value"}
release_channel = "EXPERIMENTAL"
}

resource "google_gemini_release_channel_setting_binding" "{{$.PrimaryResourceId}}" {
provider = google-beta
release_channel_setting_id = google_gemini_release_channel_setting.basic.release_channel_setting_id
setting_binding_id = "{{index $.Vars "setting_binding_id"}}"
location = "global"
target = "{{index $.Vars "target"}}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package gemini_test
{{- if ne $.TargetVersionName "ga" }}

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/plancheck"

"github.com/hashicorp/terraform-provider-google/google/acctest"
"github.com/hashicorp/terraform-provider-google/google/envvar"
)

func TestAccGeminiReleaseChannelSettingBinding_update(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"release_channel_setting_id": fmt.Sprintf("tf-test-ls-%s", acctest.RandString(t, 10)),
"setting_binding_id": fmt.Sprintf("tf-test-lsb-%s", acctest.RandString(t, 10)),
"new_project_id": fmt.Sprintf("tf-test-prj-%s", acctest.RandString(t, 6)),
"org_id": envvar.GetTestOrgFromEnv(t),
"billing_account": envvar.GetTestBillingAccountFromEnv(t),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
Steps: []resource.TestStep{
{
Config: testAccGeminiReleaseChannelSettingBinding_basic(context),
},
{
ResourceName: "google_gemini_release_channel_setting_binding.basic_binding",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"labels", "location", "release_channel_setting_id", "terraform_labels"},
},
{
Config: testAccGeminiReleaseChannelSettingBinding_update(context),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectResourceAction("google_gemini_release_channel_setting_binding.basic_binding", plancheck.ResourceActionUpdate),
},
},
},
{
ResourceName: "google_gemini_release_channel_setting_binding.basic_binding",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"labels", "location", "release_channel_setting_id", "terraform_labels"},
},
},
})
}

func testAccGeminiReleaseChannelSettingBinding_basic(context map[string]interface{}) string {
return acctest.Nprintf(`
data "google_project" "project" {
provider = google-beta
}

resource "google_project" "new_project" {
PerlMonker303 marked this conversation as resolved.
Show resolved Hide resolved
provider = google-beta
project_id = "%{new_project_id}"
name = "Terraform Acc Test Project"
melinath marked this conversation as resolved.
Show resolved Hide resolved
org_id = "%{org_id}"
billing_account = "%{billing_account}"
}

resource "google_gemini_release_channel_setting" "basic" {
provider = google-beta
release_channel_setting_id = "%{release_channel_setting_id}"
location = "global"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: there's some whitespace mismatch in this section

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed it, however locally it shows fine. Tried using tabs/spaces - same thing.

Copy link
Member

@melinath melinath Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tabs on github are 8 spaces, which is usually the cause of this kind of thing

Suggested change
location = "global"
location = "global"

labels = {"my_key" = "my_value"}
release_channel = "EXPERIMENTAL"
}

resource "google_gemini_release_channel_setting_binding" "basic_binding" {
provider = google-beta
release_channel_setting_id = google_gemini_release_channel_setting.basic.release_channel_setting_id
setting_binding_id = "%{setting_binding_id}"
location = "global"
target = "projects/${resource.google_project.new_project.number}"
}
`, context)
}

func testAccGeminiReleaseChannelSettingBinding_update(context map[string]interface{}) string {
return acctest.Nprintf(`
data "google_project" "project" {
provider = google-beta
}

resource "google_project" "new_project" {
PerlMonker303 marked this conversation as resolved.
Show resolved Hide resolved
provider = google-beta
project_id = "%{new_project_id}"
name = "Terraform Acc Test Project"
}

resource "google_gemini_release_channel_setting" "basic" {
provider = google-beta
release_channel_setting_id = "%{release_channel_setting_id}"
location = "global"
labels = {"my_key" = "my_value"}
release_channel = "EXPERIMENTAL"
}

resource "google_gemini_release_channel_setting_binding" "basic_binding" {
provider = google-beta
release_channel_setting_id = google_gemini_release_channel_setting.basic.release_channel_setting_id
setting_binding_id = "%{setting_binding_id}"
location = "global"
target = "projects/${resource.google_project.new_project.number}"
labels = {"my_key" = "my_value"}
product = "GEMINI_CODE_ASSIST"
}
`, context)
}
{{ end }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gemini_test
{{- if ne $.TargetVersionName "ga" }}

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
Expand All @@ -12,7 +13,7 @@ import (
func TestAccGeminiReleaseChannelSetting_geminiReleaseChannelSettingBasicExample_update(t *testing.T) {
t.Parallel()
context := map[string]interface{}{
"setting_id": "ls-tf1",
"setting_id": fmt.Sprintf("tf-test-ls-%s", acctest.RandString(t, 10)),
}
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
Expand Down Expand Up @@ -60,6 +61,7 @@ resource "google_gemini_release_channel_setting" "example" {
provider = google-beta
release_channel_setting_id = "%{setting_id}"
location = "global"
labels = {"my_key" = "my_value"}
release_channel = "STABLE"
}
`, context)
Expand Down
Loading