Skip to content

Commit 3f1970b

Browse files
committed
use serverRef insted of server&credentialsRef
1 parent 55c9282 commit 3f1970b

File tree

7 files changed

+66
-37
lines changed

7 files changed

+66
-37
lines changed

api/v1beta1/proxmoxcluster_types.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,9 @@ type ProxmoxClusterSpec struct {
3535
// +optional
3636
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
3737

38-
// Server is the address of the Proxmox-VE REST API endpoint.
38+
// ServerRef is used for configuring Proxmox client
3939
// to do : client options like insecure tls verify, token login, etc.
40-
Server string `json:"server"`
41-
42-
// CredentialsRef is a reference for secret which contains proxmox login secrets
43-
// and ssh configs for proxmox nodes
44-
CredentialsRef *ObjectReference `json:"credentialsRef"`
40+
ServerRef ServerRef `json:"serverRef"`
4541

4642
// storage is for proxmox storage used by vm instances
4743
Storage Storage `json:"storage"`

api/v1beta1/type.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@ import (
77
"github.com/sp-yduck/proxmox/pkg/service/node/vm"
88
)
99

10+
// ServerRef is used for configuring Proxmox client
11+
type ServerRef struct {
12+
// endpoint is the address of the Proxmox-VE REST API endpoint.
13+
Endpoint string `json:"endpoint"`
14+
15+
// to do : login type should be an option
16+
// user&pass or token
17+
18+
// to do : insecure tls verify
19+
20+
// CredentialsRef is a reference for secret which contains proxmox login secrets
21+
// and ssh configs for proxmox nodes
22+
CredentialsRef *ObjectReference `json:"credentialsRef"`
23+
}
24+
1025
// ObjectReference is a reference to another Kubernetes object instance.
1126
type ObjectReference struct {
1227
// Namespace of the referent.

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 21 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cloud/interfaces.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ type ClusterGetter interface {
3131
Client
3232
Name() string
3333
Namespace() string
34-
Server() string
3534
// NetworkName() string
3635
// Network() *infrav1.Network
3736
// AdditionalLabels() infrav1.Labels

cloud/scope/clients.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ type ProxmoxServices struct {
3232
Remote *SSHClient
3333
}
3434

35-
func newComputeService(ctx context.Context, pCluster *infrav1.ProxmoxCluster, crClient client.Client) (*service.Service, error) {
36-
credentialsRef := pCluster.Spec.CredentialsRef
35+
func newComputeService(ctx context.Context, serverRef infrav1.ServerRef, crClient client.Client) (*service.Service, error) {
36+
credentialsRef := serverRef.CredentialsRef
3737
if credentialsRef == nil {
3838
return nil, errors.New("failed to get proxmox client form nil credentialsRef")
3939
}
@@ -53,7 +53,7 @@ func newComputeService(ctx context.Context, pCluster *infrav1.ProxmoxCluster, cr
5353
return nil, errors.Errorf("failed to fetch PROXMOX_PASSWORD from Secret : %v", key)
5454
}
5555

56-
return service.NewServiceWithLogin(pCluster.Spec.Server, string(proxmoxUser), string(proxmoxPassword))
56+
return service.NewServiceWithLogin(serverRef.Endpoint, string(proxmoxUser), string(proxmoxPassword))
5757
}
5858

5959
func newRemoteClient(ctx context.Context, credentialsRef *infrav1.ObjectReference, crClient client.Client) (*SSHClient, error) {

cloud/scope/cluster.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ func NewClusterScope(ctx context.Context, params ClusterScopeParams) (*ClusterSc
4444
}
4545

4646
if params.ProxmoxServices.Compute == nil {
47-
computeSvc, err := newComputeService(ctx, params.ProxmoxCluster, params.Client)
47+
computeSvc, err := newComputeService(ctx, params.ProxmoxCluster.Spec.ServerRef, params.Client)
4848
if err != nil {
4949
return nil, errors.Errorf("failed to create proxmox compute client: %v", err)
5050
}
5151
params.ProxmoxServices.Compute = computeSvc
5252
}
5353

5454
if params.ProxmoxServices.Remote == nil {
55-
remote, err := newRemoteClient(ctx, params.ProxmoxCluster.Spec.CredentialsRef, params.Client)
55+
remote, err := newRemoteClient(ctx, params.ProxmoxCluster.Spec.ServerRef.CredentialsRef, params.Client)
5656
if err != nil {
5757
return nil, errors.Errorf("failed to create remote client: %v", err)
5858
}
@@ -89,10 +89,6 @@ func (s *ClusterScope) Namespace() string {
8989
return s.Cluster.Namespace
9090
}
9191

92-
func (s *ClusterScope) Server() string {
93-
return s.ProxmoxCluster.Spec.Server
94-
}
95-
9692
func (s *ClusterScope) ControlPlaneEndpoint() clusterv1.APIEndpoint {
9793
return s.ProxmoxCluster.Spec.ControlPlaneEndpoint
9894
}

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

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,32 @@ spec:
5757
- host
5858
- port
5959
type: object
60-
credentialsRef:
61-
description: CredentialsRef is a reference for secret which contains
62-
proxmox login secrets and ssh configs for proxmox nodes
60+
serverRef:
61+
description: 'ServerRef is used for configuring Proxmox client to
62+
do : client options like insecure tls verify, token login, etc.'
6363
properties:
64-
name:
65-
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
66-
type: string
67-
namespace:
68-
description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
64+
credentialsRef:
65+
description: CredentialsRef is a reference for secret which contains
66+
proxmox login secrets and ssh configs for proxmox nodes
67+
properties:
68+
name:
69+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
70+
type: string
71+
namespace:
72+
description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
73+
type: string
74+
required:
75+
- name
76+
- namespace
77+
type: object
78+
endpoint:
79+
description: endpoint is the address of the Proxmox-VE REST API
80+
endpoint.
6981
type: string
7082
required:
71-
- name
72-
- namespace
83+
- credentialsRef
84+
- endpoint
7385
type: object
74-
server:
75-
description: 'Server is the address of the Proxmox-VE REST API endpoint.
76-
to do : client options like insecure tls verify, token login, etc.'
77-
type: string
7886
storage:
7987
description: storage is for proxmox storage used by vm instances
8088
properties:
@@ -84,8 +92,7 @@ spec:
8492
type: string
8593
type: object
8694
required:
87-
- credentialsRef
88-
- server
95+
- serverRef
8996
- storage
9097
type: object
9198
status:

0 commit comments

Comments
 (0)