scope

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const ProviderPrefix = "microvm://"

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterScope

type ClusterScope struct {
	logr.Logger

	Cluster    *clusterv1.Cluster
	MvmCluster *infrav1.MicrovmCluster
	// contains filtered or unexported fields
}

ClusterScope is the scope for reconciling a cluster.

func NewClusterScope

func NewClusterScope(cluster *clusterv1.Cluster,
	microvmCluster *infrav1.MicrovmCluster,
	client client.Client, opts ...ClusterScopeOption,
) (*ClusterScope, error)

func (*ClusterScope) Close

func (cs *ClusterScope) Close() error

Close closes the current scope persisting the resource and status.

func (*ClusterScope) ClusterName

func (cs *ClusterScope) ClusterName() string

ClusterName returns the name of the cluster.

func (*ClusterScope) ControllerName

func (cs *ClusterScope) ControllerName() string

ControllerName returns the name of the controller that created the scope.

func (*ClusterScope) Name

func (cs *ClusterScope) Name() string

Name returns the name of the resource.

func (*ClusterScope) Namespace

func (cs *ClusterScope) Namespace() string

Namespace returns the resources namespace.

func (*ClusterScope) Patch

func (cs *ClusterScope) Patch() error

Patch persists the resource and status.

func (*ClusterScope) Placement

func (cs *ClusterScope) Placement() infrav1.Placement

Placement is used to get the placement configuration for the cluster.

type ClusterScopeOption

type ClusterScopeOption func(*ClusterScope)

func WithClusterControllerName

func WithClusterControllerName(name string) ClusterScopeOption

func WithClusterLogger

func WithClusterLogger(logger logr.Logger) ClusterScopeOption

type MachineScope

type MachineScope struct {
	logr.Logger

	Cluster    *clusterv1.Cluster
	MvmCluster *infrav1.MicrovmCluster

	Machine    *clusterv1.Machine
	MvmMachine *infrav1.MicrovmMachine
	// contains filtered or unexported fields
}

func NewMachineScope

func NewMachineScope(params MachineScopeParams, opts ...MachineScopeOption) (*MachineScope, error)

func (*MachineScope) ClusterName

func (m *MachineScope) ClusterName() string

ClusterName returns the name of the cluster.

func (*MachineScope) ControllerName

func (m *MachineScope) ControllerName() string

ControllerName returns the name of the controller that created the scope.

func (*MachineScope) GetBasicAuthToken added in v0.6.0

func (m *MachineScope) GetBasicAuthToken(addr string) (string, error)

GetBasicAuthToken will fetch the BasicAuthSecret on the MvmCluster and and return the token for the given host. If no secret or no value is found, an empty string is returned.

func (*MachineScope) GetFailureDomain

func (m *MachineScope) GetFailureDomain() (string, error)

func (*MachineScope) GetInstanceID

func (m *MachineScope) GetInstanceID() string

GetInstanceID gets the instance ID (i.e. UID) of the machine.

func (*MachineScope) GetLabels added in v0.8.0

func (m *MachineScope) GetLabels() map[string]string

GetLabels returns any user defined or default labels for the microvm.

func (*MachineScope) GetMicrovmSpec added in v0.8.0

func (m *MachineScope) GetMicrovmSpec() microvm.VMSpec

GetMicrovmSpec returns the spec for the MicroVM.

func (*MachineScope) GetProviderID

func (m *MachineScope) GetProviderID() string

GetProviderID returns the provider if for the machine. If there is no provider id then an empty string will be returned.

func (*MachineScope) GetRawBootstrapData

func (m *MachineScope) GetRawBootstrapData() (string, error)

GetRawBootstrapData will return the contents of the secret that has been created by the bootstrap provider that is being used for this cluster/machine. Initially this we will be using the Kubeadm bootstrap provider and so this will contain cloud-init configuration that will invoke kubeadm to create or join a cluster.

func (*MachineScope) GetSSHPublicKeys added in v0.6.0

func (m *MachineScope) GetSSHPublicKeys() []microvm.SSHPublicKey

GetSSHPublicKeys will return the SSH public keys for this machine. It will take into account precedence rules. If there are no keys then nil will be returned.

func (*MachineScope) GetTLSConfig added in v0.6.0

func (m *MachineScope) GetTLSConfig() (*flclient.TLSConfig, error)

GetTLSConfig will fetch the TLSSecretRef and CASecretRef on the MvmCluster and return the TLS config for the client. If either are not set, it will be assumed that the hosts are not configured will TLS and all client calls will be made without credentials.

func (*MachineScope) IsControlPlane

func (m *MachineScope) IsControlPlane() bool

IsControlPlane returns true if the machine is a control plane.

func (*MachineScope) Name

func (m *MachineScope) Name() string

Name returns the MicrovmMachine name.

func (*MachineScope) Namespace

func (m *MachineScope) Namespace() string

Namespace returns the namespace name.

func (*MachineScope) Patch

func (m *MachineScope) Patch() error

Patch persists the resource and status.

func (*MachineScope) SetNotReady

func (m *MachineScope) SetNotReady(
	reason string,
	severity clusterv1.ConditionSeverity,
	message string,
	messageArgs ...interface{},
)

SetNotReady sets any properties/conditions that are used to indicate that the MicrovmMachine is NOT 'Ready' back to the upstream CAPI machine controllers.

func (*MachineScope) SetProviderID

func (m *MachineScope) SetProviderID(failureDomain, mvmUID string)

SetProviderID saves the unique microvm and object ID to the MvmMachine spec.

func (*MachineScope) SetReady

func (m *MachineScope) SetReady()

SetReady sets any properties/conditions that are used to indicate that the MicrovmMachine is 'Ready' back to the upstream CAPI machine controllers.

type MachineScopeOption

type MachineScopeOption func(*MachineScope)

func WithMachineControllerName

func WithMachineControllerName(name string) MachineScopeOption

func WithMachineLogger

func WithMachineLogger(logger logr.Logger) MachineScopeOption

type MachineScopeParams

type MachineScopeParams struct {
	Cluster        *clusterv1.Cluster
	MicroVMCluster *infrav1.MicrovmCluster

	Machine        *clusterv1.Machine
	MicroVMMachine *infrav1.MicrovmMachine

	Client  client.Client
	Context context.Context //nolint: containedctx // don't care
}

type Scoper

type Scoper interface {
	// Name returns the name of the resource.
	Name() string
	// Namespace returns the resources namespace.
	Namespace() string
	// ClusterName returns the name of the cluster.
	ClusterName() string

	// ControllerName returns the name of the controller that created the scope.
	ControllerName() string

	// Patch persists the resource and status.
	Patch() error
}

Scoper is the interface for a scope.

Jump to

Keyboard shortcuts

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