Skip to content

Commit 9049590

Browse files
committed
Update custom diff for partition_index in glue CatalogTable
Signed-off-by: Fatih Türken <turkenf@gmail.com>
1 parent f6b1a86 commit 9049590

8 files changed

Lines changed: 152 additions & 4 deletions

File tree

apis/cluster/glue/v1beta1/zz_catalogdatabase_terraformed.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/cluster/glue/v1beta2/zz_catalogdatabase_terraformed.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/namespaced/glue/v1beta1/zz_catalogdatabase_terraformed.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/cluster/glue/config.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ func Configure(p *config.Provider) { //nolint:gocyclo
1818
// This causes refresh to fail in the first reconcile.
1919
r.TerraformResource.Schema["catalog_id"].Computed = false
2020
r.TerraformResource.Schema["catalog_id"].Optional = false
21+
22+
r.LateInitializer = config.LateInitializer{
23+
IgnoredFields: []string{"create_table_default_permission"},
24+
}
2125
})
2226

2327
p.AddResourceConfigurator("aws_glue_catalog_table", func(r *config.Resource) {
@@ -27,7 +31,11 @@ func Configure(p *config.Provider) { //nolint:gocyclo
2731
r.TerraformResource.Schema["catalog_id"].Optional = false
2832

2933
r.TerraformCustomDiff = func(diff *terraform.InstanceDiff, _ *terraform.InstanceState, _ *terraform.ResourceConfig) (*terraform.InstanceDiff, error) {
30-
if diff != nil && diff.Attributes != nil {
34+
if diff == nil || diff.Empty() || diff.Destroy || diff.Attributes == nil {
35+
return diff, nil
36+
}
37+
piDiff, ok := diff.Attributes["partition_index.#"]
38+
if ok && piDiff.Old == "" && piDiff.New == "" && piDiff.NewComputed {
3139
delete(diff.Attributes, "partition_index.#")
3240
}
3341
return diff, nil

config/namespaced/glue/config.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ func Configure(p *config.Provider) { //nolint:gocyclo
1818
// This causes refresh to fail in the first reconcile.
1919
r.TerraformResource.Schema["catalog_id"].Computed = false
2020
r.TerraformResource.Schema["catalog_id"].Optional = false
21+
22+
r.LateInitializer = config.LateInitializer{
23+
IgnoredFields: []string{"create_table_default_permission"},
24+
}
2125
})
2226

2327
p.AddResourceConfigurator("aws_glue_catalog_table", func(r *config.Resource) {
@@ -27,7 +31,11 @@ func Configure(p *config.Provider) { //nolint:gocyclo
2731
r.TerraformResource.Schema["catalog_id"].Optional = false
2832

2933
r.TerraformCustomDiff = func(diff *terraform.InstanceDiff, _ *terraform.InstanceState, _ *terraform.ResourceConfig) (*terraform.InstanceDiff, error) {
30-
if diff != nil && diff.Attributes != nil {
34+
if diff == nil || diff.Empty() || diff.Destroy || diff.Attributes == nil {
35+
return diff, nil
36+
}
37+
piDiff, ok := diff.Attributes["partition_index.#"]
38+
if ok && piDiff.Old == "" && piDiff.New == "" && piDiff.NewComputed {
3139
delete(diff.Attributes, "partition_index.#")
3240
}
3341
return diff, nil
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# SPDX-FileCopyrightText: 2025 The Crossplane Authors <https://crossplane.io>
2+
#
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
apiVersion: glue.aws.upbound.io/v1beta1
6+
kind: CatalogTable
7+
metadata:
8+
annotations:
9+
meta.upbound.io/example-id: glue/v1beta1/catalogtable
10+
labels:
11+
testing.upbound.io/example-name: example
12+
name: example-ct-w-pi
13+
spec:
14+
forProvider:
15+
catalogId: "${data.aws_account_id}"
16+
databaseNameRef:
17+
name: example-ct-cd
18+
region: us-east-1
19+
storageDescriptor:
20+
- columns:
21+
- name: my_column_1
22+
type: string
23+
- name: my_column_2
24+
type: string
25+
- name: my_column_3
26+
type: string
27+
tableType: EXTERNAL
28+
partitionIndex:
29+
- indexName: partition_index_1
30+
keys:
31+
- year
32+
- month
33+
- day
34+
partitionKeys:
35+
- name: year
36+
type: int
37+
- name: month
38+
type: int
39+
- name: day
40+
type: int
41+
- name: hour
42+
type: int
43+
---
44+
apiVersion: glue.aws.upbound.io/v1beta1
45+
kind: CatalogDatabase
46+
metadata:
47+
annotations:
48+
meta.upbound.io/example-id: glue/v1beta1/catalogtable
49+
labels:
50+
testing.upbound.io/example-name: example
51+
name: example-ct-cd
52+
spec:
53+
forProvider:
54+
catalogId: "${data.aws_account_id}"
55+
region: us-east-1

examples/glue/cluster/v1beta1/catalogtable.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
apiVersion: glue.aws.upbound.io/v1beta1
66
kind: CatalogTable
77
metadata:
8-
name: example
8+
annotations:
9+
meta.upbound.io/example-id: glue/v1beta1/catalogtable
10+
labels:
11+
testing.upbound.io/example-name: example
12+
name: example-ct
913
spec:
1014
forProvider:
1115
region: us-east-1
1216
databaseNameRef:
13-
name: example
17+
name: example-ctd
1418
catalogId: "${data.aws_account_id}"
1519
tableType: EXTERNAL
1620
storageDescriptor:
@@ -21,3 +25,16 @@ spec:
2125
type: string
2226
- name: my_column_3
2327
type: string
28+
---
29+
apiVersion: glue.aws.upbound.io/v1beta1
30+
kind: CatalogDatabase
31+
metadata:
32+
annotations:
33+
meta.upbound.io/example-id: glue/v1beta1/catalogtable
34+
labels:
35+
testing.upbound.io/example-name: example
36+
name: example-ctd
37+
spec:
38+
forProvider:
39+
catalogId: "${data.aws_account_id}"
40+
region: us-east-1
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# SPDX-FileCopyrightText: 2025 The Crossplane Authors <https://crossplane.io>
2+
#
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
apiVersion: glue.aws.m.upbound.io/v1beta1
6+
kind: CatalogTable
7+
metadata:
8+
annotations:
9+
meta.upbound.io/example-id: glue/v1beta1/catalogtable
10+
labels:
11+
testing.upbound.io/example-name: example
12+
name: example-ct-w-pi
13+
namespace: upbound-system
14+
spec:
15+
forProvider:
16+
catalogId: "${data.aws_account_id}"
17+
databaseNameRef:
18+
name: example-ct-cd
19+
region: us-east-1
20+
storageDescriptor:
21+
- columns:
22+
- name: my_column_1
23+
type: string
24+
- name: my_column_2
25+
type: string
26+
- name: my_column_3
27+
type: string
28+
tableType: EXTERNAL
29+
partitionIndex:
30+
- indexName: partition_index_1
31+
keys:
32+
- year
33+
- month
34+
- day
35+
partitionKeys:
36+
- name: year
37+
type: int
38+
- name: month
39+
type: int
40+
- name: day
41+
type: int
42+
- name: hour
43+
type: int
44+
---
45+
apiVersion: glue.aws.m.upbound.io/v1beta1
46+
kind: CatalogDatabase
47+
metadata:
48+
annotations:
49+
meta.upbound.io/example-id: glue/v1beta1/catalogtable
50+
labels:
51+
testing.upbound.io/example-name: example
52+
name: example-ct-cd
53+
namespace: upbound-system
54+
spec:
55+
forProvider:
56+
catalogId: "${data.aws_account_id}"
57+
region: us-east-1

0 commit comments

Comments
 (0)