Help us shape the future of Go! Take the 2026 Go Developer Survey

driver

package
v1.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2023 License: Apache-2.0, BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package driver contains the cloud provider specific implementations to manage machines

Package driver contains a fake driver implementation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateMachineRequest

type CreateMachineRequest struct {
	// Machine object from whom VM is to be created
	Machine *v1alpha1.Machine

	// MachineClass backing the machine object
	MachineClass *v1alpha1.MachineClass

	//  Secret backing the machineClass object
	Secret *corev1.Secret
}

CreateMachineRequest is the create request for VM creation

type CreateMachineResponse

type CreateMachineResponse struct {
	// ProviderID is the unique identification of the VM at the cloud provider.
	// ProviderID typically matches with the node.Spec.ProviderID on the node object.
	// Eg: gce://project-name/region/vm-ID
	ProviderID string

	// NodeName is the name of the node-object registered to kubernetes.
	NodeName string

	// LastKnownState represents the last state of the VM during an creation/deletion error
	LastKnownState string
}

CreateMachineResponse is the create response for VM creation

type DeleteMachineRequest

type DeleteMachineRequest struct {
	// Machine object from whom VM is to be deleted
	Machine *v1alpha1.Machine

	// MachineClass backing the machine object
	MachineClass *v1alpha1.MachineClass

	// Secret backing the machineClass object
	Secret *corev1.Secret
}

DeleteMachineRequest is the delete request for VM deletion

type DeleteMachineResponse

type DeleteMachineResponse struct {
	// LastKnownState represents the last state of the VM during an creation/deletion error
	LastKnownState string
}

DeleteMachineResponse is the delete response for VM deletion

type Driver

type Driver interface {
	// CreateMachine call is responsible for VM creation on the provider
	CreateMachine(context.Context, *CreateMachineRequest) (*CreateMachineResponse, error)
	// DeleteMachine call is responsible for VM deletion/termination on the provider
	DeleteMachine(context.Context, *DeleteMachineRequest) (*DeleteMachineResponse, error)
	// GetMachineStatus call get's the status of the VM backing the machine object on the provider
	GetMachineStatus(context.Context, *GetMachineStatusRequest) (*GetMachineStatusResponse, error)
	// ListMachines lists all the machines that might have been created by the supplied machineClass
	ListMachines(context.Context, *ListMachinesRequest) (*ListMachinesResponse, error)
	// GetVolumeIDs returns a list volumeIDs for the list of PVSpecs
	GetVolumeIDs(context.Context, *GetVolumeIDsRequest) (*GetVolumeIDsResponse, error)
	// GenerateMachineClassForMigration returns the generic machineClass for provider specific machine class CR
	// e.g. AWSMachineClass --> MachineClass
	GenerateMachineClassForMigration(context.Context, *GenerateMachineClassForMigrationRequest) (*GenerateMachineClassForMigrationResponse, error)
}

Driver is the common interface for creation/deletion of the VMs over different cloud-providers.

func NewFakeDriver

func NewFakeDriver(fakeDriver *FakeDriver) Driver

NewFakeDriver returns a new fakedriver object

type FakeDriver

type FakeDriver struct {
	VMExists       bool
	ProviderID     string
	NodeName       string
	LastKnownState string
	Err            error
}

FakeDriver is a fake driver returned when none of the actual drivers match

func (*FakeDriver) CreateMachine

func (d *FakeDriver) CreateMachine(ctx context.Context, createMachineRequest *CreateMachineRequest) (*CreateMachineResponse, error)

CreateMachine makes a call to the driver to create the machine.

func (*FakeDriver) DeleteMachine

func (d *FakeDriver) DeleteMachine(ctx context.Context, deleteMachineRequest *DeleteMachineRequest) (*DeleteMachineResponse, error)

DeleteMachine make a call to the driver to delete the machine.

func (*FakeDriver) GenerateMachineClassForMigration

GenerateMachineClassForMigration converts providerMachineClass to (generic)MachineClass

func (*FakeDriver) GetMachineStatus

func (d *FakeDriver) GetMachineStatus(ctx context.Context, getMachineStatusRequest *GetMachineStatusRequest) (*GetMachineStatusResponse, error)

GetMachineStatus makes a gRPC call to the driver to check existance of machine

func (*FakeDriver) GetVolumeIDs

func (d *FakeDriver) GetVolumeIDs(ctx context.Context, getVolumeIDs *GetVolumeIDsRequest) (*GetVolumeIDsResponse, error)

GetVolumeIDs returns a list of VolumeIDs for the PV spec list supplied

func (*FakeDriver) ListMachines

func (d *FakeDriver) ListMachines(ctx context.Context, listMachinesRequest *ListMachinesRequest) (*ListMachinesResponse, error)

ListMachines have to list machines

type GenerateMachineClassForMigrationRequest

type GenerateMachineClassForMigrationRequest struct {
	// ProviderSpecificMachineClass is provider specfic machine class object.
	// E.g. AWSMachineClass
	ProviderSpecificMachineClass interface{}
	// MachineClass is the machine class object generated that is to be filled up
	MachineClass *v1alpha1.MachineClass
	// ClassSpec contains the class spec object to determine the machineClass kind
	ClassSpec *v1alpha1.ClassSpec
}

GenerateMachineClassForMigrationRequest is the request for generating the generic machineClass for the provider specific machine class

type GenerateMachineClassForMigrationResponse

type GenerateMachineClassForMigrationResponse struct{}

GenerateMachineClassForMigrationResponse is the response for generating the generic machineClass for the provider specific machine class

type GetMachineStatusRequest

type GetMachineStatusRequest struct {
	// Machine object from whom VM status is to be fetched
	Machine *v1alpha1.Machine

	// MachineClass backing the machine object
	MachineClass *v1alpha1.MachineClass

	//  Secret backing the machineClass object
	Secret *corev1.Secret
}

GetMachineStatusRequest is the get request for VM info

type GetMachineStatusResponse

type GetMachineStatusResponse struct {
	// ProviderID is the unique identification of the VM at the cloud provider.
	// ProviderID typically matches with the node.Spec.ProviderID on the node object.
	// Eg: gce://project-name/region/vm-ID
	ProviderID string

	// NodeName is the name of the node-object registered to kubernetes.
	NodeName string
}

GetMachineStatusResponse is the get response for VM info

type GetVolumeIDsRequest

type GetVolumeIDsRequest struct {
	// PVSpecsList is a list of PV specs for whom volume-IDs are required
	// Plugin should parse this raw data into pre-defined list of PVSpecs
	PVSpecs []*corev1.PersistentVolumeSpec
}

GetVolumeIDsRequest is the request object to get a list of VolumeIDs for a PVSpec

type GetVolumeIDsResponse

type GetVolumeIDsResponse struct {
	// VolumeIDs is a list of VolumeIDs.
	VolumeIDs []string
}

GetVolumeIDsResponse is the response object of the list of VolumeIDs for a PVSpec

type ListMachinesRequest

type ListMachinesRequest struct {
	// MachineClass object
	MachineClass *v1alpha1.MachineClass

	// Secret backing the machineClass object
	Secret *corev1.Secret
}

ListMachinesRequest is the request object to get a list of VMs belonging to a machineClass

type ListMachinesResponse

type ListMachinesResponse struct {
	// MachineList is the map of list of machines. Format for the map should be <ProviderID, MachineName>.
	MachineList map[string]string
}

ListMachinesResponse is the response object of the list of VMs belonging to a machineClass

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL