scope

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package scope defines the provider scopes for reconciliation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	Locker       *locker.Locker
	Cluster      *clusterv1.Cluster
	IonosCluster *infrav1.IonosCloudCluster
	// contains filtered or unexported fields
}

Cluster defines a basic cluster context for primary use in IonosCloudClusterReconciler.

func NewCluster

func NewCluster(params ClusterParams) (*Cluster, error)

NewCluster creates a new cluster scope with the supplied parameters. This is meant to be called on each reconciliation.

func (*Cluster) DeleteCurrentRequestByDatacenter

func (c *Cluster) DeleteCurrentRequestByDatacenter(datacenterID string)

DeleteCurrentRequestByDatacenter deletes the current provisioning request for the given data center.

func (*Cluster) Finalize

func (c *Cluster) Finalize() error

Finalize will make sure to apply a patch to the current IonosCloudCluster. It also implements a retry mechanism to increase the chance of success in case the patch operation was not successful.

func (*Cluster) GetControlPlaneEndpoint

func (c *Cluster) GetControlPlaneEndpoint() clusterv1.APIEndpoint

GetControlPlaneEndpoint returns the endpoint for the IonosCloudCluster.

func (*Cluster) GetControlPlaneEndpointIP

func (c *Cluster) GetControlPlaneEndpointIP(ctx context.Context) (string, error)

GetControlPlaneEndpointIP returns the endpoint IP for the IonosCloudCluster. If the endpoint host is unset (neither an IP nor an FQDN), it will return an empty string.

func (*Cluster) GetCurrentRequestByDatacenter

func (c *Cluster) GetCurrentRequestByDatacenter(datacenterID string) (infrav1.ProvisioningRequest, bool)

GetCurrentRequestByDatacenter returns the current provisioning request for the given data center and a boolean indicating if it exists.

func (*Cluster) IsDeleted

func (c *Cluster) IsDeleted() bool

IsDeleted checks if the cluster was requested for deletion.

func (*Cluster) ListMachines

func (c *Cluster) ListMachines(
	ctx context.Context,
	machineLabels client.MatchingLabels,
) ([]infrav1.IonosCloudMachine, error)

ListMachines returns a list of IonosCloudMachines in the same namespace and with the same cluster label. With machineLabels, additional search labels can be provided.

func (*Cluster) Location

func (c *Cluster) Location() string

Location is a shortcut for getting the location used by the IONOS Cloud cluster IP block.

func (*Cluster) PatchObject

func (c *Cluster) PatchObject() error

PatchObject will apply all changes from the IonosCloudCluster. It will also make sure to patch the status subresource.

func (*Cluster) SetControlPlaneEndpointIPBlockID

func (c *Cluster) SetControlPlaneEndpointIPBlockID(id string)

SetControlPlaneEndpointIPBlockID sets the IP block ID in the IonosCloudCluster status.

func (*Cluster) SetCurrentRequestByDatacenter

func (c *Cluster) SetCurrentRequestByDatacenter(datacenterID, method, status, requestPath string)

SetCurrentRequestByDatacenter sets the current provisioning request for the given data center. This function makes sure that the map is initialized before setting the request.

type ClusterParams

type ClusterParams struct {
	Client       client.Client
	Cluster      *clusterv1.Cluster
	IonosCluster *infrav1.IonosCloudCluster
	Locker       *locker.Locker
}

ClusterParams are the parameters, which are used to create a cluster scope.

type Machine

type Machine struct {
	Locker *locker.Locker

	Machine      *clusterv1.Machine
	IonosMachine *infrav1.IonosCloudMachine

	ClusterScope *Cluster
	// contains filtered or unexported fields
}

Machine defines a basic machine context for primary use in IonosCloudMachineReconciler.

func NewMachine

func NewMachine(params MachineParams) (*Machine, error)

NewMachine creates a new Machine using the provided params.

func (*Machine) CountMachines

func (m *Machine) CountMachines(ctx context.Context, machineLabels client.MatchingLabels) (int, error)

CountMachines returns the number of existing IonosCloudMachines in the same namespace and with the same cluster label. With machineLabels, additional search labels can be provided.

func (*Machine) DatacenterID

func (m *Machine) DatacenterID() string

DatacenterID returns the data center ID used by the IonosCloudMachine.

func (*Machine) Finalize

func (m *Machine) Finalize() error

Finalize will make sure to apply a patch to the current IonosCloudMachine. It also implements a retry mechanism to increase the chance of success in case the patch operation was not successful.

func (*Machine) FindLatestMachine

func (m *Machine) FindLatestMachine(
	ctx context.Context,
	matchLabels client.MatchingLabels,
) (*infrav1.IonosCloudMachine, error)

FindLatestMachine returns the latest IonosCloudMachine in the same namespace and with the same cluster label. If no machine was found, nil is returned.

Only machines, that are different to the receiver machine, are considered. If the receiver machine is the only machine in the list, nil is returned.

func (*Machine) GetBootstrapDataSecret

func (m *Machine) GetBootstrapDataSecret(ctx context.Context, log logr.Logger) (*corev1.Secret, error)

GetBootstrapDataSecret returns the bootstrap data secret, which has been created by the Kubeadm provider.

func (*Machine) HasFailed

func (m *Machine) HasFailed() bool

HasFailed checks if the IonosCloudMachine is in a failed state.

func (*Machine) ListMachines

func (m *Machine) ListMachines(
	ctx context.Context,
	machineLabels client.MatchingLabels,
) ([]infrav1.IonosCloudMachine, error)

ListMachines is a convenience wrapper function for the Cluster.ListMachines function.

func (*Machine) PatchObject

func (m *Machine) PatchObject() error

PatchObject will apply all changes from the IonosMachine. It will also make sure to patch the status subresource.

func (*Machine) SetProviderID

func (m *Machine) SetProviderID(id string)

SetProviderID sets the provider ID for the IonosCloudMachine.

type MachineParams

type MachineParams struct {
	Client       client.Client
	Machine      *clusterv1.Machine
	ClusterScope *Cluster
	IonosMachine *infrav1.IonosCloudMachine
	Locker       *locker.Locker
}

MachineParams is a struct that contains the params used to create a new Machine through NewMachine.

Jump to

Keyboard shortcuts

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