Skip to content

Commit 55c9282

Browse files
committed
move proxmox endpoint from secret to proxmoxcluster.spec
1 parent 2213a7b commit 55c9282

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

api/v1beta1/proxmoxcluster_types.go

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

38+
// Server is the address of the Proxmox-VE REST API endpoint.
39+
// 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
3844
CredentialsRef *ObjectReference `json:"credentialsRef"`
3945

4046
// storage is for proxmox storage used by vm instances

cloud/interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ type Cluster interface {
2929
// ClusterGetter is an interface which can get cluster information.
3030
type ClusterGetter interface {
3131
Client
32-
// Region() string
3332
Name() string
3433
Namespace() string
34+
Server() string
3535
// NetworkName() string
3636
// Network() *infrav1.Network
3737
// AdditionalLabels() infrav1.Labels

cloud/scope/clients.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ import (
2525
"sigs.k8s.io/controller-runtime/pkg/client"
2626

2727
infrav1 "github.com/sp-yduck/cluster-api-provider-proxmox/api/v1beta1"
28-
// "github.com/sp-yduck/cluster-api-provider-proxmox/cloud/services/compute/vm"
2928
)
3029

3130
type ProxmoxServices struct {
3231
Compute *service.Service
3332
Remote *SSHClient
3433
}
3534

36-
func newComputeService(ctx context.Context, credentialsRef *infrav1.ObjectReference, crClient client.Client) (*service.Service, error) {
35+
func newComputeService(ctx context.Context, pCluster *infrav1.ProxmoxCluster, crClient client.Client) (*service.Service, error) {
36+
credentialsRef := pCluster.Spec.CredentialsRef
3737
if credentialsRef == nil {
3838
return nil, errors.New("failed to get proxmox client form nil credentialsRef")
3939
}
@@ -44,10 +44,6 @@ func newComputeService(ctx context.Context, credentialsRef *infrav1.ObjectRefere
4444
return nil, err
4545
}
4646

47-
proxmoxUrl, ok := secret.Data["PROXMOX_URL"]
48-
if !ok {
49-
return nil, errors.Errorf("failed to fetch PROXMOX_URL from Secret : %v", key)
50-
}
5147
proxmoxUser, ok := secret.Data["PROXMOX_USER"]
5248
if !ok {
5349
return nil, errors.Errorf("failed to fetch PROXMOX_USER from Secret : %v", key)
@@ -57,7 +53,7 @@ func newComputeService(ctx context.Context, credentialsRef *infrav1.ObjectRefere
5753
return nil, errors.Errorf("failed to fetch PROXMOX_PASSWORD from Secret : %v", key)
5854
}
5955

60-
return service.NewServiceWithLogin(string(proxmoxUrl), string(proxmoxUser), string(proxmoxPassword))
56+
return service.NewServiceWithLogin(pCluster.Spec.Server, string(proxmoxUser), string(proxmoxPassword))
6157
}
6258

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

cloud/scope/cluster.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func NewClusterScope(ctx context.Context, params ClusterScopeParams) (*ClusterSc
4444
}
4545

4646
if params.ProxmoxServices.Compute == nil {
47-
computeSvc, err := newComputeService(ctx, params.ProxmoxCluster.Spec.CredentialsRef, params.Client)
47+
computeSvc, err := newComputeService(ctx, params.ProxmoxCluster, params.Client)
4848
if err != nil {
4949
return nil, errors.Errorf("failed to create proxmox compute client: %v", err)
5050
}
@@ -89,6 +89,10 @@ 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+
9296
func (s *ClusterScope) ControlPlaneEndpoint() clusterv1.APIEndpoint {
9397
return s.ProxmoxCluster.Spec.ControlPlaneEndpoint
9498
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ spec:
5858
- port
5959
type: object
6060
credentialsRef:
61-
description: ObjectReference is a reference to another Kubernetes
62-
object instance.
61+
description: CredentialsRef is a reference for secret which contains
62+
proxmox login secrets and ssh configs for proxmox nodes
6363
properties:
6464
name:
6565
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
@@ -71,6 +71,10 @@ spec:
7171
- name
7272
- namespace
7373
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
7478
storage:
7579
description: storage is for proxmox storage used by vm instances
7680
properties:
@@ -81,6 +85,7 @@ spec:
8185
type: object
8286
required:
8387
- credentialsRef
88+
- server
8489
- storage
8590
type: object
8691
status:

0 commit comments

Comments
 (0)