scope

package
v1.0.0-alpha.6 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package scope defines cluster and machine scope as well as a repository for the Hetzner API

Index

Constants

This section is empty.

Variables

View Source
var ErrBootstrapDataNotReady = errors.New("error retrieving bootstrap data: linked Machine's bootstrap.dataSecretName is nil")

ErrBootstrapDataNotReady return an error if no bootstrap data is ready.

View Source
var ErrFailureDomainNotFound = errors.New("error no failure domain available")

ErrFailureDomainNotFound returns an error if no region is found.

Functions

func IsControlPlaneReady

func IsControlPlaneReady(ctx context.Context, c clientcmd.ClientConfig) error

IsControlPlaneReady returns if a machine is a control-plane.

Types

type ClusterScope

type ClusterScope struct {
	logr.Logger
	Client client.Client

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

ClusterScope defines the basic context for an actuator to operate upon.

func NewClusterScope

func NewClusterScope(ctx context.Context, params ClusterScopeParams) (*ClusterScope, error)

NewClusterScope creates a new Scope from the supplied parameters. This is meant to be called for each reconcile iteration.

func (*ClusterScope) ClientConfig

func (s *ClusterScope) ClientConfig(ctx context.Context) (clientcmd.ClientConfig, error)

ClientConfig return a kubernetes client config for the cluster context.

func (*ClusterScope) ClientConfigWithAPIEndpoint

func (s *ClusterScope) ClientConfigWithAPIEndpoint(ctx context.Context, endpoint clusterv1.APIEndpoint) (clientcmd.ClientConfig, error)

ClientConfigWithAPIEndpoint returns a client config.

func (*ClusterScope) Close

func (s *ClusterScope) Close(ctx context.Context) error

Close closes the current scope persisting the cluster configuration and status.

func (*ClusterScope) ControlPlaneAPIEndpointPort

func (s *ClusterScope) ControlPlaneAPIEndpointPort() int32

ControlPlaneAPIEndpointPort returns the Port of the Kube-api server.

func (*ClusterScope) GetSpecRegion

func (s *ClusterScope) GetSpecRegion() []infrav1.Region

GetSpecRegion returns a region.

func (*ClusterScope) HCloudClient

func (s *ClusterScope) HCloudClient() HCloudClient

HCloudClient gives a hcloud client.

func (*ClusterScope) ListMachines

func (s *ClusterScope) ListMachines(ctx context.Context) ([]*clusterv1.Machine, []*infrav1.HCloudMachine, error)

ListMachines returns HCloudMachines.

func (*ClusterScope) Name

func (s *ClusterScope) Name() string

Name returns the HetznerCluster name.

func (*ClusterScope) Namespace

func (s *ClusterScope) Namespace() string

Namespace returns the namespace name.

func (*ClusterScope) PatchObject

func (s *ClusterScope) PatchObject(ctx context.Context) error

PatchObject persists the machine spec and status.

func (*ClusterScope) SetStatusFailureDomain

func (s *ClusterScope) SetStatusFailureDomain(regions []infrav1.Region)

SetStatusFailureDomain sets the region for the status.

type ClusterScopeParams

type ClusterScopeParams struct {
	HCloudClient

	HCloudClientFactory HCloudClientFactory
	Client              client.Client
	Logger              logr.Logger
	Cluster             *clusterv1.Cluster
	HetznerCluster      *infrav1.HetznerCluster
}

ClusterScopeParams defines the input parameters used to create a new scope.

type HCloudClient

type HCloudClient interface {
	Token() string
	ListLocation(context.Context) ([]*hcloud.Location, error)
	CreateLoadBalancer(context.Context, hcloud.LoadBalancerCreateOpts) (hcloud.LoadBalancerCreateResult, *hcloud.Response, error)
	DeleteLoadBalancer(context.Context, int) (*hcloud.Response, error)
	GetLoadBalancer(context.Context, int) (*hcloud.LoadBalancer, *hcloud.Response, error)
	ListLoadBalancers(context.Context, hcloud.LoadBalancerListOpts) ([]*hcloud.LoadBalancer, error)
	AttachLoadBalancerToNetwork(context.Context, *hcloud.LoadBalancer, hcloud.LoadBalancerAttachToNetworkOpts) (*hcloud.Action, *hcloud.Response, error)
	ChangeLoadBalancerType(context.Context, *hcloud.LoadBalancer, hcloud.LoadBalancerChangeTypeOpts) (*hcloud.Action, *hcloud.Response, error)
	ChangeLoadBalancerAlgorithm(context.Context, *hcloud.LoadBalancer, hcloud.LoadBalancerChangeAlgorithmOpts) (*hcloud.Action, *hcloud.Response, error)
	UpdateLoadBalancer(context.Context, *hcloud.LoadBalancer, hcloud.LoadBalancerUpdateOpts) (*hcloud.LoadBalancer, *hcloud.Response, error)
	AddTargetServerToLoadBalancer(context.Context, hcloud.LoadBalancerAddServerTargetOpts, *hcloud.LoadBalancer) (*hcloud.Action, *hcloud.Response, error)
	DeleteTargetServerOfLoadBalancer(context.Context, *hcloud.LoadBalancer, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)
	AddServiceToLoadBalancer(context.Context, *hcloud.LoadBalancer, hcloud.LoadBalancerAddServiceOpts) (*hcloud.Action, *hcloud.Response, error)
	DeleteServiceFromLoadBalancer(context.Context, *hcloud.LoadBalancer, int) (*hcloud.Action, *hcloud.Response, error)
	ListImages(context.Context, hcloud.ImageListOpts) ([]*hcloud.Image, error)
	CreateServer(context.Context, hcloud.ServerCreateOpts) (hcloud.ServerCreateResult, *hcloud.Response, error)
	AttachServerToNetwork(context.Context, *hcloud.Server, hcloud.ServerAttachToNetworkOpts) (*hcloud.Action, *hcloud.Response, error)
	ListServers(context.Context, hcloud.ServerListOpts) ([]*hcloud.Server, error)
	GetServerByID(context.Context, int) (*hcloud.Server, *hcloud.Response, error)
	DeleteServer(context.Context, *hcloud.Server) (*hcloud.Response, error)
	PowerOnServer(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)
	ShutdownServer(context.Context, *hcloud.Server) (*hcloud.Action, *hcloud.Response, error)
	CreateNetwork(context.Context, hcloud.NetworkCreateOpts) (*hcloud.Network, *hcloud.Response, error)
	GetNetwork(context.Context, int) (*hcloud.Network, *hcloud.Response, error)
	ListNetworks(context.Context, hcloud.NetworkListOpts) ([]*hcloud.Network, error)
	DeleteNetwork(context.Context, *hcloud.Network) (*hcloud.Response, error)
	ListSSHKeys(ctx context.Context, opts hcloud.SSHKeyListOpts) ([]*hcloud.SSHKey, *hcloud.Response, error)
	CreatePlacementGroup(context.Context, hcloud.PlacementGroupCreateOpts) (hcloud.PlacementGroupCreateResult, *hcloud.Response, error)
	DeletePlacementGroup(context.Context, int) (*hcloud.Response, error)
	GetPlacementGroup(context.Context, int) (*hcloud.PlacementGroup, *hcloud.Response, error)
	ListPlacementGroups(context.Context, hcloud.PlacementGroupListOpts) ([]*hcloud.PlacementGroup, error)
	AddServerToPlacementGroup(context.Context, *hcloud.Server, *hcloud.PlacementGroup) (*hcloud.Action, *hcloud.Response, error)
}

HCloudClient collects all methods used by the controller in the hcloud cloud API.

type HCloudClientFactory

type HCloudClientFactory func(context.Context) (HCloudClient, error)

HCloudClientFactory implements a factory function for HCloudClient repository.

type MachineScope

type MachineScope struct {
	ClusterScope
	Machine       *clusterv1.Machine
	HCloudMachine *infrav1.HCloudMachine
}

MachineScope defines the basic context for an actuator to operate upon.

func NewMachineScope

func NewMachineScope(ctx context.Context, params MachineScopeParams) (*MachineScope, error)

NewMachineScope creates a new Scope from the supplied parameters. This is meant to be called for each reconcile iteration.

func (*MachineScope) Close

func (m *MachineScope) Close(ctx context.Context) error

Close closes the current scope persisting the cluster configuration and status.

func (*MachineScope) GetFailureDomain

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

GetFailureDomain returns the machine's failure domain or a default one based on a hash.

func (*MachineScope) GetRawBootstrapData

func (m *MachineScope) GetRawBootstrapData(ctx context.Context) ([]byte, error)

GetRawBootstrapData returns the bootstrap data from the secret in the Machine's bootstrap.dataSecretName.

func (*MachineScope) IsBootstrapDataReady

func (m *MachineScope) IsBootstrapDataReady(ctx context.Context) bool

IsBootstrapDataReady checks the readiness of a capi machine's bootstrap data.

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 HCloudMachine name.

func (*MachineScope) Namespace

func (m *MachineScope) Namespace() string

Namespace returns the namespace name.

func (*MachineScope) PatchObject

func (m *MachineScope) PatchObject(ctx context.Context) error

PatchObject persists the machine spec and status.

type MachineScopeParams

type MachineScopeParams struct {
	ClusterScopeParams
	Machine       *clusterv1.Machine
	HCloudMachine *infrav1.HCloudMachine
}

MachineScopeParams defines the input parameters used to create a new Scope.

Jump to

Keyboard shortcuts

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