Skip to content

Commit ad1231a

Browse files
authored
Merge pull request #3757 from cnmcavoy/cnmcavoy/cloud-init
Enhance the EKSConfigTemplate and add configuration for files, mounts, users, ntp, etc for CAPI feature parity
2 parents 7440d3e + 9b8b5af commit ad1231a

18 files changed

+1777
-52
lines changed

bootstrap/eks/api/v1beta1/conversion.go

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20-
"sigs.k8s.io/controller-runtime/pkg/conversion"
21-
20+
apiconversion "k8s.io/apimachinery/pkg/conversion"
2221
"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"
2324
)
2425

2526
// ConvertTo converts the v1beta1 EKSConfig receiver to a v1beta2 EKSConfig.
@@ -30,6 +31,37 @@ func (r *EKSConfig) ConvertTo(dstRaw conversion.Hub) error {
3031
return err
3132
}
3233

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+
3365
return nil
3466
}
3567

@@ -41,7 +73,7 @@ func (r *EKSConfig) ConvertFrom(srcRaw conversion.Hub) error {
4173
return err
4274
}
4375

44-
return nil
76+
return utilconversion.MarshalData(src, r)
4577
}
4678

4779
// ConvertTo converts the v1beta1 EKSConfigList receiver to a v1beta2 EKSConfigList.
@@ -66,6 +98,37 @@ func (r *EKSConfigTemplate) ConvertTo(dstRaw conversion.Hub) error {
6698
return err
6799
}
68100

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+
69132
return nil
70133
}
71134

@@ -77,7 +140,7 @@ func (r *EKSConfigTemplate) ConvertFrom(srcRaw conversion.Hub) error {
77140
return err
78141
}
79142

80-
return nil
143+
return utilconversion.MarshalData(src, r)
81144
}
82145

83146
// ConvertTo converts the v1beta1 EKSConfigTemplateList receiver to a v1beta2 EKSConfigTemplateList.
@@ -93,3 +156,8 @@ func (r *EKSConfigTemplateList) ConvertFrom(srcRaw conversion.Hub) error {
93156

94157
return Convert_v1beta2_EKSConfigTemplateList_To_v1beta1_EKSConfigTemplateList(src, r, nil)
95158
}
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+
}

bootstrap/eks/api/v1beta1/zz_generated.conversion.go

Lines changed: 57 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)