Skip to content

Commit

Permalink
convert global var in func to return ns to backup
Browse files Browse the repository at this point in the history
Signed-off-by: Thiago Pagotto <pagottoo@gmail.com>
  • Loading branch information
pagottoo committed Jul 21, 2022
1 parent b727917 commit 25a43ae
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions internal/ssl/ssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ import (
"k8s.io/client-go/tools/clientcmd"
)

var namespaces []string

func init() {
namespaces = []string{"argo", "atlantis", "chartmuseum", "gitlab", "vault"}
func getNamespacesToBackupSSL() (ns []string) {
return []string{"argo", "atlantis", "chartmuseum", "gitlab", "vault"}
}

func getItemsToBackup(apiGroup string, apiVersion string, resourceType string, namespaces []string, jqQuery string) ([]string, error) {
Expand Down Expand Up @@ -85,7 +83,7 @@ func getItemsToBackup(apiGroup string, apiVersion string, resourceType string, n
// GetBackupCertificates create a backup of Certificates on AWS S3 in yaml files
func GetBackupCertificates() (string, error) {
config := configs.ReadConfig()

namespaces := getNamespacesToBackupSSL()
log.Println("GetBackupCertificates called")
bucketName := fmt.Sprintf("k1-%s", viper.GetString("aws.hostedzonename"))
//path := "cert-manager"
Expand Down Expand Up @@ -131,7 +129,7 @@ func GetBackupCertificates() (string, error) {

func RestoreSSL() error {
config := configs.ReadConfig()

namespaces := getNamespacesToBackupSSL()
for _, ns := range namespaces {
_, _, err := pkg.ExecShellReturnStrings(config.KubectlClientPath, "--kubeconfig", config.KubeConfigPath, "create", "ns", ns)
if err != nil {
Expand Down

0 comments on commit 25a43ae

Please sign in to comment.