scope

package
v0.0.0-...-27157f3 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const ProviderPrefix = "microvm://"

Variables

View Source
var (
	// ErrEmptyProviderID means that the provider id is empty.
	//
	// Deprecated: This var is going to be removed in a future release.
	ErrEmptyProviderID = errors.New("providerID is empty")

	// ErrInvalidProviderID means that the provider id has an invalid form.
	//
	// Deprecated: This var is going to be removed in a future release.
	ErrInvalidProviderID = errors.New("providerID must be of the form <cloudProvider>://<optional>/<segments>/<provider id>")
)

Copied from https://github.com/kubernetes-sigs/cluster-api/blob/bda002f52575eeaff68da1ba33c8ef27d5b1014c/controllers/noderefutil/providerid.go As this is removed by https://github.com/kubernetes-sigs/cluster-api/pull/9136

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

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

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

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

func (*MachineScope) GetMicrovmSpec

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

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

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 ProviderID

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

ProviderID is a struct representation of a Kubernetes ProviderID. Format: cloudProvider://optional/segments/etc/id

func NewProviderID

func NewProviderID(id string) (*ProviderID, error)

NewProviderID parses the input string and returns a new ProviderID.

func (*ProviderID) CloudProvider deprecated

func (p *ProviderID) CloudProvider() string

CloudProvider returns the cloud provider portion of the ProviderID.

Deprecated: This method is going to be removed in a future release.

func (*ProviderID) Equals deprecated

func (p *ProviderID) Equals(o *ProviderID) bool

Equals returns true if this ProviderID string matches another ProviderID string.

Deprecated: This method is going to be removed in a future release.

func (*ProviderID) ID deprecated

func (p *ProviderID) ID() string

ID returns the identifier portion of the ProviderID.

Deprecated: This method is going to be removed in a future release.

func (*ProviderID) IndexKey deprecated

func (p *ProviderID) IndexKey() string

IndexKey returns the required level of uniqueness to represent and index machines uniquely from their node providerID.

Deprecated: This method is going to be removed in a future release.

func (ProviderID) String deprecated

func (p ProviderID) String() string

String returns the string representation of this object.

Deprecated: This method is going to be removed in a future release.

func (*ProviderID) Validate deprecated

func (p *ProviderID) Validate() bool

Validate returns true if the provider id is valid.

Deprecated: This method is going to be removed in a future release.

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