Help us shape the future of Go! Take the 2026 Go Developer Survey

openstack

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// TagManagedBy indicates the component that manages the resource
	TagManagedBy = "managed-by"

	// TagManagedByValue is the value for resources managed by this operator
	TagManagedByValue = "openstack-lb-operator"

	// TagServiceNamespace is the namespace of the service associated with the resource
	TagServiceNamespace = "k8s-service-namespace"

	// TagServiceName is the name of the service associated with the resource
	TagServiceName = "k8s-service-name"

	// TagClusterName is the name of the Kubernetes cluster
	TagClusterName = "k8s-cluster-name"

	// TagResourceType is the type of resource this represents
	TagResourceType = "resource-type"

	// ResourceTypePort represents a port resource
	ResourceTypePort ResourceType = "ports"

	// ResourceTypeFloatingIP represents a floating IP resource
	ResourceTypeFloatingIP ResourceType = "floatingips"
)

Resource ownership tags/labels

Variables

This section is empty.

Functions

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError checks if an error is a "not found" error

Types

type Client

type Client interface {
	// Combines all the other client interfaces
	NetworkClient
	PortClient
	FloatingIPClient
}

Client defines the OpenStack client interface

func NewClient

func NewClient(ctx context.Context, k8sClient client.Client, secretName, secretNamespace string) (Client, error)

NewClient creates a new OpenStack client from K8s secret

type ClientImpl

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

ClientImpl implements the Client interface

func (*ClientImpl) CreateFloatingIP

func (c *ClientImpl) CreateFloatingIP(
	ctx context.Context,
	networkID, portID, description string,
	serviceNamespace, serviceName string,
) (string, string, error)

CreateFloatingIP creates a floating IP in OpenStack and associates it with the port

func (*ClientImpl) CreatePort

func (c *ClientImpl) CreatePort(
	ctx context.Context,
	networkID, subnetID, portName, ipAddress, description string,
	serviceNamespace, serviceName string,
) (string, error)

CreatePort creates a port in OpenStack for the service IP

func (*ClientImpl) DeleteFloatingIP

func (c *ClientImpl) DeleteFloatingIP(ctx context.Context, floatingIPID string) error

DeleteFloatingIP deletes a floating IP from OpenStack

func (*ClientImpl) DeletePort

func (c *ClientImpl) DeletePort(ctx context.Context, portID string) error

DeletePort deletes a port from OpenStack

func (*ClientImpl) DetectNetworkForIP

func (c *ClientImpl) DetectNetworkForIP(ctx context.Context, ipAddress string) (string, string, error)

DetectNetworkForIP detects the OpenStack network and subnet for a given IP address

func (*ClientImpl) GetAllFloatingIPs

func (c *ClientImpl) GetAllFloatingIPs(ctx context.Context) ([]floatingips.FloatingIP, error)

In pkg/openstack/floatingip.go

func (*ClientImpl) GetAllPorts

func (c *ClientImpl) GetAllPorts(ctx context.Context) ([]ports.Port, error)

In pkg/openstack/port.go

func (*ClientImpl) GetFloatingIP

func (c *ClientImpl) GetFloatingIP(ctx context.Context, floatingIPID string) (bool, error)

GetFloatingIP checks if a floating IP exists in OpenStack

func (*ClientImpl) GetFloatingIPByPortID

func (c *ClientImpl) GetFloatingIPByPortID(ctx context.Context, portID string) (string, string, error)

GetFloatingIPByPortID retrieves a floating IP associated with the given port ID

func (*ClientImpl) GetFloatingIPDetails added in v0.3.0

func (c *ClientImpl) GetFloatingIPDetails(ctx context.Context, floatingIPID string) (*floatingips.FloatingIP, error)

GetFloatingIPDetails gets details of a specific floating IP

func (*ClientImpl) GetManagedFloatingIPs

func (c *ClientImpl) GetManagedFloatingIPs(
	ctx context.Context,
	serviceNamespace, serviceName string,
) ([]floatingips.FloatingIP, error)

GetManagedFloatingIPs gets all floating IPs managed by this operator for a specific service

func (*ClientImpl) GetManagedPorts

func (c *ClientImpl) GetManagedPorts(
	ctx context.Context,
	serviceNamespace, serviceName string,
) ([]ports.Port, error)

GetManagedPorts gets all ports managed by this operator for a specific service

func (*ClientImpl) GetPort

func (c *ClientImpl) GetPort(ctx context.Context, portID string) (bool, error)

GetPort checks if a port exists in OpenStack

type FloatingIPClient

type FloatingIPClient interface {
	// CreateFloatingIP creates a floating IP and associates it with a port
	CreateFloatingIP(ctx context.Context, networkID, portID, description string,
		serviceNamespace, serviceName string) (floatingIPID, floatingIPAddress string, err error)

	// GetFloatingIP checks if a floating IP exists
	GetFloatingIP(ctx context.Context, floatingIPID string) (exists bool, err error)

	// DeleteFloatingIP deletes a floating IP
	DeleteFloatingIP(ctx context.Context, floatingIPID string) error

	// GetFloatingIPByPortID finds a floating IP associated with a port
	GetFloatingIPByPortID(ctx context.Context, portID string) (floatingIPID, floatingIPAddress string, err error)

	// GetManagedFloatingIPs gets all floating IPs managed by this operator for a specific service
	GetManagedFloatingIPs(ctx context.Context, serviceNamespace, serviceName string) ([]floatingips.FloatingIP, error)
}

FloatingIPClient handles floating IP operations

type NetworkClient

type NetworkClient interface {
	// DetectNetworkForIP finds the network and subnet for a given IP
	DetectNetworkForIP(ctx context.Context, ipAddress string) (networkID, subnetID string, err error)

	// GetAllFloatingIPs gets all floating IPs in OpenStack
	GetAllFloatingIPs(ctx context.Context) ([]floatingips.FloatingIP, error)

	// GetAllPorts gets all ports in OpenStack
	GetAllPorts(ctx context.Context) ([]ports.Port, error)

	// GetFloatingIPDetails gets details of a specific floating IP by ID
	GetFloatingIPDetails(ctx context.Context, floatingIPID string) (*floatingips.FloatingIP, error)
}

NetworkClient handles network operations

type PortClient

type PortClient interface {
	// CreatePort creates an OpenStack port
	CreatePort(ctx context.Context, networkID, subnetID, portName, ipAddress, description string,
		serviceNamespace, serviceName string) (portID string, err error)

	// GetPort checks if a port exists
	GetPort(ctx context.Context, portID string) (exists bool, err error)

	// DeletePort deletes an OpenStack port
	DeletePort(ctx context.Context, portID string) error

	// GetManagedPorts gets all ports managed by this operator for a specific service
	GetManagedPorts(ctx context.Context, serviceNamespace, serviceName string) ([]ports.Port, error)
}

PortClient handles port operations

type ResourceType

type ResourceType string

ResourceType represents the type of OpenStack resource

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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