@@ -17,9 +17,10 @@ limitations under the License.
17
17
package v1beta1
18
18
19
19
import (
20
- "sigs.k8s.io/controller-runtime/pkg/conversion"
21
-
20
+ apiconversion "k8s.io/apimachinery/pkg/conversion"
22
21
"sigs.k8s.io/cluster-api-provider-aws/v2/bootstrap/eks/api/v1beta2"
22
+ utilconversion "sigs.k8s.io/cluster-api/util/conversion"
23
+ "sigs.k8s.io/controller-runtime/pkg/conversion"
23
24
)
24
25
25
26
// ConvertTo converts the v1beta1 EKSConfig receiver to a v1beta2 EKSConfig.
@@ -30,6 +31,37 @@ func (r *EKSConfig) ConvertTo(dstRaw conversion.Hub) error {
30
31
return err
31
32
}
32
33
34
+ // Manually restore data.
35
+ restored := & v1beta2.EKSConfig {}
36
+ if ok , err := utilconversion .UnmarshalData (r , restored ); err != nil || ! ok {
37
+ return err
38
+ }
39
+
40
+ if restored .Spec .PreBootstrapCommands != nil {
41
+ dst .Spec .PreBootstrapCommands = restored .Spec .PreBootstrapCommands
42
+ }
43
+ if restored .Spec .PostBootstrapCommands != nil {
44
+ dst .Spec .PostBootstrapCommands = restored .Spec .PostBootstrapCommands
45
+ }
46
+ if restored .Spec .BootstrapCommandOverride != nil {
47
+ dst .Spec .BootstrapCommandOverride = restored .Spec .BootstrapCommandOverride
48
+ }
49
+ if restored .Spec .Files != nil {
50
+ dst .Spec .Files = restored .Spec .Files
51
+ }
52
+ if restored .Spec .DiskSetup != nil {
53
+ dst .Spec .DiskSetup = restored .Spec .DiskSetup
54
+ }
55
+ if restored .Spec .Mounts != nil {
56
+ dst .Spec .Mounts = restored .Spec .Mounts
57
+ }
58
+ if restored .Spec .Users != nil {
59
+ dst .Spec .Users = restored .Spec .Users
60
+ }
61
+ if restored .Spec .NTP != nil {
62
+ dst .Spec .NTP = restored .Spec .NTP
63
+ }
64
+
33
65
return nil
34
66
}
35
67
@@ -41,7 +73,7 @@ func (r *EKSConfig) ConvertFrom(srcRaw conversion.Hub) error {
41
73
return err
42
74
}
43
75
44
- return nil
76
+ return utilconversion . MarshalData ( src , r )
45
77
}
46
78
47
79
// ConvertTo converts the v1beta1 EKSConfigList receiver to a v1beta2 EKSConfigList.
@@ -66,6 +98,37 @@ func (r *EKSConfigTemplate) ConvertTo(dstRaw conversion.Hub) error {
66
98
return err
67
99
}
68
100
101
+ // Manually restore data.
102
+ restored := & v1beta2.EKSConfigTemplate {}
103
+ if ok , err := utilconversion .UnmarshalData (r , restored ); err != nil || ! ok {
104
+ return err
105
+ }
106
+
107
+ if restored .Spec .Template .Spec .PreBootstrapCommands != nil {
108
+ dst .Spec .Template .Spec .PreBootstrapCommands = restored .Spec .Template .Spec .PreBootstrapCommands
109
+ }
110
+ if restored .Spec .Template .Spec .PostBootstrapCommands != nil {
111
+ dst .Spec .Template .Spec .PostBootstrapCommands = restored .Spec .Template .Spec .PostBootstrapCommands
112
+ }
113
+ if restored .Spec .Template .Spec .BootstrapCommandOverride != nil {
114
+ dst .Spec .Template .Spec .BootstrapCommandOverride = restored .Spec .Template .Spec .BootstrapCommandOverride
115
+ }
116
+ if restored .Spec .Template .Spec .Files != nil {
117
+ dst .Spec .Template .Spec .Files = restored .Spec .Template .Spec .Files
118
+ }
119
+ if restored .Spec .Template .Spec .DiskSetup != nil {
120
+ dst .Spec .Template .Spec .DiskSetup = restored .Spec .Template .Spec .DiskSetup
121
+ }
122
+ if restored .Spec .Template .Spec .Mounts != nil {
123
+ dst .Spec .Template .Spec .Mounts = restored .Spec .Template .Spec .Mounts
124
+ }
125
+ if restored .Spec .Template .Spec .Users != nil {
126
+ dst .Spec .Template .Spec .Users = restored .Spec .Template .Spec .Users
127
+ }
128
+ if restored .Spec .Template .Spec .NTP != nil {
129
+ dst .Spec .Template .Spec .NTP = restored .Spec .Template .Spec .NTP
130
+ }
131
+
69
132
return nil
70
133
}
71
134
@@ -77,7 +140,7 @@ func (r *EKSConfigTemplate) ConvertFrom(srcRaw conversion.Hub) error {
77
140
return err
78
141
}
79
142
80
- return nil
143
+ return utilconversion . MarshalData ( src , r )
81
144
}
82
145
83
146
// ConvertTo converts the v1beta1 EKSConfigTemplateList receiver to a v1beta2 EKSConfigTemplateList.
@@ -93,3 +156,8 @@ func (r *EKSConfigTemplateList) ConvertFrom(srcRaw conversion.Hub) error {
93
156
94
157
return Convert_v1beta2_EKSConfigTemplateList_To_v1beta1_EKSConfigTemplateList (src , r , nil )
95
158
}
159
+
160
+ // Convert_v1beta2_EKSConfigSpec_To_v1beta1_EKSConfigSpec converts a v1beta2 EKSConfigSpec receiver to a v1beta1 EKSConfigSpec.
161
+ func Convert_v1beta2_EKSConfigSpec_To_v1beta1_EKSConfigSpec (in * v1beta2.EKSConfigSpec , out * EKSConfigSpec , s apiconversion.Scope ) error {
162
+ return autoConvert_v1beta2_EKSConfigSpec_To_v1beta1_EKSConfigSpec (in , out , s )
163
+ }
0 commit comments