From f85deaa7a102bace6d9c3464bdcd3cb95b1e42aa Mon Sep 17 00:00:00 2001 From: 1aal Date: Fri, 15 Dec 2023 12:30:22 +0800 Subject: [PATCH 1/3] filter by provider label --- pkg/cmd/addon/addon.go | 4 +++- pkg/types/types.go | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/addon/addon.go b/pkg/cmd/addon/addon.go index a992a5674..6fcd95d89 100644 --- a/pkg/cmd/addon/addon.go +++ b/pkg/cmd/addon/addon.go @@ -704,7 +704,9 @@ func (o *addonCmdOpts) buildHelmPatch(result map[string]interface{}) error { helmSpec.InstallValues.SetValues = o.addonEnableFlags.SetValues } // set resource registry - helmSpec.InstallValues.SetValues = append(helmSpec.InstallValues.SetValues, fmt.Sprintf("%s=%s", types.ImageRegistryKey, viper.Get(types.CfgKeyImageRegistry))) + if strings.ToLower(o.addon.Labels[types.ProviderLabelKey]) == types.PrivateProvider || strings.ToLower(o.addon.Labels[types.AddonProviderLabelKey]) == types.PrivateProvider { + helmSpec.InstallValues.SetValues = append(helmSpec.InstallValues.SetValues, fmt.Sprintf("%s=%s", types.ImageRegistryKey, viper.Get(types.CfgKeyImageRegistry))) + } b, err := json.Marshal(&helmSpec) if err != nil { diff --git a/pkg/types/types.go b/pkg/types/types.go index cba729d2e..f917b4333 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -58,6 +58,8 @@ const ( // DefaultIndexName defines the kbcli addon default index name DefaultIndexName = "kubeblocks" + // PrivateProvider define the private addon provider means apecloud manage the addon image + PrivateProvider = "apecloud" // DefaultNamespace is the namespace where kubeblocks is installed if // no other namespace is specified DefaultNamespace = "kb-system" From 50fcde0ccc0720ef85947ec6ba3daf8666de7fa1 Mon Sep 17 00:00:00 2001 From: 1aal Date: Fri, 15 Dec 2023 13:02:04 +0800 Subject: [PATCH 2/3] fix default addon image registry --- pkg/cmd/addon/addon.go | 4 +--- pkg/cmd/cli.go | 1 - pkg/types/types.go | 2 -- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/pkg/cmd/addon/addon.go b/pkg/cmd/addon/addon.go index 6fcd95d89..a992a5674 100644 --- a/pkg/cmd/addon/addon.go +++ b/pkg/cmd/addon/addon.go @@ -704,9 +704,7 @@ func (o *addonCmdOpts) buildHelmPatch(result map[string]interface{}) error { helmSpec.InstallValues.SetValues = o.addonEnableFlags.SetValues } // set resource registry - if strings.ToLower(o.addon.Labels[types.ProviderLabelKey]) == types.PrivateProvider || strings.ToLower(o.addon.Labels[types.AddonProviderLabelKey]) == types.PrivateProvider { - helmSpec.InstallValues.SetValues = append(helmSpec.InstallValues.SetValues, fmt.Sprintf("%s=%s", types.ImageRegistryKey, viper.Get(types.CfgKeyImageRegistry))) - } + helmSpec.InstallValues.SetValues = append(helmSpec.InstallValues.SetValues, fmt.Sprintf("%s=%s", types.ImageRegistryKey, viper.Get(types.CfgKeyImageRegistry))) b, err := json.Marshal(&helmSpec) if err != nil { diff --git a/pkg/cmd/cli.go b/pkg/cmd/cli.go index 7657630e3..17d42782b 100644 --- a/pkg/cmd/cli.go +++ b/pkg/cmd/cli.go @@ -250,7 +250,6 @@ func initConfig() { viper.SetDefault(types.CfgKeyClusterDefaultMemory, "1Gi") viper.SetDefault(types.CfgKeyHelmRepoURL, "") - viper.SetDefault(types.CfgKeyImageRegistry, "infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com") // If a config file is found, read it in. if err := viper.ReadInConfig(); err == nil { fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed()) diff --git a/pkg/types/types.go b/pkg/types/types.go index f917b4333..cba729d2e 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -58,8 +58,6 @@ const ( // DefaultIndexName defines the kbcli addon default index name DefaultIndexName = "kubeblocks" - // PrivateProvider define the private addon provider means apecloud manage the addon image - PrivateProvider = "apecloud" // DefaultNamespace is the namespace where kubeblocks is installed if // no other namespace is specified DefaultNamespace = "kb-system" From 024dd68462908de74a3577b83b8ae45046abe779 Mon Sep 17 00:00:00 2001 From: 1aal Date: Fri, 15 Dec 2023 13:08:53 +0800 Subject: [PATCH 3/3] fix default addon image registry --- pkg/cmd/addon/addon.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/addon/addon.go b/pkg/cmd/addon/addon.go index a992a5674..1f20e5fa1 100644 --- a/pkg/cmd/addon/addon.go +++ b/pkg/cmd/addon/addon.go @@ -704,7 +704,9 @@ func (o *addonCmdOpts) buildHelmPatch(result map[string]interface{}) error { helmSpec.InstallValues.SetValues = o.addonEnableFlags.SetValues } // set resource registry - helmSpec.InstallValues.SetValues = append(helmSpec.InstallValues.SetValues, fmt.Sprintf("%s=%s", types.ImageRegistryKey, viper.Get(types.CfgKeyImageRegistry))) + if viper.Get(types.CfgKeyImageRegistry) != "" { + helmSpec.InstallValues.SetValues = append(helmSpec.InstallValues.SetValues, fmt.Sprintf("%s=%s", types.ImageRegistryKey, viper.Get(types.CfgKeyImageRegistry))) + } b, err := json.Marshal(&helmSpec) if err != nil {