From 880ef303e8e6056990f0e0a9a31b6f384272bfab Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Thu, 15 Oct 2020 14:09:08 +0300 Subject: [PATCH] Set alert provider secretRef only if specified Signed-off-by: Stefan Prodan --- cmd/gotk/create_alertprovider.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/gotk/create_alertprovider.go b/cmd/gotk/create_alertprovider.go index 8df247e9..a5e8b531 100644 --- a/cmd/gotk/create_alertprovider.go +++ b/cmd/gotk/create_alertprovider.go @@ -19,7 +19,6 @@ package main import ( "context" "fmt" - "github.com/fluxcd/pkg/apis/meta" "github.com/spf13/cobra" corev1 "k8s.io/api/core/v1" @@ -30,6 +29,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" notificationv1 "github.com/fluxcd/notification-controller/api/v1beta1" + "github.com/fluxcd/pkg/apis/meta" ) var createAlertProviderCmd = &cobra.Command{ @@ -99,12 +99,15 @@ func createAlertProviderCmdRun(cmd *cobra.Command, args []string) error { Channel: apChannel, Username: apUsername, Address: apAddress, - SecretRef: &corev1.LocalObjectReference{ - Name: apSecretRef, - }, }, } + if apSecretRef != "" { + alertProvider.Spec.SecretRef = &corev1.LocalObjectReference{ + Name: apSecretRef, + } + } + if export { return exportAlertProvider(alertProvider) }