Skip to content

Commit f3d59b0

Browse files
fix: resolve argocdService initialization issue in notifications CLI (cherry-pick #24664 for 3.1) (#24681)
Signed-off-by: puretension <[email protected]> Co-authored-by: DOHYEONG LEE <[email protected]>
1 parent 4081e29 commit f3d59b0

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

cmd/argocd/commands/admin/notifications.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ func NewNotificationsCommand() *cobra.Command {
3030
)
3131

3232
var argocdService service.Service
33+
3334
toolsCommand := cmd.NewToolsCommand(
3435
"notifications",
3536
"argocd admin notifications",
3637
applications,
37-
settings.GetFactorySettingsForCLI(argocdService, "argocd-notifications-secret", "argocd-notifications-cm", false),
38+
settings.GetFactorySettingsForCLI(func() service.Service { return argocdService }, "argocd-notifications-secret", "argocd-notifications-cm", false),
3839
func(clientConfig clientcmd.ClientConfig) {
3940
k8sCfg, err := clientConfig.ClientConfig()
4041
if err != nil {

util/notification/settings/settings.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ func GetFactorySettings(argocdService service.Service, secretName, configMapName
2828
}
2929

3030
// GetFactorySettingsForCLI allows the initialization of argocdService to be deferred until it is used, when InitGetVars is called.
31-
func GetFactorySettingsForCLI(argocdService service.Service, secretName, configMapName string, selfServiceNotificationEnabled bool) api.Settings {
31+
func GetFactorySettingsForCLI(serviceGetter func() service.Service, secretName, configMapName string, selfServiceNotificationEnabled bool) api.Settings {
3232
return api.Settings{
3333
SecretName: secretName,
3434
ConfigMapName: configMapName,
3535
InitGetVars: func(cfg *api.Config, configMap *corev1.ConfigMap, secret *corev1.Secret) (api.GetVars, error) {
36+
argocdService := serviceGetter()
3637
if argocdService == nil {
3738
return nil, errors.New("argocdService is not initialized")
3839
}

0 commit comments

Comments
 (0)