Skip to content

Commit a5f33ef

Browse files
zhujian7claude
andcommitted
Add default namespace support to AgentInstallNamespaceFromDeploymentConfigFunc
This enhancement allows callers to specify a fallback namespace when the addon deployment config doesn't specify an agent install namespace. The function now accepts an optional defaultNs parameter that will be returned when config.Spec.AgentInstallNamespace is empty. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Signed-off-by: zhujian <[email protected]>
1 parent 1a0a9be commit a5f33ef

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/utils/addon_config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (g *defaultAddOnDeploymentConfigGetter) Get(
3535
// namespace from the addon deployment config. If the addon does not support addon deployment config or there is no
3636
// matched addon deployment config, it will return an empty string.
3737
func AgentInstallNamespaceFromDeploymentConfigFunc(
38-
adcgetter AddOnDeploymentConfigGetter,
38+
adcgetter AddOnDeploymentConfigGetter, defaultNs ...string,
3939
) func(*addonapiv1alpha1.ManagedClusterAddOn) (string, error) {
4040
return func(addon *addonapiv1alpha1.ManagedClusterAddOn) (string, error) {
4141
if addon == nil {
@@ -58,6 +58,9 @@ func AgentInstallNamespaceFromDeploymentConfigFunc(
5858
return "", nil
5959
}
6060

61+
if config.Spec.AgentInstallNamespace == "" && len(defaultNs) > 0 {
62+
return defaultNs[0], nil
63+
}
6164
return config.Spec.AgentInstallNamespace, nil
6265
}
6366
}

0 commit comments

Comments
 (0)