Skip to content

Commit 761171b

Browse files
Merge pull request #1877 from erhancagirici/ignore-diff-route53-cname-trailing-dots
fix: ignore diff for trailing dots in Record.route53 names
2 parents 3d80d7d + ac49a4c commit 761171b

6 files changed

Lines changed: 109 additions & 1 deletion

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export SUBPACKAGES := $(SUBPACKAGES)
8282
KIND_VERSION = v0.29.0
8383
UP_VERSION = v0.40.0-0.rc.3
8484
UP_CHANNEL = alpha
85-
UPTEST_VERSION = v2.0.1
85+
UPTEST_VERSION = v2.1.0
8686
KUSTOMIZE_VERSION = v5.3.0
8787
YQ_VERSION = v4.40.5
8888
CROSSPLANE_VERSION = 1.20.0

config/cluster/route53/config.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
package route53
66

77
import (
8+
"strings"
9+
810
"github.com/crossplane/upjet/v2/pkg/config"
11+
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
912
)
1013

1114
// Configure adds configurations for the route53 group.
@@ -32,6 +35,19 @@ func Configure(p *config.Provider) { //nolint:gocyclo
3235
}
3336
delete(r.References, "alias.name")
3437
delete(r.References, "alias.zone_id")
38+
r.TerraformCustomDiff = func(diff *terraform.InstanceDiff, state *terraform.InstanceState, config *terraform.ResourceConfig) (*terraform.InstanceDiff, error) {
39+
if diff == nil || diff.Empty() || diff.Destroy || diff.Attributes == nil {
40+
return diff, nil
41+
}
42+
nameDiff, ok := diff.Attributes["name"]
43+
if !ok {
44+
return diff, nil
45+
}
46+
if strings.TrimSuffix(nameDiff.New, ".") == strings.TrimSuffix(nameDiff.Old, ".") {
47+
delete(diff.Attributes, "name")
48+
}
49+
return diff, nil
50+
}
3551
})
3652
p.AddResourceConfigurator("aws_route53_vpc_association_authorization", func(r *config.Resource) {
3753
r.References["zone_id"] = config.Reference{

config/namespaced/route53/config.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
package route53
66

77
import (
8+
"strings"
9+
810
"github.com/crossplane/upjet/v2/pkg/config"
11+
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
912
)
1013

1114
// Configure adds configurations for the route53 group.
@@ -32,6 +35,19 @@ func Configure(p *config.Provider) { //nolint:gocyclo
3235
}
3336
delete(r.References, "alias.name")
3437
delete(r.References, "alias.zone_id")
38+
r.TerraformCustomDiff = func(diff *terraform.InstanceDiff, state *terraform.InstanceState, config *terraform.ResourceConfig) (*terraform.InstanceDiff, error) {
39+
if diff == nil || diff.Empty() || diff.Destroy || diff.Attributes == nil {
40+
return diff, nil
41+
}
42+
nameDiff, ok := diff.Attributes["name"]
43+
if !ok {
44+
return diff, nil
45+
}
46+
if strings.TrimSuffix(nameDiff.New, ".") == strings.TrimSuffix(nameDiff.Old, ".") {
47+
delete(diff.Attributes, "name")
48+
}
49+
return diff, nil
50+
}
3551
})
3652
p.AddResourceConfigurator("aws_route53_vpc_association_authorization", func(r *config.Resource) {
3753
r.References["zone_id"] = config.Reference{
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# SPDX-FileCopyrightText: 2024 The Crossplane Authors <https://crossplane.io>
2+
#
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
apiVersion: route53.aws.upbound.io/v1beta1
6+
kind: Record
7+
metadata:
8+
annotations:
9+
meta.upbound.io/example-id: route53/v1beta1/record
10+
labels:
11+
testing.upbound.io/example-name: example
12+
name: example-with-dot
13+
spec:
14+
forProvider:
15+
name: www.mycompany.test.
16+
records:
17+
- "dev.upbound.io"
18+
ttl: 5
19+
type: CNAME
20+
zoneIdSelector:
21+
matchLabels:
22+
testing.upbound.io/example-name: example
23+
---
24+
apiVersion: route53.aws.upbound.io/v1beta1
25+
kind: Zone
26+
metadata:
27+
annotations:
28+
meta.upbound.io/example-id: route53/v1beta1/record
29+
labels:
30+
testing.upbound.io/example-name: example
31+
name: example-with-dot
32+
spec:
33+
forProvider:
34+
name: mycompany.test

examples/route53/cluster/v1beta1/record.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
apiVersion: route53.aws.upbound.io/v1beta1
66
kind: Record
77
metadata:
8+
annotations:
9+
meta.upbound.io/example-id: route53/v1beta1/record
10+
labels:
11+
testing.upbound.io/example-name: example
812
name: example
913
spec:
1014
forProvider:
@@ -19,6 +23,8 @@ spec:
1923
apiVersion: route53.aws.upbound.io/v1beta1
2024
kind: Zone
2125
metadata:
26+
annotations:
27+
meta.upbound.io/example-id: route53/v1beta1/record
2228
labels:
2329
testing.upbound.io/example-name: example
2430
name: example
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# SPDX-FileCopyrightText: 2024 The Crossplane Authors <https://crossplane.io>
2+
#
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
apiVersion: route53.aws.m.upbound.io/v1beta1
6+
kind: Record
7+
metadata:
8+
annotations:
9+
meta.upbound.io/example-id: route53/v1beta1/record
10+
labels:
11+
testing.upbound.io/example-name: example
12+
name: example-with-dot
13+
namespace: upbound-system
14+
spec:
15+
forProvider:
16+
name: www.mycompany.test.
17+
records:
18+
- "dev.upbound.io"
19+
ttl: 5
20+
type: CNAME
21+
zoneIdSelector:
22+
matchLabels:
23+
testing.upbound.io/example-name: example
24+
---
25+
apiVersion: route53.aws.m.upbound.io/v1beta1
26+
kind: Zone
27+
metadata:
28+
annotations:
29+
meta.upbound.io/example-id: route53/v1beta1/record
30+
labels:
31+
testing.upbound.io/example-name: example
32+
name: example-with-dot
33+
namespace: upbound-system
34+
spec:
35+
forProvider:
36+
name: mycompany.test

0 commit comments

Comments
 (0)