From 0914eda4543257bf298ff01ee29c01ab22d20186 Mon Sep 17 00:00:00 2001 From: Pedro Juarez Date: Wed, 7 Dec 2022 14:01:33 -0600 Subject: [PATCH] fix: --kubeconfig parameter was being ignored in init and delete commands (#1363) --- kubectl-minio/cmd/delete.go | 11 ++++++++++- kubectl-minio/cmd/init.go | 10 +++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/kubectl-minio/cmd/delete.go b/kubectl-minio/cmd/delete.go index 459c811c656..f9ab66f6d71 100644 --- a/kubectl-minio/cmd/delete.go +++ b/kubectl-minio/cmd/delete.go @@ -132,8 +132,17 @@ func (o *deleteCmd) run(writer io.Writer) error { return err } + path, _ := rootCmd.Flags().GetString(kubeconfig) + + var parameters []string + if path != "" { + parameters = append(parameters, "--kubeconfig", path, "delete", "-f", "-") + } else { + parameters = append(parameters, "delete", "-f", "-") + } + // do kubectl apply - cmd := exec.Command("kubectl", "delete", "-f", "-") + cmd := exec.Command("kubectl", parameters...) cmd.Stdin = strings.NewReader(string(yml)) diff --git a/kubectl-minio/cmd/init.go b/kubectl-minio/cmd/init.go index e6e227aa6da..ff4164ea5f6 100644 --- a/kubectl-minio/cmd/init.go +++ b/kubectl-minio/cmd/init.go @@ -293,8 +293,16 @@ func (o *operatorInitCmd) run(writer io.Writer) error { return err } + path, _ := rootCmd.Flags().GetString(kubeconfig) + + var parameters []string + if path != "" { + parameters = append(parameters, "--kubeconfig", path, "apply", "-f", "-") + } else { + parameters = append(parameters, "apply", "-f", "-") + } // do kubectl apply - cmd := exec.Command("kubectl", "apply", "-f", "-") + cmd := exec.Command("kubectl", parameters...) cmd.Stdin = strings.NewReader(string(yml))