Skip to content

Commit 3699e8b

Browse files
committed
address PR review
1 parent 0f718b0 commit 3699e8b

File tree

8 files changed

+104
-105
lines changed

8 files changed

+104
-105
lines changed

mmv1/products/biglakeiceberg/IcebergNamespace.yaml

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import_format:
2525
- '{{catalog}}/{{namespace_id}}'
2626
immutable: false
2727
custom_code:
28-
custom_update: 'templates/terraform/custom_update/biglake_iceberg_namespace_update.go.tmpl'
28+
constants: 'templates/terraform/constants/biglake_iceberg_namespace.go.tmpl'
29+
update_encoder: 'templates/terraform/encoders/biglake_iceberg_namespace.go.tmpl'
2930
parameters:
3031
- name: 'catalog'
3132
type: String
@@ -51,12 +52,14 @@ properties:
5152
required: false
5253
default_from_api: true
5354
diff_suppress_func: 'icebergNamespacePropertiesDiffSuppress'
55+
update_verb: 'POST'
56+
update_url: 'iceberg/v1/restcatalog/v1/projects/{{project}}/catalogs/{{catalog}}/namespaces/{{namespace_id}}/properties'
5457
iam_policy:
5558
base_url: 'v1/projects/{{project}}/catalogs/{{catalog}}/namespaces/{{namespace_id}}'
5659
parent_resource_attribute: 'namespace_id'
5760
method_name_separator: ":"
5861
fetch_iam_policy_verb: 'GET'
59-
supports_user_project_override: true
62+
supports_indirect_user_project_override: true
6063
import_format:
6164
- 'projects/{{project}}/catalogs/{{catalog}}/namespaces/{{namespace_id}}'
6265
allowed_iam_role: 'roles/biglake.editor'
@@ -68,32 +71,35 @@ samples:
6871
steps:
6972
- name: 'basic'
7073
vars:
71-
name: 'my_iceberg_namespace'
72-
catalog: 'my_iceberg_catalog'
73-
random_suffix: ''
74+
bucket_suffix: '%{bucket_suffix}'
75+
test_vars_overrides:
76+
bucket_suffix: 'acctest.RandString(t, 10)'
7477
test_env_vars:
75-
GOOGLE_BILLING_PROJECT: 'PROJECT'
78+
GOOGLE_BILLING_PROJECT: 'PROJECT_NAME'
7679
USER_PROJECT_OVERRIDE: 'true'
77-
config_path: 'templates/terraform/examples/biglake_iceberg_namespace.tf.tmpl'
80+
config_path: 'templates/terraform/samples/biglake_iceberg_namespace.tf.tmpl'
7881
- name: 'biglake_iceberg_namespace_update'
7982
primary_resource_id: 'my_iceberg_namespace'
8083
steps:
8184
- name: 'initial'
8285
vars:
83-
name: 'my_iceberg_namespace'
84-
catalog: 'my_iceberg_catalog'
85-
prop_val: 'initial'
86-
random_suffix: ''
86+
prop_val: '%{prop_val}'
87+
bucket_suffix: '%{bucket_suffix}'
88+
test_vars_overrides:
89+
prop_val: '"initial"'
90+
bucket_suffix: 'acctest.RandString(t, 10)'
8791
test_env_vars:
88-
GOOGLE_BILLING_PROJECT: 'PROJECT'
92+
GOOGLE_BILLING_PROJECT: 'PROJECT_NAME'
8993
USER_PROJECT_OVERRIDE: 'true'
90-
config_path: 'templates/terraform/examples/biglake_iceberg_namespace_update.tf.tmpl'
94+
config_path: 'templates/terraform/samples/biglake_iceberg_namespace_update.tf.tmpl'
9195
- name: 'updated'
9296
vars:
93-
name: 'my_iceberg_namespace'
94-
catalog: 'my_iceberg_catalog'
95-
prop_val: 'updated'
96-
random_suffix: ''
97-
GOOGLE_BILLING_PROJECT: 'PROJECT'
97+
prop_val: '%{prop_val}'
98+
bucket_suffix: '%{bucket_suffix}'
99+
test_vars_overrides:
100+
prop_val: '"updated"'
101+
bucket_suffix: 'context["bucket_suffix"]'
102+
test_env_vars:
103+
GOOGLE_BILLING_PROJECT: 'PROJECT_NAME'
98104
USER_PROJECT_OVERRIDE: 'true'
99-
config_path: 'templates/terraform/examples/biglake_iceberg_namespace_update.tf.tmpl'
105+
config_path: 'templates/terraform/samples/biglake_iceberg_namespace_update.tf.tmpl'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var icebergNamespaceIgnoredProperties = map[string]bool{
2+
"location": true,
3+
}
4+
5+
func icebergNamespacePropertiesDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
6+
// properties.KEY
7+
parts := strings.Split(k, ".")
8+
if len(parts) == 2 && icebergNamespaceIgnoredProperties[parts[1]] {
9+
return true
10+
}
11+
return false
12+
}

mmv1/templates/terraform/custom_update/biglake_iceberg_namespace_update.go.tmpl

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
if d.HasChange("properties") {
2+
oldProp, newProp := d.GetChange("properties")
3+
oldMap := oldProp.(map[string]interface{})
4+
newMap := newProp.(map[string]interface{})
5+
6+
removals := []string{}
7+
for k := range oldMap {
8+
if icebergNamespaceIgnoredProperties[k] {
9+
continue
10+
}
11+
if _, ok := newMap[k]; !ok {
12+
removals = append(removals, k)
13+
}
14+
}
15+
16+
updates := map[string]string{}
17+
for k, v := range newMap {
18+
if icebergNamespaceIgnoredProperties[k] {
19+
continue
20+
}
21+
updates[k] = v.(string)
22+
}
23+
24+
return map[string]interface{}{
25+
"removals": removals,
26+
"updates": updates,
27+
}, nil
28+
}
29+
return nil, nil

mmv1/templates/terraform/iam_policy.go.tmpl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,6 @@ func (u *{{ $.ResourceName }}IamUpdater) GetResourceIamPolicy() (*cloudresourcem
252252
}
253253

254254
headers := make(http.Header)
255-
{{- if $.IamPolicy.SupportsUserProjectOverride }}
256-
headers.Set("x-goog-user-project", project)
257-
{{- end }}
258255

259256
policy, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
260257
Config: u.Config,
@@ -321,9 +318,6 @@ func (u *{{ $.ResourceName }}IamUpdater) SetResourceIamPolicy(policy *cloudresou
321318
}
322319

323320
headers := make(http.Header)
324-
{{- if $.IamPolicy.SupportsUserProjectOverride }}
325-
headers.Set("x-goog-user-project", project)
326-
{{- end }}
327321

328322
_, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
329323
Config: u.Config,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
resource "google_storage_bucket" "bucket" {
2+
name = "my-bucket-%{bucket_suffix}"
3+
location = "us-central1"
4+
force_destroy = true
5+
uniform_bucket_level_access = true
6+
}
7+
8+
resource "google_biglake_iceberg_catalog" "catalog" {
9+
name = google_storage_bucket.bucket.name
10+
catalog_type = "CATALOG_TYPE_GCS_BUCKET"
11+
}
12+
13+
resource "google_biglake_iceberg_namespace" "{{$.PrimaryResourceId}}" {
14+
catalog = google_biglake_iceberg_catalog.catalog.name
15+
namespace_id = "my-namespace-%{bucket_suffix}"
16+
properties = {
17+
key = "value"
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
resource "google_storage_bucket" "bucket" {
2+
name = "my-bucket-%{bucket_suffix}"
3+
location = "us-central1"
4+
force_destroy = true
5+
uniform_bucket_level_access = true
6+
}
7+
8+
resource "google_biglake_iceberg_catalog" "catalog" {
9+
name = google_storage_bucket.bucket.name
10+
catalog_type = "CATALOG_TYPE_GCS_BUCKET"
11+
}
12+
13+
resource "google_biglake_iceberg_namespace" "{{$.PrimaryResourceId}}" {
14+
catalog = google_biglake_iceberg_catalog.catalog.name
15+
namespace_id = "my-namespace-%{bucket_suffix}"
16+
properties = {
17+
key = "{{index $.Vars "prop_val"}}"
18+
}
19+
}

mmv1/third_party/terraform/services/biglakeiceberg/utils.go

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)