Skip to content

Commit a09d23d

Browse files
committed
refactor: SetProviderID()
1 parent 8552fea commit a09d23d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

cloud/interfaces.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55

66
"github.com/sp-yduck/proxmox/pkg/service"
7-
"github.com/sp-yduck/proxmox/pkg/service/node/vm"
87
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
98

109
infrav1 "github.com/sp-yduck/cluster-api-provider-proxmox/api/v1beta1"
@@ -55,6 +54,7 @@ type MachineGetter interface {
5554
// ControlPlaneGroupName() string
5655
NodeName() string
5756
GetInstanceID() *string
57+
GetImage() infrav1.Image
5858
GetProviderID() string
5959
GetBootstrapData() (string, error)
6060
GetInstanceStatus() *infrav1.InstanceStatus
@@ -66,7 +66,7 @@ type MachineGetter interface {
6666

6767
// MachineSetter is an interface which can set machine information.
6868
type MachineSetter interface {
69-
SetProviderID(instance *vm.VirtualMachine) error
69+
SetProviderID(node string, vmid int) error
7070
SetInstanceStatus(v infrav1.InstanceStatus)
7171
SetNodeName(name string)
7272
// SetFailureMessage(v error)

cloud/scope/machine.go

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

2222
"github.com/pkg/errors"
23-
"github.com/sp-yduck/proxmox/pkg/service/node/vm"
2423
corev1 "k8s.io/api/core/v1"
2524
"k8s.io/apimachinery/pkg/types"
2625
"k8s.io/utils/pointer"
@@ -159,6 +158,10 @@ func (m *MachineScope) GetProviderID() string {
159158
return ""
160159
}
161160

161+
func (m *MachineScope) GetImage() infrav1.Image {
162+
return m.ProxmoxMachine.Spec.Image
163+
}
164+
162165
func (m *MachineScope) GetCloudInit() infrav1.CloudInit {
163166
return m.ProxmoxMachine.Spec.CloudInit
164167
}
@@ -179,8 +182,8 @@ func (m *MachineScope) GetHardware() infrav1.Hardware {
179182
}
180183

181184
// SetProviderID sets the ProxmoxMachine providerID in spec.
182-
func (m *MachineScope) SetProviderID(instance *vm.VirtualMachine) error {
183-
providerid, err := providerid.New(instance.Node.Name(), instance.VMID)
185+
func (m *MachineScope) SetProviderID(node string, vmid int) error {
186+
providerid, err := providerid.New(node, vmid)
184187
if err != nil {
185188
return err
186189
}

cloud/services/compute/instance/reconcile.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ func (s *Service) Reconcile(ctx context.Context) error {
2929
}
3030
log.Info(fmt.Sprintf("instance : %v", instance))
3131

32-
s.scope.SetProviderID(instance)
32+
s.scope.SetProviderID(instance.Node.Name(), instance.VMID)
3333
s.scope.SetInstanceStatus(infrav1.InstanceStatus(instance.Status))
34+
// s.scope.SetAddresses()
3435
return nil
3536
}
3637

0 commit comments

Comments
 (0)