Skip to content

Commit 5693bcf

Browse files
committed
wip: initial commit for proxmox sdk migration
1 parent d8bdaeb commit 5693bcf

File tree

8 files changed

+22
-17
lines changed

8 files changed

+22
-17
lines changed

cloud/interfaces.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package cloud
33
import (
44
"context"
55

6-
"github.com/sp-yduck/proxmox/pkg/service"
6+
"github.com/sp-yduck/proxmox-go/proxmox"
77
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
88

99
infrav1 "github.com/sp-yduck/cluster-api-provider-proxmox/api/v1beta1"
@@ -16,7 +16,7 @@ type Reconciler interface {
1616
}
1717

1818
type Client interface {
19-
CloudClient() *service.Service
19+
CloudClient() *proxmox.Service
2020
RemoteClient() *scope.SSHClient
2121
}
2222

cloud/scope/clients.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ import (
2020
"context"
2121

2222
"github.com/pkg/errors"
23-
"github.com/sp-yduck/proxmox/pkg/service"
23+
"github.com/sp-yduck/proxmox-go/proxmox"
2424
corev1 "k8s.io/api/core/v1"
2525
"sigs.k8s.io/controller-runtime/pkg/client"
2626

2727
infrav1 "github.com/sp-yduck/cluster-api-provider-proxmox/api/v1beta1"
2828
)
2929

3030
type ProxmoxServices struct {
31-
Compute *service.Service
31+
Compute *proxmox.Service
3232
Remote *SSHClient
3333
}
3434

35-
func newComputeService(ctx context.Context, serverRef infrav1.ServerRef, crClient client.Client) (*service.Service, error) {
35+
func newComputeService(ctx context.Context, serverRef infrav1.ServerRef, crClient client.Client) (*proxmox.Service, error) {
3636
secretRef := serverRef.SecretRef
3737
if secretRef == nil {
3838
return nil, errors.New("failed to get proxmox client form nil secretRef")
@@ -52,8 +52,12 @@ func newComputeService(ctx context.Context, serverRef infrav1.ServerRef, crClien
5252
if !ok {
5353
return nil, errors.Errorf("failed to fetch PROXMOX_PASSWORD from Secret : %v", key)
5454
}
55+
authConfig := proxmox.AuthConfig{
56+
Username: string(proxmoxUser),
57+
Password: string(proxmoxPassword),
58+
}
5559

56-
return service.NewServiceWithLogin(serverRef.Endpoint, string(proxmoxUser), string(proxmoxPassword))
60+
return proxmox.NewService(serverRef.Endpoint, authConfig, true)
5761
}
5862

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

cloud/scope/cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import (
2020
"context"
2121

2222
"github.com/pkg/errors"
23+
"github.com/sp-yduck/proxmox-go/proxmox"
2324
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2425
"sigs.k8s.io/cluster-api/util/patch"
2526
"sigs.k8s.io/controller-runtime/pkg/client"
2627

2728
infrav1 "github.com/sp-yduck/cluster-api-provider-proxmox/api/v1beta1"
28-
"github.com/sp-yduck/proxmox/pkg/service"
2929
)
3030

3131
type ClusterScopeParams struct {
@@ -110,7 +110,7 @@ func (s *ClusterScope) Storage() infrav1.Storage {
110110
return s.ProxmoxCluster.Spec.Storage
111111
}
112112

113-
func (s *ClusterScope) CloudClient() *service.Service {
113+
func (s *ClusterScope) CloudClient() *proxmox.Service {
114114
return s.ProxmoxServices.Compute
115115
}
116116

cloud/scope/machine.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121

2222
"github.com/pkg/errors"
23+
"github.com/sp-yduck/proxmox-go/proxmox"
2324
corev1 "k8s.io/api/core/v1"
2425
"k8s.io/apimachinery/pkg/types"
2526
"k8s.io/utils/pointer"
@@ -31,7 +32,6 @@ import (
3132

3233
infrav1 "github.com/sp-yduck/cluster-api-provider-proxmox/api/v1beta1"
3334
"github.com/sp-yduck/cluster-api-provider-proxmox/cloud/providerid"
34-
"github.com/sp-yduck/proxmox/pkg/service"
3535
)
3636

3737
type MachineScopeParams struct {
@@ -78,7 +78,7 @@ type MachineScope struct {
7878
ClusterGetter *ClusterScope
7979
}
8080

81-
func (m *MachineScope) CloudClient() *service.Service {
81+
func (m *MachineScope) CloudClient() *proxmox.Service {
8282
return m.ClusterGetter.CloudClient()
8383
}
8484

cloud/services/compute/instance/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package instance
22

33
import (
4-
"github.com/sp-yduck/proxmox/pkg/service"
4+
"github.com/sp-yduck/proxmox-go/proxmox"
55

66
"github.com/sp-yduck/cluster-api-provider-proxmox/cloud"
77
"github.com/sp-yduck/cluster-api-provider-proxmox/cloud/scope"
@@ -13,7 +13,7 @@ type Scope interface {
1313

1414
type Service struct {
1515
scope Scope
16-
client service.Service
16+
client proxmox.Service
1717
remote scope.SSHClient
1818
}
1919

cloud/services/compute/storage/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package storage
22

33
import (
4-
"github.com/sp-yduck/proxmox/pkg/service"
4+
"github.com/sp-yduck/proxmox-go/proxmox"
55

66
"github.com/sp-yduck/cluster-api-provider-proxmox/cloud"
77
)
@@ -12,7 +12,7 @@ type Scope interface {
1212

1313
type Service struct {
1414
scope Scope
15-
client service.Service
15+
client proxmox.Service
1616
}
1717

1818
func NewService(s Scope) *Service {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require (
88
github.com/onsi/gomega v1.27.8
99
github.com/pkg/errors v0.9.1
1010
github.com/sp-yduck/proxmox v0.0.0-20230702124708-d086ca37fd8f
11+
github.com/sp-yduck/proxmox-go v0.0.0-alpha4
1112
golang.org/x/crypto v0.11.0
1213
gopkg.in/yaml.v3 v3.0.1
1314
k8s.io/api v0.26.1
@@ -54,7 +55,6 @@ require (
5455
github.com/prometheus/common v0.37.0 // indirect
5556
github.com/prometheus/procfs v0.8.0 // indirect
5657
github.com/spf13/pflag v1.0.5 // indirect
57-
github.com/stretchr/testify v1.8.2 // indirect
5858
go.uber.org/atomic v1.9.0 // indirect
5959
go.uber.org/multierr v1.8.0 // indirect
6060
go.uber.org/zap v1.24.0 // indirect

go.sum

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
290290
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
291291
github.com/sp-yduck/proxmox v0.0.0-20230702124708-d086ca37fd8f h1:n32eSWqWLtjk+jb4B1Ok+W5KoAxuYuouEkXjumqySXI=
292292
github.com/sp-yduck/proxmox v0.0.0-20230702124708-d086ca37fd8f/go.mod h1:VIKtGZXlx0nO9Y+K2vJ4z3rJLkZ3v0OvTnKbO22EnL4=
293+
github.com/sp-yduck/proxmox-go v0.0.0-alpha4 h1:z4S3zc/mGBvthz4gjP9Dj4SEzXnEgyDz9dPNimfB8vs=
294+
github.com/sp-yduck/proxmox-go v0.0.0-alpha4/go.mod h1:hrQc1bUUCN71yn+in+LkfdpJstaaMv2nrn3+GeKFbkA=
293295
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
294296
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
295297
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
@@ -309,8 +311,7 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
309311
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
310312
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
311313
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
312-
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
313-
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
314+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
314315
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
315316
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
316317
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=

0 commit comments

Comments
 (0)