scope

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const ProviderIDPrefix = "huaweicloud://"

ProviderIDPrefix is the prefix of ECS resource IDs to form the Kubernetes Provider ID. NOTE: this format matches the 2 slashes format used in cloud-provider and cluster-autoscaler.

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

func GenerateProviderID

func GenerateProviderID(ids ...string) string

GenerateProviderID generates a valid HuaweiCloud Node/Machine ProviderID field.

By default, the last id provided is used as identifier (last part).

func NewECSClient

func NewECSClient(scope ECSScope) (*ecsiface.EcsClient, error)

Types

type ClusterScope

type ClusterScope struct {
	Logger      *logr.Logger
	Cluster     *clusterv1.Cluster
	HCCluster   *infrav1alpha1.HuaweiCloudCluster
	Credentials *basic.Credentials
	// contains filtered or unexported fields
}

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

func NewClusterScope

func NewClusterScope(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) Close

func (s *ClusterScope) Close() error

func (*ClusterScope) ClusterName

func (s *ClusterScope) ClusterName() string

Name returns the CAPI Cluster name.

func (*ClusterScope) CoreCluster

func (s *ClusterScope) CoreCluster() conditions.Setter

CoreCluster returns the core cluster object.

func (*ClusterScope) Credential

func (c *ClusterScope) Credential() auth.ICredential

func (*ClusterScope) ELB

ELB returns the cluster ELB.

func (*ClusterScope) ImageLookupBaseOS

func (c *ClusterScope) ImageLookupBaseOS() string

func (*ClusterScope) ImageLookupFormat

func (c *ClusterScope) ImageLookupFormat() string

func (*ClusterScope) ImageLookupOrg

func (c *ClusterScope) ImageLookupOrg() string

func (*ClusterScope) InfraCluster

func (s *ClusterScope) InfraCluster() conditions.Setter

InfraCluster returns the huaweicloud cluster object.

func (*ClusterScope) Network

func (*ClusterScope) PatchObject

func (s *ClusterScope) PatchObject() error

PatchObject persists the cluster configuration and status.

func (*ClusterScope) Region

func (s *ClusterScope) Region() string

Region returns the cluster region.

func (*ClusterScope) SSHKeyName

func (c *ClusterScope) SSHKeyName() *string

func (*ClusterScope) SecurityGroups

SecurityGroups returns the cluster security groups as a map, it creates the map if empty.

func (*ClusterScope) SetELB

func (s *ClusterScope) SetELB(elb infrav1alpha1.LoadBalancer)

SetELB updates the cluster ELB.

func (*ClusterScope) SetNatGatewaysIPs

func (s *ClusterScope) SetNatGatewaysIPs(ips []string)

SetNatGatewaysIPs sets the Nat Gateways Public IPs.

func (*ClusterScope) SetSecurityGroups

SetSecurityGroups updates the cluster security groups.

func (*ClusterScope) SetSubnets

func (s *ClusterScope) SetSubnets(subnets infrav1alpha1.Subnets)

SetSubnets updates the clusters subnets.

func (*ClusterScope) Subnets

func (s *ClusterScope) Subnets() infrav1alpha1.Subnets

Subnets returns the cluster subnets.

func (*ClusterScope) VPC

VPC returns the cluster VPC.

type ClusterScopeParams

type ClusterScopeParams struct {
	Client      client.Client
	Logger      *logr.Logger
	Cluster     *clusterv1.Cluster
	HCCluster   *infrav1alpha1.HuaweiCloudCluster
	Credentials *basic.Credentials
}

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

type ECSScope

type ECSScope interface {
	basic.ClusterScoper

	// VPC returns the cluster VPC.
	VPC() *infrav1alpha1.VPCSpec

	// Subnets returns the cluster subnets.
	Subnets() infrav1alpha1.Subnets

	// Network returns the cluster network object.
	Network() *infrav1alpha1.NetworkStatus

	// SecurityGroups returns the cluster security groups as a map, it creates the map if empty.
	SecurityGroups() map[infrav1alpha1.SecurityGroupRole]infrav1alpha1.SecurityGroup

	// SSHKeyName returns the SSH key name to use for instances.
	SSHKeyName() *string

	// ImageLookupFormat returns the format string to use when looking up AMIs
	ImageLookupFormat() string

	// ImageLookupOrg returns the organization name to use when looking up AMIs
	ImageLookupOrg() string

	// ImageLookupBaseOS returns the base operating system name to use when looking up AMIs
	ImageLookupBaseOS() string
}

ECSScope is the interface for the scope to be used with the ecs service.

type MachineScope

type MachineScope struct {
	Logger logr.Logger

	Cluster      *clusterv1.Cluster
	Machine      *clusterv1.Machine
	InfraCluster ECSScope
	HCMachine    *infrav1.HuaweiCloudMachine
	Credentials  *basic.Credentials
	// contains filtered or unexported fields
}

MachineScope defines a scope defined around a machine and its cluster.

func NewMachineScope

func NewMachineScope(params MachineScopeParams) (*MachineScope, error)

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

func (*MachineScope) Close

func (m *MachineScope) Close() error

Close the MachineScope by updating the machine spec, machine status.

func (*MachineScope) GetBootstrapData

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

GetBootstrapData returns the bootstrap data from the secret in the Machine's bootstrap.dataSecretName as base64.

func (*MachineScope) GetCredentials added in v0.1.0

func (m *MachineScope) GetCredentials() *basic.Credentials

func (*MachineScope) GetInstanceID

func (m *MachineScope) GetInstanceID() *string

GetInstanceID returns the HuaweiCloudMachine instance id by parsing Spec.ProviderID.

func (*MachineScope) GetInstanceState

func (m *MachineScope) GetInstanceState() *infrav1.InstanceState

GetInstanceState returns the HuaweiCloudMachine instance state from the status.

func (*MachineScope) GetProviderID

func (m *MachineScope) GetProviderID() string

GetProviderID returns the HuaweiCloudMachine providerID from the spec.

func (*MachineScope) GetRawBootstrapData

func (m *MachineScope) GetRawBootstrapData() ([]byte, error)

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

func (*MachineScope) GetRawBootstrapDataWithFormat

func (m *MachineScope) GetRawBootstrapDataWithFormat() ([]byte, string, error)

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

func (*MachineScope) HasFailed

func (m *MachineScope) HasFailed() bool

HasFailed returns the failure state of the machine scope.

func (*MachineScope) InstanceIsInKnownState

func (m *MachineScope) InstanceIsInKnownState() bool

InstanceIsInKnownState checks if the machine scope's instance state is known.

func (*MachineScope) InstanceIsOperational

func (m *MachineScope) InstanceIsOperational() bool

InstanceIsOperational returns the operational state of the machine scope.

func (*MachineScope) InstanceIsRunning

func (m *MachineScope) InstanceIsRunning() bool

InstanceIsRunning returns the instance state of the machine scope.

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

func (*MachineScope) Namespace

func (m *MachineScope) Namespace() string

Namespace returns the namespace name.

func (*MachineScope) PatchObject

func (m *MachineScope) PatchObject() error

PatchObject persists the machine spec and status.

func (*MachineScope) Role

func (m *MachineScope) Role() string

Role returns the machine role from the labels.

func (*MachineScope) SetAddresses

func (m *MachineScope) SetAddresses(addrs []clusterv1.MachineAddress)

SetAddresses sets the HuaweiCloudMachine address status.

func (*MachineScope) SetFailureMessage

func (m *MachineScope) SetFailureMessage(v error)

SetFailureMessage sets the HuaweiCloudMachine status failure message.

func (*MachineScope) SetFailureReason

func (m *MachineScope) SetFailureReason(v capierrors.MachineStatusError)

SetFailureReason sets the HuaweiCloudMachine status failure reason.

func (*MachineScope) SetInstanceID

func (m *MachineScope) SetInstanceID(instanceID string)

SetInstanceID sets the HuaweiCloudMachine instanceID in spec.

func (*MachineScope) SetInstanceState

func (m *MachineScope) SetInstanceState(v infrav1.InstanceState)

SetInstanceState sets the HuaweiCloudMachine status instance state.

func (*MachineScope) SetNotReady

func (m *MachineScope) SetNotReady()

SetNotReady sets the HuaweiCloudMachine Ready Status to false.

func (*MachineScope) SetProviderID

func (m *MachineScope) SetProviderID(instanceID string)

SetProviderID sets the HuaweiCloudMachine providerID in spec.

func (*MachineScope) SetReady

func (m *MachineScope) SetReady()

SetReady sets the HuaweiCloudMachine Ready Status.

type MachineScopeParams

type MachineScopeParams struct {
	Client       client.Client
	Logger       *logr.Logger
	Cluster      *clusterv1.Cluster
	Machine      *clusterv1.Machine
	InfraCluster ECSScope
	HCMachine    *infrav1.HuaweiCloudMachine
	Credentials  *basic.Credentials
}

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

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) 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) 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.

Jump to

Keyboard shortcuts

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