Skip to content

Commit 522907f

Browse files
author
Joshua Reed
committed
Secrets ref create and fetch test added.
1 parent bf98d11 commit 522907f

8 files changed

+37
-31
lines changed

controllers/cloudstackaffinitygroup_controller.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package controllers
1818

1919
import (
2020
"context"
21-
"github.com/onsi/ginkgo/v2"
2221

2322
ctrl "sigs.k8s.io/controller-runtime"
2423
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -55,7 +54,6 @@ func NewCSAGReconciliationRunner() *CloudStackAGReconciliationRunner {
5554
}
5655

5756
func (reconciler *CloudStackAffinityGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
58-
defer ginkgo.GinkgoRecover()
5957
return NewCSAGReconciliationRunner().
6058
UsingBaseReconciler(reconciler.ReconcilerBase).
6159
ForRequest(req).
@@ -64,7 +62,6 @@ func (reconciler *CloudStackAffinityGroupReconciler) Reconcile(ctx context.Conte
6462
}
6563

6664
func (r *CloudStackAGReconciliationRunner) Reconcile() (ctrl.Result, error) {
67-
defer ginkgo.GinkgoRecover()
6865
controllerutil.AddFinalizer(r.ReconciliationSubject, infrav1.AffinityGroupFinalizer)
6966
affinityGroup := &cloud.AffinityGroup{Name: r.ReconciliationSubject.Spec.Name, Type: r.ReconciliationSubject.Spec.Type}
7067
if err := r.CSUser.GetOrCreateAffinityGroup(affinityGroup); err != nil {

controllers/cloudstackcluster_controller.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package controllers
1919
import (
2020
"context"
2121
"fmt"
22-
"github.com/onsi/ginkgo/v2"
2322
"reflect"
2423

2524
ctrl "sigs.k8s.io/controller-runtime"
@@ -77,7 +76,6 @@ func NewCSClusterReconciliationRunner() *CloudStackClusterReconciliationRunner {
7776

7877
// Reconcile is the method k8s will call upon a reconciliation request.
7978
func (reconciler *CloudStackClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (retRes ctrl.Result, retErr error) {
80-
defer ginkgo.GinkgoRecover()
8179
return NewCSClusterReconciliationRunner().
8280
UsingBaseReconciler(reconciler.ReconcilerBase).
8381
ForRequest(req).
@@ -87,7 +85,6 @@ func (reconciler *CloudStackClusterReconciler) Reconcile(ctx context.Context, re
8785

8886
// Reconcile actually reconciles the CloudStackCluster.
8987
func (r *CloudStackClusterReconciliationRunner) Reconcile() (res ctrl.Result, reterr error) {
90-
defer ginkgo.GinkgoRecover()
9188
return r.RunReconciliationStages(
9289
r.RequeueIfMissingBaseCRs,
9390
r.CreateFailureDomains(r.ReconciliationSubject.Spec.FailureDomains),

controllers/cloudstackfailuredomain_controller.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package controllers
1919
import (
2020
"context"
2121

22-
"github.com/onsi/ginkgo/v2"
2322

2423
"github.com/pkg/errors"
2524
corev1 "k8s.io/api/core/v1"
@@ -59,7 +58,6 @@ func NewCSFailureDomainReconciliationRunner() *CloudStackFailureDomainReconcilia
5958

6059
// Reconcile is the method k8s will call upon a reconciliation request.
6160
func (reconciler *CloudStackFailureDomainReconciler) Reconcile(ctx context.Context, req ctrl.Request) (retRes ctrl.Result, retErr error) {
62-
defer ginkgo.GinkgoRecover()
6361
return NewCSFailureDomainReconciliationRunner().
6462
UsingBaseReconciler(reconciler.ReconcilerBase).
6563
ForRequest(req).
@@ -69,7 +67,6 @@ func (reconciler *CloudStackFailureDomainReconciler) Reconcile(ctx context.Conte
6967

7068
// Reconcile on the ReconciliationRunner actually attempts to modify or create the reconciliation subject.
7169
func (r *CloudStackFailureDomainReconciliationRunner) Reconcile() (retRes ctrl.Result, retErr error) {
72-
defer ginkgo.GinkgoRecover()
7370
endpointCredentials := &corev1.Secret{}
7471
ref := r.ReconciliationSubject.Spec.ACSEndpoint
7572
key := client.ObjectKey{Name: ref.Name, Namespace: ref.Namespace}

controllers/cloudstackisolatednetwork_controller.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package controllers
1818

1919
import (
2020
"context"
21-
"github.com/onsi/ginkgo/v2"
2221
"strings"
2322

2423
"sigs.k8s.io/cluster-api/util/patch"
@@ -58,7 +57,6 @@ func NewCSIsoNetReconciliationRunner() *CloudStackIsoNetReconciliationRunner {
5857
}
5958

6059
func (reconciler *CloudStackIsoNetReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res ctrl.Result, retErr error) {
61-
defer ginkgo.GinkgoRecover()
6260
return NewCSIsoNetReconciliationRunner().
6361
UsingBaseReconciler(reconciler.ReconcilerBase).
6462
ForRequest(req).
@@ -67,7 +65,6 @@ func (reconciler *CloudStackIsoNetReconciler) Reconcile(ctx context.Context, req
6765
}
6866

6967
func (r *CloudStackIsoNetReconciliationRunner) Reconcile() (retRes ctrl.Result, retErr error) {
70-
defer ginkgo.GinkgoRecover()
7168
if res, err := r.RequeueIfMissingBaseCRs(); r.ShouldReturn(res, err) {
7269
return res, err
7370
}

controllers/cloudstackmachine_controller.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package controllers
1919
import (
2020
"context"
2121
"fmt"
22-
"github.com/onsi/ginkgo/v2"
2322
"math/rand"
2423
"reflect"
2524

@@ -82,7 +81,6 @@ func NewCSMachineReconciliationRunner() *CloudStackMachineReconciliationRunner {
8281
// Reconcile is part of the main kubernetes reconciliation loop which aims to
8382
// move the current state of the cluster closer to the desired state.
8483
func (reconciler *CloudStackMachineReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res ctrl.Result, retErr error) {
85-
defer ginkgo.GinkgoRecover()
8684
return NewCSMachineReconciliationRunner().
8785
UsingBaseReconciler(reconciler.ReconcilerBase).
8886
ForRequest(req).
@@ -91,7 +89,6 @@ func (reconciler *CloudStackMachineReconciler) Reconcile(ctx context.Context, re
9189
}
9290

9391
func (r *CloudStackMachineReconciliationRunner) Reconcile() (retRes ctrl.Result, reterr error) {
94-
defer ginkgo.GinkgoRecover()
9592
return r.RunReconciliationStages(
9693
r.GetZonesAndRequeueIfMissing(r.Zones),
9794
r.GetParent(r.ReconciliationSubject, r.CAPIMachine),

controllers/cloudstackmachinestatechecker_controller.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package controllers
1818

1919
import (
2020
"context"
21-
"github.com/onsi/ginkgo/v2"
2221
"strings"
2322
"time"
2423

@@ -60,7 +59,6 @@ func NewCSMachineStateCheckerReconciliationRunner() *CloudStackMachineStateCheck
6059
}
6160

6261
func (r *CloudStackMachineStateCheckerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
63-
defer ginkgo.GinkgoRecover()
6462
return NewCSMachineStateCheckerReconciliationRunner().
6563
UsingBaseReconciler(r.ReconcilerBase).
6664
ForRequest(req).
@@ -69,7 +67,6 @@ func (r *CloudStackMachineStateCheckerReconciler) Reconcile(ctx context.Context,
6967
}
7068

7169
func (r *CloudStackMachineStateCheckerReconciliationRunner) Reconcile() (ctrl.Result, error) {
72-
defer ginkgo.GinkgoRecover()
7370
if res, err := r.GetParent(r.ReconciliationSubject, r.CSMachine)(); r.ShouldReturn(res, err) {
7471
return res, err
7572
}

controllers/cloudstackzone_controller.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package controllers
1919
import (
2020
"context"
2121

22-
"github.com/onsi/ginkgo/v2"
2322

2423
ctrl "sigs.k8s.io/controller-runtime"
2524
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -59,7 +58,6 @@ func NewCSZoneReconciliationRunner() *CloudStackZoneReconciliationRunner {
5958

6059
// Reconciler Reconcile adapts the runner to the runner to what k8s expects.
6160
func (reconciler *CloudStackZoneReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res ctrl.Result, retErr error) {
62-
defer ginkgo.GinkgoRecover()
6361
return NewCSZoneReconciliationRunner().
6462
UsingBaseReconciler(reconciler.ReconcilerBase).
6563
ForRequest(req).
@@ -76,7 +74,6 @@ func (reconciler *CloudStackZoneReconciler) SetupWithManager(mgr ctrl.Manager) e
7674

7775
// Reconcile attempts to move the state of CRs to the requested state.
7876
func (r *CloudStackZoneReconciliationRunner) Reconcile() (retRes ctrl.Result, reterr error) {
79-
defer ginkgo.GinkgoRecover()
8077
// Prevent premature deletion.
8178
controllerutil.AddFinalizer(r.ReconciliationSubject, infrav1.FailuDomainFinalizer)
8279

test/dummies/v1beta2/vars.go

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ var ( // Declare exported dummy vars.
3333
ClusterName string
3434
ClusterNameSpace string
3535
CSMachineTemplate1 *infrav1.CloudStackMachineTemplate
36+
ACSEndpointSecret1 *corev1.Secret
37+
ACSEndpointSecret2 *corev1.Secret
3638
Zone1 infrav1.Zone
3739
Zone2 infrav1.Zone
3840
CSZone1 *infrav1.CloudStackZone
@@ -97,6 +99,7 @@ func SetDummyVars() {
9799
// These need to be in order as they build upon eachother.
98100
SetDummyZoneVars()
99101
SetDiskOfferingVars()
102+
SetACSEndpointSecretVars()
100103
SetDummyCAPCClusterVars()
101104
SetDummyCAPIClusterVars()
102105
SetDummyCAPIMachineVars()
@@ -282,27 +285,30 @@ func SetDummyCAPCClusterVars() {
282285
CSFailureDomain1 = &infrav1.CloudStackFailureDomain{
283286
TypeMeta: metav1.TypeMeta{
284287
APIVersion: CSApiVersion,
285-
Kind: "CloudStackFailureDomain",
286-
},
288+
Kind: "CloudStackFailureDomain"},
287289
ObjectMeta: metav1.ObjectMeta{
288290
Name: "fd1",
289291
Namespace: "default",
290292
UID: "0",
291-
Labels: ClusterLabel,
292-
},
293-
Spec: infrav1.CloudStackFailureDomainSpec{Name: "fd1", Zone: Zone1}}
293+
Labels: ClusterLabel},
294+
Spec: infrav1.CloudStackFailureDomainSpec{Name: "fd1", Zone: Zone1,
295+
ACSEndpoint: corev1.SecretReference{
296+
Namespace: ClusterNameSpace,
297+
Name: ACSEndpointSecret1.Name}}}
294298
CSFailureDomain2 = &infrav1.CloudStackFailureDomain{
295299
TypeMeta: metav1.TypeMeta{
296300
APIVersion: CSApiVersion,
297-
Kind: "CloudStackFailureDomain",
298-
},
301+
Kind: "CloudStackFailureDomain"},
299302
ObjectMeta: metav1.ObjectMeta{
300303
Name: "fd2",
301304
Namespace: "default",
302305
UID: "0",
303-
Labels: ClusterLabel,
304-
},
305-
Spec: infrav1.CloudStackFailureDomainSpec{Zone: Zone1}}
306+
Labels: ClusterLabel},
307+
Spec: infrav1.CloudStackFailureDomainSpec{Name: "fd2", Zone: Zone2,
308+
ACSEndpoint: corev1.SecretReference{
309+
Namespace: ClusterNameSpace,
310+
Name: ACSEndpointSecret2.Name}}}
311+
306312
CSCluster = &infrav1.CloudStackCluster{
307313
TypeMeta: metav1.TypeMeta{
308314
APIVersion: CSApiVersion,
@@ -337,6 +343,27 @@ func SetDummyCAPCClusterVars() {
337343
CSISONet1.Spec.ID = ISONet1.ID
338344
}
339345

346+
func SetACSEndpointSecretVars() {
347+
ACSEndpointSecret1 = &corev1.Secret{
348+
ObjectMeta: metav1.ObjectMeta{
349+
Namespace: ClusterNameSpace,
350+
Name: "acsendpointsecret1"},
351+
StringData: map[string]string{
352+
"api-key": "someKey1",
353+
"secret-key": "someSecretKey1",
354+
"api-url": "http://someUri1:8080/client/api"},
355+
}
356+
ACSEndpointSecret2 = &corev1.Secret{
357+
ObjectMeta: metav1.ObjectMeta{
358+
Namespace: ClusterNameSpace,
359+
Name: "acsendpointsecret2"},
360+
StringData: map[string]string{
361+
"api-key": "someKey2",
362+
"secret-key": "someSecretKey2",
363+
"api-url": "http://someUri2:8080/client/api"},
364+
}
365+
}
366+
340367
// SetClusterDummyDomainAndAccount sets domain and account in the CSCluster Spec. This is not the default.
341368
func SetClusterDummyDomainAndAccount() {
342369
CSCluster.Spec.Account = AccountName

0 commit comments

Comments
 (0)