Skip to content

Commit

Permalink
e2e: ensure controller's secret created using credentialsrequest
Browse files Browse the repository at this point in the history
  • Loading branch information
alebedev87 committed Oct 24, 2023
1 parent e2e98f4 commit e5e259f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/e2e/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ func TestMain(m *testing.M) {
} else {
fmt.Println("Controller role is expected to exist when the test is run on a ROSA STS cluster")
controllerRoleARN = mustGetEnv(controllerRoleARNVarName)
// TODO: remove the copying once ROSA can provision 4.14 clusters
// which support stsIAMRoleARN field in CredentialsRequest.
if err := copySecret(context.TODO(), kubeClient, controllerSecretName, "aws-load-balancer-controller-credentialsrequest-cluster"); err != nil {
fmt.Printf("failed to copy controller secret: %v", err)
os.Exit(1)
}
}

os.Exit(m.Run())
Expand Down
21 changes: 21 additions & 0 deletions test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,3 +508,24 @@ func mustGetEnv(name string) string {
}
return val
}

// copySecret makes a copy of a secret in the operator's namespace.
func copySecret(ctx context.Context, kubeClient client.Client, nameIn, nameOut string) error {
secretIn := &corev1.Secret{}
if err := kubeClient.Get(ctx, types.NamespacedName{Name: nameIn, Namespace: operatorNamespace}, secretIn); err != nil {
return err
}

secretOut := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: nameOut,
Namespace: operatorNamespace,
},
Data: secretIn.Data,
}
if err := kubeClient.Create(ctx, secretOut); err != nil {
return err
}

return nil
}

0 comments on commit e5e259f

Please sign in to comment.