From 50648ab0fedda02460a81878cb94ce32162a732e Mon Sep 17 00:00:00 2001 From: nitishfy Date: Thu, 21 Nov 2024 00:08:50 +0530 Subject: [PATCH] resolve bug Signed-off-by: nitishfy --- cmd/helmrelease.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/helmrelease.go b/cmd/helmrelease.go index 10abec3..a98e71c 100644 --- a/cmd/helmrelease.go +++ b/cmd/helmrelease.go @@ -17,6 +17,7 @@ package cmd import ( "context" + "fmt" "os" "strconv" @@ -64,6 +65,10 @@ with kubectl.`, helmReleaseNamespace, _ := cmd.Flags().GetString("namespace") confirmMigrate, _ := cmd.Flags().GetBool("confirm-migrate") + if helmReleaseName == "" || helmReleaseNamespace == "" { + log.Fatal("Both --name and --namespace flags must be provided") + } + // Set up the default context ctx := context.TODO() @@ -103,8 +108,10 @@ with kubectl.`, } // Get the helmchart based on type, report if error + helmChartName := fmt.Sprintf("%s-%s", helmReleaseNamespace, helmReleaseName) + helmChart := &sourcev1.HelmChart{} - err = k.Get(ctx, types.NamespacedName{Namespace: helmRepoNamespace, Name: helmRepoNamespace + "-" + helmRelease.Name}, helmChart) + err = k.Get(ctx, types.NamespacedName{Namespace: helmRepoNamespace, Name: helmChartName}, helmChart) if err != nil { log.Fatal(err) }