Skip to content

Commit

Permalink
Merge pull request #189 from zzzeek/fix_np_errors
Browse files Browse the repository at this point in the history
dont use logForObject with nil pointer
  • Loading branch information
openshift-merge-bot[bot] authored and zzzeek committed Feb 8, 2024
2 parents 3dcb5d5 + 39a0a29 commit 738a135
Show file tree
Hide file tree
Showing 5 changed files with 323 additions and 57 deletions.
28 changes: 28 additions & 0 deletions api/test/helpers/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package helpers

import (
"context"
"fmt"
"time"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -216,3 +217,30 @@ func (tc *TestHelper) SimulateMariaDBAccountCompleted(name types.NamespacedName)

tc.Logger.Info("Simulated DB Account completed", "on", name)
}

// CreateMariaDBAccount creates and persists a MariaDBAccount resource and
// associated Secret in the Kubernetes cluster
func (tc *TestHelper) CreateMariaDBAccount(name types.NamespacedName) (*mariadbv1.MariaDBAccount, *corev1.Secret) {
secret := tc.CreateSecret(
types.NamespacedName{Namespace: name.Namespace, Name: fmt.Sprintf("%s-db-secret", name.Name)},
map[string][]byte{
"DatabasePassword": []byte(fmt.Sprintf("%s123", name.Name)),
},
)

instance := &mariadbv1.MariaDBAccount{
ObjectMeta: metav1.ObjectMeta{
Name: name.Name,
Namespace: name.Namespace,
},
Spec: mariadbv1.MariaDBAccountSpec{
UserName: fmt.Sprintf("%s_account", name.Name),
Secret: fmt.Sprintf("%s-db-secret", name.Name),
},
}
gomega.Eventually(func(g gomega.Gomega) {
g.Expect(tc.K8sClient.Create(tc.Ctx, instance)).Should(gomega.Succeed())
}, tc.Timeout, tc.Interval).Should(gomega.Succeed())

return instance, secret
}
Loading

0 comments on commit 738a135

Please sign in to comment.