From 181fcaec6b7e9188d260746ed67246b34bc8cce9 Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Tue, 13 Aug 2024 20:03:46 -0400 Subject: [PATCH] Use non-default namespace in mock controller --- cmd/mock/main.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cmd/mock/main.go b/cmd/mock/main.go index c953acc..59ad2eb 100644 --- a/cmd/mock/main.go +++ b/cmd/mock/main.go @@ -21,11 +21,16 @@ var ( scheme = runtime.NewScheme() ) +const ( + // to make sure we are not hardcoding namespaces in code + namespace = "81c6ed4dc0bf88203081454aefa806ca" +) + func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(jumpstarterdevv1alpha1.AddToScheme(scheme)) - os.Setenv("NAMESPACE", "default") + os.Setenv("NAMESPACE", namespace) } func main() { @@ -34,12 +39,12 @@ func main() { exporter := jumpstarterdevv1alpha1.Exporter{ ObjectMeta: metav1.ObjectMeta{ Name: "exporter-sample", - Namespace: "default", + Namespace: namespace, }, Spec: jumpstarterdevv1alpha1.ExporterSpec{ Credentials: []corev1.SecretReference{{ Name: "exporter-sample-token", - Namespace: "default", + Namespace: namespace, }}, }, } @@ -49,19 +54,19 @@ func main() { &jumpstarterdevv1alpha1.Identity{ ObjectMeta: metav1.ObjectMeta{ Name: "identity-sample", - Namespace: "default", + Namespace: namespace, }, Spec: jumpstarterdevv1alpha1.IdentitySpec{ Credentials: []corev1.SecretReference{{ Name: "identity-sample-token", - Namespace: "default", + Namespace: namespace, }}, }, }, &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ Name: "exporter-sample-token", - Namespace: "default", + Namespace: namespace, }, Data: map[string][]byte{ "token": []byte("54d8cd395728888be9fcb93c4575d99e"), @@ -70,7 +75,7 @@ func main() { &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ Name: "identity-sample-token", - Namespace: "default", + Namespace: namespace, }, Data: map[string][]byte{ "token": []byte("fc5c6dda1083a69e9886dc160de5b44e"), @@ -79,7 +84,7 @@ func main() { &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ Name: "jumpstarter-router-secret", - Namespace: "default", + Namespace: namespace, }, Data: map[string][]byte{ "key": []byte("a70643ffe8f924351fc343439399bbf4"),