mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-05-22 00:54:00 +00:00
Read namespce from status at first to build config (#308)
Signed-off-by: Jian Qiu <jqiu@redhat.com>
This commit is contained in:
@@ -59,10 +59,13 @@ func (c *registrationConfig) x509Subject(clusterName, agentName string) *pkix.Na
|
||||
}
|
||||
|
||||
// getAddOnInstallationNamespace returns addon installation namespace from addon spec.
|
||||
// If the installation namespace is not specified on addon spec, the addon default
|
||||
// It first checks the installation namespace in status then addon spec, the addon default
|
||||
// installation namespace open-cluster-management-agent-addon will be returned.
|
||||
func getAddOnInstallationNamespace(addOn *addonv1alpha1.ManagedClusterAddOn) string {
|
||||
installationNamespace := addOn.Spec.InstallNamespace
|
||||
installationNamespace := addOn.Status.Namespace
|
||||
if installationNamespace == "" {
|
||||
installationNamespace = addOn.Spec.InstallNamespace
|
||||
}
|
||||
if installationNamespace == "" {
|
||||
installationNamespace = defaultAddOnInstallationNamespace
|
||||
}
|
||||
|
||||
@@ -52,6 +52,27 @@ func TestGetRegistrationConfigs(t *testing.T) {
|
||||
newRegistrationConfig(addOnName, addOnNamespace, "kubernetes.io/kube-apiserver-client", "", nil, false),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "namespace in status",
|
||||
addon: &addonv1alpha1.ManagedClusterAddOn{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: testinghelpers.TestManagedClusterName,
|
||||
Name: addOnName,
|
||||
},
|
||||
Spec: addonv1alpha1.ManagedClusterAddOnSpec{},
|
||||
Status: addonv1alpha1.ManagedClusterAddOnStatus{
|
||||
Registrations: []addonv1alpha1.RegistrationConfig{
|
||||
{
|
||||
SignerName: "kubernetes.io/kube-apiserver-client",
|
||||
},
|
||||
},
|
||||
Namespace: addOnNamespace,
|
||||
},
|
||||
},
|
||||
configs: []registrationConfig{
|
||||
newRegistrationConfig(addOnName, addOnNamespace, "kubernetes.io/kube-apiserver-client", "", nil, false),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "with default signer hosted mode",
|
||||
addon: &addonv1alpha1.ManagedClusterAddOn{
|
||||
|
||||
Reference in New Issue
Block a user