From a8f0136d9f928217ec29f9cf440a928fd7bebc5f Mon Sep 17 00:00:00 2001 From: John Dietz Date: Sun, 13 Nov 2022 20:25:24 -0500 Subject: [PATCH 1/2] adding ghcr secrets to the other 3 namespaces --- internal/k3d/secrets.go | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/internal/k3d/secrets.go b/internal/k3d/secrets.go index 9b55703b9..c170a705f 100644 --- a/internal/k3d/secrets.go +++ b/internal/k3d/secrets.go @@ -5,18 +5,19 @@ import ( "encoding/base64" "errors" "fmt" + "log" + "os" + "github.com/kubefirst/kubefirst/internal/k8s" "github.com/spf13/viper" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "log" - "os" ) func AddK3DSecrets(dryrun bool) error { clientset, err := k8s.GetClientSet(dryrun) - newNamespaces := []string{"argo", "argocd", "atlantis", "chartmuseum", "github-runner", "vault"} + newNamespaces := []string{"argo", "argocd", "atlantis", "chartmuseum", "github-runner", "vault", "development", "staging", "production"} for i, s := range newNamespaces { namespace := &v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: s}} _, err = clientset.CoreV1().Namespaces().Create(context.TODO(), namespace, metav1.CreateOptions{}) @@ -77,6 +78,36 @@ func AddK3DSecrets(dryrun bool) error { log.Println("Error:", err) return errors.New("error creating kubernetes secret: argo/docker-config") } + + developmentDockerSecrets := &v1.Secret{ + ObjectMeta: metav1.ObjectMeta{Name: "docker-config", Namespace: "development"}, + Data: map[string][]byte{"config.json": []byte(dockerConfigString)}, + } + _, err = clientset.CoreV1().Secrets("development").Create(context.TODO(), developmentDockerSecrets, metav1.CreateOptions{}) + if err != nil { + log.Println("Error:", err) + return errors.New("error creating kubernetes secret: development/docker-config") + } + + stagingDockerSecrets := &v1.Secret{ + ObjectMeta: metav1.ObjectMeta{Name: "docker-config", Namespace: "staging"}, + Data: map[string][]byte{"config.json": []byte(dockerConfigString)}, + } + _, err = clientset.CoreV1().Secrets("staging").Create(context.TODO(), stagingDockerSecrets, metav1.CreateOptions{}) + if err != nil { + log.Println("Error:", err) + return errors.New("error creating kubernetes secret: development/docker-config") + } + + productionDockerSecrets := &v1.Secret{ + ObjectMeta: metav1.ObjectMeta{Name: "docker-config", Namespace: "production"}, + Data: map[string][]byte{"config.json": []byte(dockerConfigString)}, + } + _, err = clientset.CoreV1().Secrets("production").Create(context.TODO(), productionDockerSecrets, metav1.CreateOptions{}) + if err != nil { + log.Println("Error:", err) + return errors.New("error creating kubernetes secret: development/docker-config") + } viper.Set("kubernetes.argo-docker.secret.created", true) viper.WriteConfig() From fa3a27b58c7d9ac4eb812d8ce09608998ef7f9ee Mon Sep 17 00:00:00 2001 From: John Dietz Date: Sun, 13 Nov 2022 20:32:50 -0500 Subject: [PATCH 2/2] Update secrets.go --- internal/k3d/secrets.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/k3d/secrets.go b/internal/k3d/secrets.go index c170a705f..7c3914812 100644 --- a/internal/k3d/secrets.go +++ b/internal/k3d/secrets.go @@ -96,7 +96,7 @@ func AddK3DSecrets(dryrun bool) error { _, err = clientset.CoreV1().Secrets("staging").Create(context.TODO(), stagingDockerSecrets, metav1.CreateOptions{}) if err != nil { log.Println("Error:", err) - return errors.New("error creating kubernetes secret: development/docker-config") + return errors.New("error creating kubernetes secret: staging/docker-config") } productionDockerSecrets := &v1.Secret{ @@ -106,7 +106,7 @@ func AddK3DSecrets(dryrun bool) error { _, err = clientset.CoreV1().Secrets("production").Create(context.TODO(), productionDockerSecrets, metav1.CreateOptions{}) if err != nil { log.Println("Error:", err) - return errors.New("error creating kubernetes secret: development/docker-config") + return errors.New("error creating kubernetes secret: production/docker-config") } viper.Set("kubernetes.argo-docker.secret.created", true) viper.WriteConfig()