api

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateClusterWithCleanup

func CreateClusterWithCleanup(client *APIClient, ctx context.Context, config *TestConfig, payload openapi.ComputeClusterWrite) (openapi.ComputeClusterRead, string)

CreateClusterWithCleanup creates a cluster, waits for provisioning, and schedules automatic cleanup. Accepts a typed struct for type safety (or use BuildTyped() from the builder).

func CreateInstanceWithCleanup added in v1.13.0

func CreateInstanceWithCleanup(client *APIClient, ctx context.Context, config *TestConfig, payload openapi.InstanceCreate) (openapi.InstanceRead, string)

CreateInstanceWithCleanup creates an instance, waits for it to be provisioned, and schedules automatic cleanup.

func ExtractMachineID

func ExtractMachineID(cluster openapi.ComputeClusterRead) string

ExtractMachineID extracts the first machine ID from a cluster's first workload pool.

func ExtractMachineIDsFromPool

func ExtractMachineIDsFromPool(cluster openapi.ComputeClusterRead, poolName string) []string

ExtractMachineIDsFromPool extracts machine IDs from a specific workload pool by name.

func FindPoolByName added in v1.12.0

FindPoolByName finds a workload pool by name in the cluster spec.

func GetMachineStatus

func GetMachineStatus(cluster openapi.ComputeClusterRead, machineID string) string

GetMachineStatus retrieves the current status of a machine by ID from a cluster. Searches all workload pools for the machine.

func VerifyClusterPresence

func VerifyClusterPresence(clusters []openapi.ComputeClusterRead, expectedClusterIDs []string)

VerifyClusterPresence verifies that clusters are present in the list.

func VerifyDefaultFirewallRule added in v1.12.0

func VerifyDefaultFirewallRule(cluster *openapi.ComputeClusterRead, poolName string)

VerifyDefaultFirewallRule verifies a pool has the default SSH firewall rule.

func VerifyMachineEvicted

func VerifyMachineEvicted(cluster openapi.ComputeClusterRead, poolName, evictedMachineID string, expectedReplicas int) bool

VerifyMachineEvicted checks that a machine ID is not present in a specific pool and the pool has the expected replica count.

func VerifyMultiplePoolsReplicas added in v1.12.0

func VerifyMultiplePoolsReplicas(cluster *openapi.ComputeClusterRead, poolReplicas map[string]int)

VerifyMultiplePoolsReplicas verifies multiple pools have their expected replicas.

func VerifyPoolFirewallRules added in v1.12.0

func VerifyPoolFirewallRules(cluster *openapi.ComputeClusterRead, poolName string, expectedRuleCount int)

VerifyPoolFirewallRules verifies a pool has the expected firewall configuration.

func VerifyPoolReplicas added in v1.12.0

func VerifyPoolReplicas(cluster *openapi.ComputeClusterRead, poolName string, expectedReplicas int)

VerifyPoolReplicas verifies a pool has the expected number of replicas in spec.

func VerifyProjectPresence

func VerifyProjectPresence(clusters []openapi.ComputeClusterRead, expectedProjectIDs []string)

VerifyProjectPresence verifies that projects are present in the cluster list.

func VerifyWorkloadPoolUpdate

func VerifyWorkloadPoolUpdate(cluster openapi.ComputeClusterRead, expectedMinPools int)

VerifyWorkloadPoolUpdate verifies that a cluster's workload pools were updated correctly.

func WaitForInstanceActive added in v1.13.0

func WaitForInstanceActive(client *APIClient, ctx context.Context, config *TestConfig, instanceID string)

WaitForInstanceActive waits for an instance to reach active/running power state.

func WaitForMachineStatus

func WaitForMachineStatus(client *APIClient, ctx context.Context, config *TestConfig, clusterID, machineID, expectedStatus string)

WaitForMachineStatus waits for a specific machine to reach the expected status.

func WaitForMachinesAvailable

func WaitForMachinesAvailable(client *APIClient, ctx context.Context, config *TestConfig, clusterID string) string

WaitForMachinesAvailable waits for machines to be available in the cluster and returns the first machine ID.

func WaitForPoolMachinesActive added in v1.12.0

func WaitForPoolMachinesActive(client *APIClient, ctx context.Context, config *TestConfig, clusterID, poolName string, expectedCount int)

WaitForPoolMachinesActive waits for all machines in a pool to become active.

func WaitForPoolReplicas added in v1.12.0

func WaitForPoolReplicas(client *APIClient, ctx context.Context, config *TestConfig, clusterID, poolName string, expectedReplicas int)

WaitForPoolReplicas waits for a workload pool to have the expected number of replicas.

Types

type APIClient

type APIClient struct {
	*coreclient.APIClient
	// contains filtered or unexported fields
}

APIClient wraps the core API client with compute-specific methods.

func NewAPIClient

func NewAPIClient(baseURL string) (*APIClient, error)

NewAPIClient creates a new Compute API client.

func NewAPIClientWithConfig

func NewAPIClientWithConfig(config *TestConfig) *APIClient

NewAPIClientWithConfig creates a new Compute API client with the given config.

func (*APIClient) CheckClusterQuota

func (c *APIClient) CheckClusterQuota(ctx context.Context, orgID string) error

CheckClusterQuota checks if there is sufficient cluster quota available.

func (*APIClient) CreateCluster

func (c *APIClient) CreateCluster(ctx context.Context, orgID, projectID string, body openapi.ComputeClusterWrite) (openapi.ComputeClusterRead, error)

CreateCluster creates a new compute cluster. Accepts a typed struct for type safety, then converts to JSON for the request.

func (*APIClient) CreateInstance added in v1.13.0

func (c *APIClient) CreateInstance(ctx context.Context, payload openapi.InstanceCreate) (openapi.InstanceRead, error)

CreateInstance creates a new instance.

func (*APIClient) DeleteCluster

func (c *APIClient) DeleteCluster(ctx context.Context, orgID, projectID, clusterID string) error

func (*APIClient) DeleteInstance added in v1.13.0

func (c *APIClient) DeleteInstance(ctx context.Context, instanceID string) error

DeleteInstance deletes an instance.

func (*APIClient) EvictMachines

func (c *APIClient) EvictMachines(ctx context.Context, orgID, projectID, clusterID string, machineIDs []string) error

EvictMachines evicts specified machines from a cluster. Uses typed struct for type safety, then converts to JSON for the request.

func (*APIClient) GetCluster

func (c *APIClient) GetCluster(ctx context.Context, orgID, projectID, clusterID string) (openapi.ComputeClusterRead, error)

GetCluster retrieves a specific cluster. Im using this to poll with eventually to wait for the cluster to be provisioned.

func (*APIClient) GetInstance added in v1.13.0

func (c *APIClient) GetInstance(ctx context.Context, instanceID string) (openapi.InstanceRead, error)

GetInstance retrieves a specific instance.

func (*APIClient) GetInstanceConsoleOutput added in v1.13.0

func (c *APIClient) GetInstanceConsoleOutput(ctx context.Context, instanceID string, length *int) (*regionopenapi.ConsoleOutputResponse, error)

GetInstanceConsoleOutput retrieves console output for an instance.

func (*APIClient) HardRebootMachine

func (c *APIClient) HardRebootMachine(ctx context.Context, orgID, projectID, clusterID, machineID string) error

HardRebootMachine performs a hard reboot of a machine.

func (*APIClient) ListClusters

func (c *APIClient) ListClusters(ctx context.Context, orgID, projectID string) ([]openapi.ComputeClusterRead, error)

ListClusters lists all clusters for a project.

func (*APIClient) ListFlavors

func (c *APIClient) ListFlavors(ctx context.Context, orgID, regionID string) (regionopenapi.Flavors, error)

func (*APIClient) ListImages

func (c *APIClient) ListImages(ctx context.Context, orgID, regionID string) (regionopenapi.Images, error)

func (*APIClient) ListOrganizationClusters

func (c *APIClient) ListOrganizationClusters(ctx context.Context, orgID string) ([]openapi.ComputeClusterRead, error)

ListOrganizationClusters lists all clusters for an organization across all projects.

func (*APIClient) ListRegions

func (c *APIClient) ListRegions(ctx context.Context, orgID string) (regionopenapi.Regions, error)

func (*APIClient) SoftRebootMachine

func (c *APIClient) SoftRebootMachine(ctx context.Context, orgID, projectID, clusterID, machineID string) error

SoftRebootMachine performs a graceful reboot of a machine.

func (*APIClient) StartMachine

func (c *APIClient) StartMachine(ctx context.Context, orgID, projectID, clusterID, machineID string) error

StartMachine starts a stopped machine.

func (*APIClient) StopMachine

func (c *APIClient) StopMachine(ctx context.Context, orgID, projectID, clusterID, machineID string) error

StopMachine stops a running machine.

func (*APIClient) UpdateCluster

func (c *APIClient) UpdateCluster(ctx context.Context, orgID, projectID, clusterID string, body openapi.ComputeClusterWrite) error

UpdateCluster updates an existing cluster. Accepts a typed struct for type safety, then converts to JSON for the request.

type ClusterInfo

type ClusterInfo struct {
	Cluster   openapi.ComputeClusterRead
	ClusterID string
	ProjectID string
}

ClusterInfo holds cluster metadata and project information.

type ClusterPayloadBuilder

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

ClusterPayloadBuilder builds cluster payloads for testing using type-safe OpenAPI structs.

func NewClusterPayload

func NewClusterPayload() *ClusterPayloadBuilder

NewClusterPayload creates a new cluster payload builder with defaults from config.

func (*ClusterPayloadBuilder) Build

func (b *ClusterPayloadBuilder) Build() map[string]interface{}

Build returns the cluster as a map for JSON marshaling (required for API client).

func (*ClusterPayloadBuilder) BuildTyped

BuildTyped returns the typed cluster struct directly.

func (*ClusterPayloadBuilder) ClearWorkloadPools added in v1.12.0

func (b *ClusterPayloadBuilder) ClearWorkloadPools() *ClusterPayloadBuilder

ClearWorkloadPools removes all default workload pools to start fresh.

func (*ClusterPayloadBuilder) WithDescription

func (b *ClusterPayloadBuilder) WithDescription(desc string) *ClusterPayloadBuilder

WithDescription sets the cluster description.

func (*ClusterPayloadBuilder) WithFlavorID

func (b *ClusterPayloadBuilder) WithFlavorID(flavorID string) *ClusterPayloadBuilder

WithFlavorID sets the flavor ID for all workload pools.

func (*ClusterPayloadBuilder) WithImageID

func (b *ClusterPayloadBuilder) WithImageID(imageID string) *ClusterPayloadBuilder

WithImageID sets the image ID for all workload pools.

func (*ClusterPayloadBuilder) WithName

WithName sets the cluster name.

func (*ClusterPayloadBuilder) WithProjectID

func (b *ClusterPayloadBuilder) WithProjectID(projectID string) *ClusterPayloadBuilder

WithProjectID overrides the default project ID for multi-project testing.

func (*ClusterPayloadBuilder) WithRegionID

func (b *ClusterPayloadBuilder) WithRegionID(regionID string) *ClusterPayloadBuilder

WithRegionID sets the region ID.

func (*ClusterPayloadBuilder) WithWorkloadPool

func (b *ClusterPayloadBuilder) WithWorkloadPool(name, flavorID, imageID string, replicas int) *ClusterPayloadBuilder

WithWorkloadPool adds a workload pool configuration.

type ClusterUpdateFixture

type ClusterUpdateFixture struct {
	Cluster          openapi.ComputeClusterRead
	ClusterID        string
	OriginalReplicas int
}

ClusterUpdateFixture represents a cluster setup for update testing.

func CreateClusterUpdateFixture

func CreateClusterUpdateFixture(client *APIClient, ctx context.Context, config *TestConfig, clusterName string) *ClusterUpdateFixture

CreateClusterUpdateFixture creates a cluster specifically for update testing.

func (*ClusterUpdateFixture) CreateUpdatePayload

func (f *ClusterUpdateFixture) CreateUpdatePayload(config *TestConfig, newReplicas int) openapi.ComputeClusterWrite

CreateUpdatePayload creates a cluster update payload with modified workload pools. Returns typed struct for type safety.

type Endpoints

type Endpoints struct{}

Endpoints contains all API endpoint patterns.

func NewEndpoints

func NewEndpoints() *Endpoints

NewEndpoints creates a new Endpoints instance.

func (*Endpoints) CreateCluster

func (e *Endpoints) CreateCluster(orgID, projectID string) string

func (*Endpoints) CreateInstance added in v1.13.0

func (e *Endpoints) CreateInstance() string

Instance management endpoints (V2 API).

func (*Endpoints) DeleteCluster

func (e *Endpoints) DeleteCluster(orgID, projectID, clusterID string) string

func (*Endpoints) DeleteInstance added in v1.13.0

func (e *Endpoints) DeleteInstance(instanceID string) string

func (*Endpoints) EvictMachines

func (e *Endpoints) EvictMachines(orgID, projectID, clusterID string) string

func (*Endpoints) GetCluster

func (e *Endpoints) GetCluster(orgID, projectID, clusterID string) string

func (*Endpoints) GetInstance added in v1.13.0

func (e *Endpoints) GetInstance(instanceID string) string

func (*Endpoints) GetInstanceConsoleOutput added in v1.13.0

func (e *Endpoints) GetInstanceConsoleOutput(instanceID string) string

func (*Endpoints) HardRebootMachine

func (e *Endpoints) HardRebootMachine(orgID, projectID, clusterID, machineID string) string

func (*Endpoints) HealthCheck

func (e *Endpoints) HealthCheck() string

Health and metadata endpoints.

func (*Endpoints) ListClusters

func (e *Endpoints) ListClusters(orgID, projectID string) string

Cluster management endpoints.

func (*Endpoints) ListFlavors

func (e *Endpoints) ListFlavors(orgID, regionID string) string

func (*Endpoints) ListImages

func (e *Endpoints) ListImages(orgID, regionID string) string

func (*Endpoints) ListOrganizationClusters

func (e *Endpoints) ListOrganizationClusters(orgID string) string

func (*Endpoints) ListRegions

func (e *Endpoints) ListRegions(orgID string) string

Discovery endpoints.

func (*Endpoints) OpenAPISpec

func (e *Endpoints) OpenAPISpec() string

func (*Endpoints) SoftRebootMachine

func (e *Endpoints) SoftRebootMachine(orgID, projectID, clusterID, machineID string) string

func (*Endpoints) StartMachine

func (e *Endpoints) StartMachine(orgID, projectID, clusterID, machineID string) string

Machine operation endpoints.

func (*Endpoints) StopMachine

func (e *Endpoints) StopMachine(orgID, projectID, clusterID, machineID string) string

func (*Endpoints) UpdateCluster

func (e *Endpoints) UpdateCluster(orgID, projectID, clusterID string) string

func (*Endpoints) Version

func (e *Endpoints) Version() string

type GinkgoLogger added in v1.13.0

type GinkgoLogger struct{}

GinkgoLogger implements the Logger interface for Ginkgo tests.

func (*GinkgoLogger) Printf added in v1.13.0

func (g *GinkgoLogger) Printf(format string, args ...interface{})

type InstancePayloadBuilder added in v1.13.0

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

InstancePayloadBuilder builds instance payloads for testing using type-safe OpenAPI structs.

func NewInstancePayload added in v1.13.0

func NewInstancePayload() *InstancePayloadBuilder

NewInstancePayload creates a new instance payload builder with defaults from config.

func (*InstancePayloadBuilder) Build added in v1.13.0

Build returns the typed instance struct.

func (*InstancePayloadBuilder) WithFlavorID added in v1.13.0

func (b *InstancePayloadBuilder) WithFlavorID(flavorID string) *InstancePayloadBuilder

WithFlavorID sets the flavor ID.

func (*InstancePayloadBuilder) WithImageID added in v1.13.0

func (b *InstancePayloadBuilder) WithImageID(imageID string) *InstancePayloadBuilder

WithImageID sets the image ID.

func (*InstancePayloadBuilder) WithName added in v1.13.0

WithName sets the instance name.

func (*InstancePayloadBuilder) WithNetworkID added in v1.13.0

func (b *InstancePayloadBuilder) WithNetworkID(networkID string) *InstancePayloadBuilder

WithNetworkID sets the network ID.

type MultiProjectClusterFixture

type MultiProjectClusterFixture struct {
	Clusters []ClusterInfo
	Projects []string
}

MultiProjectClusterFixture represents clusters across multiple projects for testing.

func CreateMultiProjectClusterFixture

func CreateMultiProjectClusterFixture(client *APIClient, ctx context.Context, config *TestConfig, projectIDs []string) *MultiProjectClusterFixture

CreateMultiProjectClusterFixture creates clusters in the specified projects for testing.

type QuotaInfo

type QuotaInfo struct {
	Kind        string `json:"kind"`
	DisplayName string `json:"displayName"`
	Description string `json:"description"`
	Quantity    int    `json:"quantity"`
	Used        int    `json:"used"`
	Committed   int    `json:"committed"`
	Reserved    int    `json:"reserved"`
	Default     int    `json:"default"`
	Free        int    `json:"free"`
}

QuotaInfo represents quota information for a resource.

type QuotaResponse

type QuotaResponse struct {
	Quotas []QuotaInfo `json:"quotas"`
}

QuotaResponse represents the quota API response structure.

type TestConfig

type TestConfig struct {
	coreconfig.BaseConfig
	IdentityBaseURL    string
	OrgID              string
	ProjectID          string
	SecondaryProjectID string
	RegionID           string
	SecondaryRegionID  string
	FlavorID           string
	ImageID            string
	NetworkID          string
}

TestConfig extends the base config with Compute-specific fields.

func LoadTestConfig

func LoadTestConfig() (*TestConfig, error)

LoadTestConfig loads configuration from environment variables and .env files using viper. Returns an error if required configuration values are missing.

Jump to

Keyboard shortcuts

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