Skip to content

Commit

Permalink
fix lint and unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
TiberiuGC committed Mar 28, 2024
1 parent ebdf92e commit a0349dd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions pkg/apis/eksctl.io/v1alpha5/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2055,10 +2055,6 @@ var _ = Describe("ClusterConfig validation", func() {
err := api.ValidateManagedNodeGroup(0, mng)
Expect(err).NotTo(HaveOccurred())

mng.AMIFamily = api.NodeImageFamilyAmazonLinux2
err = api.ValidateManagedNodeGroup(0, mng)
Expect(err).NotTo(HaveOccurred())

mng.AMIFamily = api.NodeImageFamilyUbuntu1804
err = api.ValidateManagedNodeGroup(0, mng)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -2074,8 +2070,13 @@ var _ = Describe("ClusterConfig validation", func() {
mng.AMIFamily = api.NodeImageFamilyBottlerocket
mng.OverrideBootstrapCommand = nil
err = api.ValidateManagedNodeGroup(0, mng)
errorMsg := fmt.Sprintf("cannot set amiFamily to %s when using a custom AMI for managed nodes, only %s, %s, %s and %s are supported", mng.AMIFamily, api.NodeImageFamilyAmazonLinux2, api.NodeImageFamilyUbuntu1804, api.NodeImageFamilyUbuntu2004, api.NodeImageFamilyUbuntu2204)
errorMsg := fmt.Sprintf("cannot set amiFamily to %s when using a custom AMI for managed nodes, only %s, %s, %s, %s and %s are supported",
mng.AMIFamily, api.NodeImageFamilyAmazonLinux2023, api.NodeImageFamilyAmazonLinux2, api.NodeImageFamilyUbuntu1804, api.NodeImageFamilyUbuntu2004, api.NodeImageFamilyUbuntu2204)
Expect(err).To(MatchError(errorMsg))

mng.AMIFamily = api.NodeImageFamilyAmazonLinux2023
err = api.ValidateManagedNodeGroup(0, mng)
Expect(err).NotTo(HaveOccurred())
})

It("fails when the AMIFamily is WindowsServer2004CoreContainer", func() {
Expand Down
1 change: 1 addition & 0 deletions pkg/cfn/builder/managed_nodegroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ func TestManagedNodeRole(t *testing.T) {
t.Run(fmt.Sprintf("%d: %s", i, tt.description), func(t *testing.T) {
require := require.New(t)
clusterConfig := api.NewClusterConfig()
clusterConfig.Status = &api.ClusterStatus{}
api.SetManagedNodeGroupDefaults(tt.nodeGroup, clusterConfig.Metadata, false)
p := mockprovider.NewMockProvider()
fakeVPCImporter := new(vpcfakes.FakeImporter)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ctl/cmdutils/nodegroup_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func AddCommonCreateNodeGroupFlags(fs *pflag.FlagSet, cmd *Cmd, ng *api.NodeGrou
ng.SSH.EnableSSM = fs.Bool("enable-ssm", false, "Enable AWS Systems Manager (SSM)")

fs.StringVar(&ng.AMI, "node-ami", "", "'auto-ssm', 'auto' or an AMI ID (advanced use)")
fs.StringVar(&ng.AMIFamily, "node-ami-family", api.DefaultNodeImageFamily, fmt.Sprintf("supported AMI families: %s", strings.Join(api.SupportedNodeVolumeTypes(), ", ")))
fs.StringVar(&ng.AMIFamily, "node-ami-family", api.DefaultNodeImageFamily, fmt.Sprintf("supported AMI families: %s", strings.Join(api.SupportedAMIFamilies(), ", ")))

fs.BoolVarP(&ng.PrivateNetworking, "node-private-networking", "P", false, "whether to make nodegroup networking private")

Expand Down
8 changes: 4 additions & 4 deletions pkg/nodebootstrap/al2023.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ func (m *AL2023) UserData() (string, error) {

func (m *AL2023) setNodeConfig() {
m.nodeConfig = &NodeConfig{
ApiVersion: "node.eks.aws/v1alpha1",
APIVersion: "node.eks.aws/v1alpha1",
Kind: "NodeConfig",
Spec: NodeSpec{
Cluster: ClusterSpec{
Name: m.cfg.Metadata.Name,
ApiServerEndpoint: m.cfg.Status.Endpoint,
APIServerEndpoint: m.cfg.Status.Endpoint,
CertificateAuthority: base64.StdEncoding.EncodeToString(m.cfg.Status.CertificateAuthorityData),
CIDR: m.cfg.Status.KubernetesNetworkConfig.ServiceIPv4CIDR,
},
Expand All @@ -93,7 +93,7 @@ func (m *AL2023) setNodeConfig() {
}

type NodeConfig struct {
ApiVersion string `yaml:"apiVersion"`
APIVersion string `yaml:"apiVersion"`
Kind string `yaml:"kind"`
Spec NodeSpec `yaml:"spec"`
}
Expand All @@ -104,7 +104,7 @@ type NodeSpec struct {
}

type ClusterSpec struct {
ApiServerEndpoint string `yaml:"apiServerEndpoint"`
APIServerEndpoint string `yaml:"apiServerEndpoint"`
CertificateAuthority string `yaml:"certificateAuthority"`
CIDR string `yaml:"cidr"`
Name string `yaml:"name"`
Expand Down

0 comments on commit a0349dd

Please sign in to comment.