Skip to content

Commit bd5cbe9

Browse files
committed
lint fix
updated access entry descriptions taken from latest AWS CDK
1 parent 743d4d1 commit bd5cbe9

File tree

6 files changed

+35
-34
lines changed

6 files changed

+35
-34
lines changed

controlplane/eks/api/v1beta2/awsmanagedcontrolplane_webhook_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,4 +1206,3 @@ func TestWebhookValidateAccessEntries(t *testing.T) {
12061206
})
12071207
}
12081208
}
1209-

controlplane/eks/api/v1beta2/types.go

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,38 +100,46 @@ var (
100100
EKSAuthenticationModeAPIAndConfigMap = EKSAuthenticationMode("api_and_config_map")
101101
)
102102

103-
// AccessEntryType defines the type of an access entry
103+
// AccessEntryType represents the different types of access entries that can be used in an Amazon EKS cluster
104104
type AccessEntryType string
105105

106+
// APIValue returns the corresponding EKS API value for the access entry type
106107
func (a AccessEntryType) APIValue() *string {
107108
v := strings.ToUpper(string(a))
108109
return &v
109110
}
110111

111112
var (
112-
AccessEntryTypeStandard = AccessEntryType("standard")
113-
AccessEntryTypeEC2Linux = AccessEntryType("ec2_linux")
114-
AccessEntryTypeEC2Windows = AccessEntryType("ec2_windows")
115-
AccessEntryTypeFargateLinux = AccessEntryType("fargate_linux")
116-
AccessEntryTypeEC2 = AccessEntryType("ec2")
117-
AccessEntryTypeHybridLinux = AccessEntryType("hybrid_linux")
113+
// AccessEntryTypeStandard represents a standard access entry
114+
AccessEntryTypeStandard = AccessEntryType("standard")
115+
// AccessEntryTypeEC2Linux represents an EC2 Linux access entry
116+
AccessEntryTypeEC2Linux = AccessEntryType("ec2_linux")
117+
// AccessEntryTypeEC2Windows represents an EC2 Windows access entry
118+
AccessEntryTypeEC2Windows = AccessEntryType("ec2_windows")
119+
// AccessEntryTypeFargateLinux represents a Fargate Linux access entry
120+
AccessEntryTypeFargateLinux = AccessEntryType("fargate_linux")
121+
// AccessEntryTypeEC2 represents a generic EC2 access entry
122+
AccessEntryTypeEC2 = AccessEntryType("ec2")
123+
// AccessEntryTypeHybridLinux represents a hybrid node access entry
124+
AccessEntryTypeHybridLinux = AccessEntryType("hybrid_linux")
125+
// AccessEntryTypeHyperpodLinux represents a SageMaker HyperPod access entry
118126
AccessEntryTypeHyperpodLinux = AccessEntryType("hyperpod_linux")
119127
)
120128

121129
// AccessScopeType defines the scope type for an access policy
122130
type AccessScopeType string
123131

124132
var (
133+
// AccessScopeTypeCluster indicates that the access policy applies to the entire cluster
125134
AccessScopeTypeCluster = AccessScopeType("cluster")
135+
// AccessScopeTypeNamespace indicates that the access policy applies to a specific namespace within the cluster
126136
AccessScopeTypeNamespace = AccessScopeType("namespace")
127137
)
128138

129-
var (
130-
// DefaultEKSControlPlaneRole is the name of the default IAM role to use for the EKS control plane
131-
// if no other role is supplied in the spec and if iam role creation is not enabled. The default
132-
// can be created using clusterawsadm or created manually.
133-
DefaultEKSControlPlaneRole = fmt.Sprintf("eks-controlplane%s", iamv1.DefaultNameSuffix)
134-
)
139+
// DefaultEKSControlPlaneRole is the name of the default IAM role to use for the EKS control plane
140+
// if no other role is supplied in the spec and if iam role creation is not enabled. The default
141+
// can be created using clusterawsadm or created manually.
142+
var DefaultEKSControlPlaneRole = fmt.Sprintf("eks-controlplane%s", iamv1.DefaultNameSuffix)
135143

136144
// IAMAuthenticatorConfig represents an aws-iam-authenticator configuration.
137145
type IAMAuthenticatorConfig struct {

pkg/cloud/services/eks/accessentry.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,3 @@ func (s *Service) getExistingAccessPolicies(ctx context.Context, principalARN st
277277

278278
return existingPolicies, nil
279279
}
280-

pkg/cloud/services/eks/accessentry_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,4 +796,3 @@ func TestDeleteAccessEntry(t *testing.T) {
796796
})
797797
}
798798
}
799-

test/e2e/suites/managed/eks_access_entries_test.go

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ import (
2323
"context"
2424
"fmt"
2525

26-
ekstypes "github.com/aws/aws-sdk-go-v2/service/eks/types"
2726
"github.com/onsi/ginkgo/v2"
2827
. "github.com/onsi/gomega"
2928
corev1 "k8s.io/api/core/v1"
30-
"sigs.k8s.io/controller-runtime/pkg/client"
3129

3230
ekscontrolplanev1 "sigs.k8s.io/cluster-api-provider-aws/v2/controlplane/eks/api/v1beta2"
3331
"sigs.k8s.io/cluster-api-provider-aws/v2/test/e2e/shared"
@@ -75,17 +73,17 @@ var _ = ginkgo.Describe("[managed] [auth] EKS authentication mode tests", func()
7573

7674
ginkgo.By("should create a cluster with access entries")
7775
ManagedClusterSpec(ctx, func() ManagedClusterSpecInput {
78-
return ManagedClusterSpecInput{
79-
E2EConfig: e2eCtx.E2EConfig,
80-
ConfigClusterFn: defaultConfigCluster,
81-
BootstrapClusterProxy: e2eCtx.Environment.BootstrapClusterProxy,
82-
AWSSession: e2eCtx.BootstrapUserAWSSession,
83-
Namespace: namespace,
84-
ClusterName: clusterName,
85-
Flavour: EKSControlPlaneOnlyWithAccessEntriesFlavor,
86-
ControlPlaneMachineCount: 1, // NOTE: this cannot be zero as clusterctl returns an error
87-
WorkerMachineCount: 0,
88-
}
76+
return ManagedClusterSpecInput{
77+
E2EConfig: e2eCtx.E2EConfig,
78+
ConfigClusterFn: defaultConfigCluster,
79+
BootstrapClusterProxy: e2eCtx.Environment.BootstrapClusterProxy,
80+
AWSSession: e2eCtx.BootstrapUserAWSSession,
81+
Namespace: namespace,
82+
ClusterName: clusterName,
83+
Flavour: EKSControlPlaneOnlyWithAccessEntriesFlavor,
84+
ControlPlaneMachineCount: 1, // NOTE: this cannot be zero as clusterctl returns an error
85+
WorkerMachineCount: 0,
86+
}
8987
})
9088

9189
ginkgo.By("should have created the expected access entries")
@@ -122,7 +120,6 @@ var _ = ginkgo.Describe("[managed] [auth] EKS authentication mode tests", func()
122120
}
123121
verifyAccessEntries(ctx, eksClusterName, expectedEntries, e2eCtx.BootstrapUserAWSSession)
124122

125-
126123
ginkgo.By("EKS cluster should be active")
127124
verifyClusterActiveAndOwned(ctx, eksClusterName, e2eCtx.BootstrapUserAWSSession)
128125

test/e2e/suites/managed/helpers.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ func getEKSCluster(ctx context.Context, eksClusterName string, sess *aws.Config)
108108
Name: aws.String(eksClusterName),
109109
}
110110
result, err := eksClient.DescribeCluster(ctx, input)
111-
112111
if err != nil {
113112
return nil, err
114113
}
@@ -281,8 +280,8 @@ func verifyAccessEntries(ctx context.Context, eksClusterName string, expectedEnt
281280
})
282281
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to describe access entry: %s", principalARN))
283282

284-
Expect(describeOutput.AccessEntry.Type).To(Equal(expectedEntry.Type), "access entry type does not match")
285-
Expect(describeOutput.AccessEntry.Username).To(Equal(expectedEntry.Username), "access entry username does not match")
283+
Expect(describeOutput.AccessEntry.Type).To(HaveValue(BeEquivalentTo(expectedEntry.Type)), "access entry type does not match")
284+
Expect(describeOutput.AccessEntry.Username).To(HaveValue(BeEquivalentTo(expectedEntry.Username)), "access entry username does not match")
286285

287286
if len(expectedEntry.KubernetesGroups) > 0 {
288287
slices.Sort(expectedEntry.KubernetesGroups)
@@ -306,7 +305,7 @@ func verifyAccessEntries(ctx context.Context, eksClusterName string, expectedEnt
306305
expectedPolicy, exists := expectedPolicies[*policy.PolicyArn]
307306
Expect(exists).To(BeTrue(), fmt.Sprintf("unexpected access policy: %s", *policy.PolicyArn))
308307

309-
Expect(policy.AccessScope.Type).To(Equal(expectedPolicy.AccessScope.Type), "access policy scope type does not match")
308+
Expect(policy.AccessScope.Type).To(BeEquivalentTo(expectedPolicy.AccessScope.Type), "access policy scope type does not match")
310309

311310
if expectedPolicy.AccessScope.Type == "namespace" {
312311
slices.Sort(expectedPolicy.AccessScope.Namespaces)

0 commit comments

Comments
 (0)