core

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProviderName is the kubevirt provider name.
	ProviderName = "kubevirt"
)

Variables

This section is empty.

Functions

func GetClient

func GetClient(secret *corev1.Secret) (client.Client, string, error)

GetClient creates a client from the kubeconfig saved in the "kubeconfig" field of the given secret. It also returns the namespace of the kubeconfig's current context.

func GetServerVersion

func GetServerVersion(secret *corev1.Secret) (string, error)

GetServerVersion gets the server version from the kubeconfig saved in the "kubeconfig" field of the given secret.

func IsMachineNotFoundError

func IsMachineNotFoundError(err error) bool

IsMachineNotFoundError returns true if the given error is a MachineNotFoundError, false otherwise.

Types

type ClientFactory

type ClientFactory interface {
	// GetClient creates a client from the kubeconfig saved in the "kubeconfig" field of the given secret.
	// It also returns the namespace of the kubeconfig's current context.
	GetClient(secret *corev1.Secret) (client.Client, string, error)
}

ClientFactory creates a client from the kubeconfig saved in the "kubeconfig" field of the given secret.

type ClientFactoryFunc

type ClientFactoryFunc func(secret *corev1.Secret) (client.Client, string, error)

ClientFactoryFunc is a function that implements ClientFactory.

func (ClientFactoryFunc) GetClient

func (f ClientFactoryFunc) GetClient(secret *corev1.Secret) (client.Client, string, error)

GetClient creates a client from the kubeconfig saved in the "kubeconfig" field of the given secret. It also returns the namespace of the kubeconfig's current context.

type MachineNotFoundError

type MachineNotFoundError struct {
	// Name is the machine name
	Name string
}

MachineNotFoundError represents a "machine not found" error.

func (*MachineNotFoundError) Error

func (e *MachineNotFoundError) Error() string

type PluginSPIImpl

type PluginSPIImpl struct {
	// contains filtered or unexported fields
}

PluginSPIImpl is the implementation of PluginSPI interface.

func NewPluginSPIImpl

func NewPluginSPIImpl(cf ClientFactory, svf ServerVersionFactory, timer Timer) *PluginSPIImpl

NewPluginSPIImpl creates a new PluginSPIImpl with the given ClientFactory, ServerVersionFactory, and Timer.

func (PluginSPIImpl) CreateMachine

func (p PluginSPIImpl) CreateMachine(ctx context.Context, machineName string, providerSpec *api.KubeVirtProviderSpec, secret *corev1.Secret) (providerID string, err error)

CreateMachine creates a machine with the given name, using the given provider spec and secret. Here it creates a kubevirt virtual machine and a secret containing the userdata (cloud-init).

func (PluginSPIImpl) DeleteMachine

func (p PluginSPIImpl) DeleteMachine(ctx context.Context, machineName, _ string, _ *api.KubeVirtProviderSpec, secret *corev1.Secret) (foundProviderID string, err error)

DeleteMachine deletes the machine with the given name and provider id, using the given provider spec and secret. Here it deletes the kubevirt virtual machine with the given name.

func (PluginSPIImpl) GetMachineStatus

func (p PluginSPIImpl) GetMachineStatus(ctx context.Context, machineName, _ string, _ *api.KubeVirtProviderSpec, secret *corev1.Secret) (foundProviderID string, err error)

GetMachineStatus returns the provider id of the machine with the given name and provider id, using the given provider spec and secret. Here it returns the provider id of the kubevirt virtual machine with the given name.

func (PluginSPIImpl) ListMachines

func (p PluginSPIImpl) ListMachines(ctx context.Context, providerSpec *api.KubeVirtProviderSpec, secret *corev1.Secret) (providerIDList map[string]string, err error)

ListMachines lists all machines matching the given provider spec and secret. Here it lists all kubevirt virtual machines matching the tags of the given provider spec.

func (PluginSPIImpl) ShutDownMachine

func (p PluginSPIImpl) ShutDownMachine(ctx context.Context, machineName, _ string, _ *api.KubeVirtProviderSpec, secret *corev1.Secret) (foundProviderID string, err error)

ShutDownMachine shuts down the machine with the given name and provider id, using the given provider spec and secret. Here it shuts down the kubevirt virtual machine with the given name by setting its spec.running field to false.

type ServerVersionFactory

type ServerVersionFactory interface {
	// GetServerVersion gets the server version from the kubeconfig saved in the "kubeconfig" field of the given secret.
	GetServerVersion(secret *corev1.Secret) (string, error)
}

ServerVersionFactory gets the server version from the kubeconfig saved in the "kubeconfig" field of the given secret.

type ServerVersionFactoryFunc

type ServerVersionFactoryFunc func(secret *corev1.Secret) (string, error)

ServerVersionFactoryFunc is a function that implements ServerVersionFactory.

func (ServerVersionFactoryFunc) GetServerVersion

func (f ServerVersionFactoryFunc) GetServerVersion(secret *corev1.Secret) (string, error)

GetServerVersion gets the server version from the kubeconfig saved in the "kubeconfig" field of the given secret.

type Timer

type Timer interface {
	// Now returns the current local time.
	Now() time.Time
}

Timer returns the current local time.

type TimerFunc

type TimerFunc func() time.Time

TimerFunc is a function that implements Timer.

func (TimerFunc) Now

func (f TimerFunc) Now() time.Time

Now returns the current local time.

Jump to

Keyboard shortcuts

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