Skip to content

Commit 9ecc240

Browse files
committed
fix merge issues
Signed-off-by: Pankaj Walke <[email protected]>
1 parent 8e113d9 commit 9ecc240

File tree

6 files changed

+26
-29
lines changed

6 files changed

+26
-29
lines changed

cmd/clusterawsadm/cmd/eks/addons/list_installed.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/aws/aws-sdk-go-v2/service/eks"
2626
"github.com/aws/aws-sdk-go/aws"
2727
"github.com/spf13/cobra"
28+
"k8s.io/utils/ptr"
2829

2930
cmdout "sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/printers"
3031
)
@@ -52,13 +53,10 @@ func listInstalledCmd() *cobra.Command {
5253
}
5354

5455
func listInstalledAddons(region, clusterName, printerType *string) error {
55-
var regionOptsFunc config.LoadOptionsFunc
5656
ctx := context.TODO()
57-
if *region != "" {
58-
regionOptsFunc = config.WithRegion(*region)
59-
}
57+
6058
optFns := []func(*config.LoadOptions) error{
61-
regionOptsFunc,
59+
config.WithRegion(ptr.Deref(region, "")),
6260
}
6361

6462
cfg, err := config.LoadDefaultConfig(context.Background(), optFns...)

test/e2e/shared/aws.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ func NewAWSSessionWithKeyV2(accessKey *iamtypes.AccessKey) *awsv2.Config {
483483
}
484484

485485
// createCloudFormationStack ensures the cloudformation stack is up to date.
486-
func createCloudFormationStack(ctx context.Context, cfg awsv2.Config, prov client.ConfigProvider, t *cfn_bootstrap.Template, tags map[string]string) error {
486+
func createCloudFormationStack(ctx context.Context, cfg *awsv2.Config, prov client.ConfigProvider, t *cfn_bootstrap.Template, tags map[string]string) error {
487487
By(fmt.Sprintf("Creating AWS CloudFormation stack for AWS IAM resources: stack-name=%s", t.Spec.StackName))
488488
cfnClient := cfn.New(prov)
489489
// CloudFormation stack will clean up on a failure, we don't need an Eventually here.
@@ -545,8 +545,8 @@ func SetMultitenancyEnvVars(prov client.ConfigProvider) error {
545545
}
546546

547547
// Delete resources that already exists.
548-
func deleteResourcesInCloudFormation(ctx context.Context, cfg awsv2.Config, t *cfn_bootstrap.Template) {
549-
iamSvc := iam.NewFromConfig(cfg)
548+
func deleteResourcesInCloudFormation(ctx context.Context, cfg *awsv2.Config, t *cfn_bootstrap.Template) {
549+
iamSvc := iam.NewFromConfig(*cfg)
550550
temp := *renderCustomCloudFormation(t)
551551
var (
552552
iamUsers []*cfn_iam.User
@@ -660,7 +660,7 @@ func deleteResourcesInCloudFormation(ctx context.Context, cfg awsv2.Config, t *c
660660
}
661661

662662
// TODO: remove once test infra accounts are fixed.
663-
func deleteMultitenancyRoles(ctx context.Context, cfg awsv2.Config) {
663+
func deleteMultitenancyRoles(ctx context.Context, cfg *awsv2.Config) {
664664
if err := DeleteRole(ctx, cfg, "multi-tenancy-role"); err != nil {
665665
By(fmt.Sprintf("failed to delete role multi-tenancy-role %s", err))
666666
}
@@ -670,8 +670,8 @@ func deleteMultitenancyRoles(ctx context.Context, cfg awsv2.Config) {
670670
}
671671

672672
// detachAllPoliciesForRole detaches all policies for role.
673-
func detachAllPoliciesForRole(ctx context.Context, cfg awsv2.Config, name string) error {
674-
iamSvc := iam.NewFromConfig(cfg)
673+
func detachAllPoliciesForRole(ctx context.Context, cfg *awsv2.Config, name string) error {
674+
iamSvc := iam.NewFromConfig(*cfg)
675675

676676
input := &iam.ListAttachedRolePoliciesInput{
677677
RoleName: aws.String(name),
@@ -697,8 +697,8 @@ func detachAllPoliciesForRole(ctx context.Context, cfg awsv2.Config, name string
697697
}
698698

699699
// DeleteUser deletes an IAM user in a best effort manner.
700-
func DeleteUser(ctx context.Context, cfg awsv2.Config, name string) error {
701-
iamSvc := iam.NewFromConfig(cfg)
700+
func DeleteUser(ctx context.Context, cfg *awsv2.Config, name string) error {
701+
iamSvc := iam.NewFromConfig(*cfg)
702702

703703
// if user does not exist, return.
704704
_, err := iamSvc.GetUser(ctx, &iam.GetUserInput{UserName: aws.String(name)})
@@ -715,8 +715,8 @@ func DeleteUser(ctx context.Context, cfg awsv2.Config, name string) error {
715715
}
716716

717717
// DeleteRole deletes roles in a best effort manner.
718-
func DeleteRole(ctx context.Context, cfg awsv2.Config, name string) error {
719-
iamSvc := iam.NewFromConfig(cfg)
718+
func DeleteRole(ctx context.Context, cfg *awsv2.Config, name string) error {
719+
iamSvc := iam.NewFromConfig(*cfg)
720720

721721
// if role does not exist, return.
722722
_, err := iamSvc.GetRole(ctx, &iam.GetRoleInput{RoleName: aws.String(name)})
@@ -868,8 +868,8 @@ func ensureTestImageUploaded(e2eCtx *E2EContext) error {
868868

869869
// ensureNoServiceLinkedRoles removes an auto-created IAM role, and tests
870870
// the controller's IAM permissions to use ELB and Spot instances successfully.
871-
func ensureNoServiceLinkedRoles(ctx context.Context, cfg awsv2.Config) {
872-
iamSvc := iam.NewFromConfig(cfg)
871+
func ensureNoServiceLinkedRoles(ctx context.Context, cfg *awsv2.Config) {
872+
iamSvc := iam.NewFromConfig(*cfg)
873873

874874
By("Deleting AWS IAM Service Linked Role: role-name=AWSServiceRoleForElasticLoadBalancing")
875875
_, err := iamSvc.DeleteServiceLinkedRole(ctx, &iam.DeleteServiceLinkedRoleInput{
@@ -929,8 +929,8 @@ func encodeCredentials(accessKey *iamtypes.AccessKey, region string) string {
929929

930930
// newUserAccessKey generates a new AWS Access Key pair based off of the
931931
// bootstrap user. This tests that the CloudFormation policy is correct.
932-
func newUserAccessKey(ctx context.Context, cfg awsv2.Config, userName string) *iamtypes.AccessKey {
933-
iamSvc := iam.NewFromConfig(cfg)
932+
func newUserAccessKey(ctx context.Context, cfg *awsv2.Config, userName string) *iamtypes.AccessKey {
933+
iamSvc := iam.NewFromConfig(*cfg)
934934

935935
keyOuts, _ := iamSvc.ListAccessKeys(ctx, &iam.ListAccessKeysInput{
936936
UserName: aws.String(userName),

test/e2e/shared/context.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ type E2EContext struct {
6565
Environment RuntimeEnvironment
6666
// AWSSession is the AWS session for the tests.
6767
AWSSession client.ConfigProvider
68-
// AWSClient is the AWS client for the tests.
69-
AWSConfig awsv2.Config
68+
// AWSSessionV2 is the AWS SDK V2 client for the tests.
69+
AWSSessionV2 *awsv2.Config
7070
// BootstrapUserAWSSession is the AWS session for the bootstrap user.
7171
BootstrapUserAWSSession client.ConfigProvider
7272
// BootstrapUserAWSSessionV2 is the AWS SDK V2 session for the bootstrap user.

test/e2e/shared/suite.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func Node1BeforeSuite(e2eCtx *E2EContext) []byte {
143143
count++
144144
By(fmt.Sprintf("Trying to create CloudFormation stack... attempt %d", count))
145145
success := true
146-
if err := createCloudFormationStack(context.TODO(), e2eCtx.AWSConfig, e2eCtx.AWSSession, bootstrapTemplate, bootstrapTags); err != nil {
146+
if err := createCloudFormationStack(context.TODO(), e2eCtx.AWSSessionV2, e2eCtx.AWSSession, bootstrapTemplate, bootstrapTags); err != nil {
147147
By(fmt.Sprintf("Failed to create CloudFormation stack in attempt %d: %s", count, err.Error()))
148148
deleteCloudFormationStack(e2eCtx.AWSSession, bootstrapTemplate)
149149
success = false
@@ -153,9 +153,9 @@ func Node1BeforeSuite(e2eCtx *E2EContext) []byte {
153153
}
154154

155155
ensureStackTags(e2eCtx.AWSSession, bootstrapTemplate.Spec.StackName, bootstrapTags)
156-
ensureNoServiceLinkedRoles(context.TODO(), e2eCtx.AWSConfig)
156+
ensureNoServiceLinkedRoles(context.TODO(), e2eCtx.AWSSessionV2)
157157
ensureSSHKeyPair(e2eCtx.AWSSession, DefaultSSHKeyPairName)
158-
e2eCtx.Environment.BootstrapAccessKey = newUserAccessKey(context.TODO(), e2eCtx.AWSConfig, bootstrapTemplate.Spec.BootstrapUser.UserName)
158+
e2eCtx.Environment.BootstrapAccessKey = newUserAccessKey(context.TODO(), e2eCtx.AWSSessionV2, bootstrapTemplate.Spec.BootstrapUser.UserName)
159159
e2eCtx.BootstrapUserAWSSession = NewAWSSessionWithKey(e2eCtx.Environment.BootstrapAccessKey)
160160
//TODO: v2AccessKey can be removed after AWS SDK V2 Migration
161161
v2AccessKey := &iamtypes.AccessKey{

test/e2e/suites/managed/helpers.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"time"
2626

2727
"github.com/aws/aws-sdk-go-v2/aws"
28-
awsv2 "github.com/aws/aws-sdk-go-v2/aws"
2928
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
3029
"github.com/aws/aws-sdk-go-v2/service/eks"
3130
ekstypes "github.com/aws/aws-sdk-go-v2/service/eks/types"
@@ -199,8 +198,8 @@ func verifyManagedNodeGroup(ctx context.Context, eksClusterName, nodeGroupName s
199198
}
200199
}
201200

202-
func verifyASG(eksClusterName, asgName string, checkOwned bool, cfg awsv2.Config) {
203-
asgClient := autoscaling.NewFromConfig(cfg)
201+
func verifyASG(eksClusterName, asgName string, checkOwned bool, cfg *aws.Config) {
202+
asgClient := autoscaling.NewFromConfig(*cfg)
204203

205204
input := &autoscaling.DescribeAutoScalingGroupsInput{
206205
AutoScalingGroupNames: []string{

test/e2e/suites/managed/machine_pool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func MachinePoolSpec(ctx context.Context, inputGetter func() MachinePoolSpecInpu
6060
Expect(input.ConfigClusterFn).ToNot(BeNil(), "Invalid argument. input.ConfigClusterFn can't be nil")
6161
Expect(input.BootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. input.BootstrapClusterProxy can't be nil")
6262
Expect(input.AWSSession).ToNot(BeNil(), "Invalid argument. input.AWSSession can't be nil")
63-
Expect(input.AWSConfig).ToNot(BeNil(), "Invalid argument. input.AWSCfg can't be nil")
63+
Expect(input.AWSSessionV2).ToNot(BeNil(), "Invalid argument. input.AWSCfg can't be nil")
6464
Expect(input.Namespace).NotTo(BeNil(), "Invalid argument. input.Namespace can't be nil")
6565
Expect(input.ClusterName).ShouldNot(BeEmpty(), "Invalid argument. input.ClusterName can't be empty")
6666
Expect(input.Flavor).ShouldNot(BeEmpty(), "Invalid argument. input.Flavor can't be empty")
@@ -113,7 +113,7 @@ func MachinePoolSpec(ctx context.Context, inputGetter func() MachinePoolSpecInpu
113113
verifyManagedNodeGroup(ctx, eksClusterName, nodeGroupName, true, input.AWSSessionV2)
114114
} else {
115115
asgName := getASGName(input.ClusterName)
116-
verifyASG(eksClusterName, asgName, true, input.AWSConfig)
116+
verifyASG(eksClusterName, asgName, true, input.AWSSessionV2)
117117
}
118118

119119
if input.IncludeScaling { // TODO (richardcase): should this be a separate spec?

0 commit comments

Comments
 (0)