/
delta.go
114 lines (106 loc) · 4.49 KB
/
delta.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license" file accompanying this file. This file 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.
// Code generated by ack-generate. DO NOT EDIT.
package load_balancer
import (
"bytes"
"reflect"
ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare"
acktags "github.com/aws-controllers-k8s/runtime/pkg/tags"
)
// Hack to avoid import errors during build...
var (
_ = &bytes.Buffer{}
_ = &reflect.Method{}
_ = &acktags.Tags{}
)
// newResourceDelta returns a new `ackcompare.Delta` used to compare two
// resources
func newResourceDelta(
a *resource,
b *resource,
) *ackcompare.Delta {
delta := ackcompare.NewDelta()
if (a == nil && b != nil) ||
(a != nil && b == nil) {
delta.Add("", a, b)
return delta
}
customPreCompare(delta, a, b)
if ackcompare.HasNilDifference(a.ko.Spec.CustomerOwnedIPv4Pool, b.ko.Spec.CustomerOwnedIPv4Pool) {
delta.Add("Spec.CustomerOwnedIPv4Pool", a.ko.Spec.CustomerOwnedIPv4Pool, b.ko.Spec.CustomerOwnedIPv4Pool)
} else if a.ko.Spec.CustomerOwnedIPv4Pool != nil && b.ko.Spec.CustomerOwnedIPv4Pool != nil {
if *a.ko.Spec.CustomerOwnedIPv4Pool != *b.ko.Spec.CustomerOwnedIPv4Pool {
delta.Add("Spec.CustomerOwnedIPv4Pool", a.ko.Spec.CustomerOwnedIPv4Pool, b.ko.Spec.CustomerOwnedIPv4Pool)
}
}
if ackcompare.HasNilDifference(a.ko.Spec.IPAddressType, b.ko.Spec.IPAddressType) {
delta.Add("Spec.IPAddressType", a.ko.Spec.IPAddressType, b.ko.Spec.IPAddressType)
} else if a.ko.Spec.IPAddressType != nil && b.ko.Spec.IPAddressType != nil {
if *a.ko.Spec.IPAddressType != *b.ko.Spec.IPAddressType {
delta.Add("Spec.IPAddressType", a.ko.Spec.IPAddressType, b.ko.Spec.IPAddressType)
}
}
if ackcompare.HasNilDifference(a.ko.Spec.Name, b.ko.Spec.Name) {
delta.Add("Spec.Name", a.ko.Spec.Name, b.ko.Spec.Name)
} else if a.ko.Spec.Name != nil && b.ko.Spec.Name != nil {
if *a.ko.Spec.Name != *b.ko.Spec.Name {
delta.Add("Spec.Name", a.ko.Spec.Name, b.ko.Spec.Name)
}
}
if ackcompare.HasNilDifference(a.ko.Spec.Scheme, b.ko.Spec.Scheme) {
delta.Add("Spec.Scheme", a.ko.Spec.Scheme, b.ko.Spec.Scheme)
} else if a.ko.Spec.Scheme != nil && b.ko.Spec.Scheme != nil {
if *a.ko.Spec.Scheme != *b.ko.Spec.Scheme {
delta.Add("Spec.Scheme", a.ko.Spec.Scheme, b.ko.Spec.Scheme)
}
}
if !reflect.DeepEqual(a.ko.Spec.SecurityGroupRefs, b.ko.Spec.SecurityGroupRefs) {
delta.Add("Spec.SecurityGroupRefs", a.ko.Spec.SecurityGroupRefs, b.ko.Spec.SecurityGroupRefs)
}
if len(a.ko.Spec.SecurityGroups) != len(b.ko.Spec.SecurityGroups) {
delta.Add("Spec.SecurityGroups", a.ko.Spec.SecurityGroups, b.ko.Spec.SecurityGroups)
} else if len(a.ko.Spec.SecurityGroups) > 0 {
if !ackcompare.SliceStringPEqual(a.ko.Spec.SecurityGroups, b.ko.Spec.SecurityGroups) {
delta.Add("Spec.SecurityGroups", a.ko.Spec.SecurityGroups, b.ko.Spec.SecurityGroups)
}
}
if len(a.ko.Spec.SubnetMappings) != len(b.ko.Spec.SubnetMappings) {
delta.Add("Spec.SubnetMappings", a.ko.Spec.SubnetMappings, b.ko.Spec.SubnetMappings)
} else if len(a.ko.Spec.SubnetMappings) > 0 {
if !reflect.DeepEqual(a.ko.Spec.SubnetMappings, b.ko.Spec.SubnetMappings) {
delta.Add("Spec.SubnetMappings", a.ko.Spec.SubnetMappings, b.ko.Spec.SubnetMappings)
}
}
if !reflect.DeepEqual(a.ko.Spec.SubnetRefs, b.ko.Spec.SubnetRefs) {
delta.Add("Spec.SubnetRefs", a.ko.Spec.SubnetRefs, b.ko.Spec.SubnetRefs)
}
if len(a.ko.Spec.Subnets) != len(b.ko.Spec.Subnets) {
delta.Add("Spec.Subnets", a.ko.Spec.Subnets, b.ko.Spec.Subnets)
} else if len(a.ko.Spec.Subnets) > 0 {
if !ackcompare.SliceStringPEqual(a.ko.Spec.Subnets, b.ko.Spec.Subnets) {
delta.Add("Spec.Subnets", a.ko.Spec.Subnets, b.ko.Spec.Subnets)
}
}
if !ackcompare.MapStringStringEqual(ToACKTags(a.ko.Spec.Tags), ToACKTags(b.ko.Spec.Tags)) {
delta.Add("Spec.Tags", a.ko.Spec.Tags, b.ko.Spec.Tags)
}
if ackcompare.HasNilDifference(a.ko.Spec.Type, b.ko.Spec.Type) {
delta.Add("Spec.Type", a.ko.Spec.Type, b.ko.Spec.Type)
} else if a.ko.Spec.Type != nil && b.ko.Spec.Type != nil {
if *a.ko.Spec.Type != *b.ko.Spec.Type {
delta.Add("Spec.Type", a.ko.Spec.Type, b.ko.Spec.Type)
}
}
return delta
}