Skip to content

Commit 4821298

Browse files
authored
USe cluster namespace if no namespace provided in credentials Ref (#248)
* USe cluster namespace if no namespace provided in credentials Ref * Add note regarding secret Ref namespace
1 parent 1d2a859 commit 4821298

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

api/v1alpha1/proxmoxcluster_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ type ProxmoxClusterSpec struct {
7676

7777
// CredentialsRef is a reference to a Secret that contains the credentials to use for provisioning this cluster. If not
7878
// supplied then the credentials of the controller will be used.
79+
// if no namespace is provided, the namespace of the ProxmoxCluster will be used.
7980
// +optional
8081
CredentialsRef *corev1.SecretReference `json:"credentialsRef,omitempty"`
8182
}

config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,8 @@ spec:
567567
credentialsRef:
568568
description: CredentialsRef is a reference to a Secret that contains
569569
the credentials to use for provisioning this cluster. If not supplied
570-
then the credentials of the controller will be used.
570+
then the credentials of the controller will be used. if no namespace
571+
is provided, the namespace of the ProxmoxCluster will be used.
571572
properties:
572573
name:
573574
description: name is unique within a namespace to reference a

config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclustertemplates.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,8 @@ spec:
617617
description: CredentialsRef is a reference to a Secret that
618618
contains the credentials to use for provisioning this cluster.
619619
If not supplied then the credentials of the controller will
620-
be used.
620+
be used. if no namespace is provided, the namespace of the
621+
ProxmoxCluster will be used.
621622
properties:
622623
name:
623624
description: name is unique within a namespace to reference

pkg/scope/cluster.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,12 @@ func NewClusterScope(params ClusterScopeParams) (*ClusterScope, error) {
129129
func (s *ClusterScope) setupProxmoxClient(ctx context.Context) (capmox.Client, error) {
130130
// get the credentials secret
131131
secret := corev1.Secret{}
132+
namespace := s.ProxmoxCluster.Spec.CredentialsRef.Namespace
133+
if len(namespace) == 0 {
134+
namespace = s.ProxmoxCluster.GetNamespace()
135+
}
132136
err := s.client.Get(ctx, client.ObjectKey{
133-
Namespace: s.ProxmoxCluster.Spec.CredentialsRef.Namespace,
137+
Namespace: namespace,
134138
Name: s.ProxmoxCluster.Spec.CredentialsRef.Name,
135139
}, &secret)
136140
if err != nil {

0 commit comments

Comments
 (0)