api

package
v1.16.0-rc3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 CreateSSHCertificateAuthorityWithCleanup

func CreateSSHCertificateAuthorityWithCleanup(regionClient *RegionAPIClient, ctx context.Context, config *TestConfig, publicKey string) string

CreateSSHCertificateAuthorityWithCleanup creates an SSH CA and schedules cleanup.

func CreateSSHOpenSecurityGroupWithCleanup

func CreateSSHOpenSecurityGroupWithCleanup(regionClient *RegionAPIClient, ctx context.Context, config *TestConfig) string

CreateSSHOpenSecurityGroupWithCleanup creates an ingress TCP/22 security group and schedules cleanup.

func RunSSHCommand

func RunSSHCommand(address, user string, authMethods []ssh.AuthMethod, timeout time.Duration, command string) (string, error)

func SignSSHUserCertificate

func SignSSHUserCertificate(caSigner, userSigner ssh.Signer, principal string, validFor time.Duration) (ssh.AuthMethod, error)

func WaitForImageReady

func WaitForImageReady(regionClient *RegionAPIClient, ctx context.Context, config *TestConfig, imageID string)

WaitForImageReady polls until a custom image reaches the ready state in the region. Uses a 1-hour timeout to accommodate image download and import times.

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 WaitForInstancePublicIP

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

WaitForInstancePublicIP waits for an instance to get a public IP address.

func WaitForSSHReady

func WaitForSSHReady(publicIP string, timeout time.Duration)

func WaitForTCPPort

func WaitForTCPPort(address string, timeout time.Duration)

WaitForTCPPort waits for a TCP port to become reachable.

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) 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) DeleteInstance added in v1.13.0

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

DeleteInstance deletes an instance.

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

func (c *APIClient) GetInstanceSSHKey(ctx context.Context, instanceID string) (*regionopenapi.SshKeyResponse, error)

GetInstanceSSHKey retrieves the SSH private key for an instance.

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

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

func (*APIClient) RebootInstance

func (c *APIClient) RebootInstance(ctx context.Context, instanceID string, hard bool) error

RebootInstance reboots an instance. Set hard to true for a hard power cycle.

func (*APIClient) SnapshotInstance added in v1.14.0

func (c *APIClient) SnapshotInstance(ctx context.Context, instanceID string, name string) (*regionopenapi.Image, error)

func (*APIClient) StartInstance

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

StartInstance starts a stopped instance.

func (*APIClient) StopInstance

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

StopInstance stops a running instance.

type Endpoints

type Endpoints struct{}

Endpoints contains all API endpoint patterns.

func NewEndpoints

func NewEndpoints() *Endpoints

NewEndpoints creates a new Endpoints instance.

func (*Endpoints) CreateInstance added in v1.13.0

func (e *Endpoints) CreateInstance() string

Instance management endpoints (V2 API).

func (*Endpoints) DeleteInstance added in v1.13.0

func (e *Endpoints) DeleteInstance(instanceID 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) GetInstanceSSHKey

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

func (*Endpoints) GetInstanceSnapshot added in v1.14.0

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

func (*Endpoints) HealthCheck

func (e *Endpoints) HealthCheck() string

Health and metadata 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) ListRegions

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

Discovery endpoints.

func (*Endpoints) OpenAPISpec

func (e *Endpoints) OpenAPISpec() string

func (*Endpoints) RebootInstance

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

func (*Endpoints) StartInstance

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

func (*Endpoints) StopInstance

func (e *Endpoints) StopInstance(instanceID 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 ImagePayloadBuilder

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

ImagePayloadBuilder builds ImageCreate payloads for testing.

func NewImagePayload

func NewImagePayload() *ImagePayloadBuilder

NewImagePayload creates a builder with sensible defaults.

func (*ImagePayloadBuilder) Build

Build returns the typed ImageCreate struct.

func (*ImagePayloadBuilder) WithName

func (b *ImagePayloadBuilder) WithName(name string) *ImagePayloadBuilder

WithName overrides the image name.

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.

func (*InstancePayloadBuilder) WithPublicIP

func (b *InstancePayloadBuilder) WithPublicIP(enabled bool) *InstancePayloadBuilder

WithPublicIP enables public IP allocation for the instance.

func (*InstancePayloadBuilder) WithSSHCertificateAuthorityID

func (b *InstancePayloadBuilder) WithSSHCertificateAuthorityID(id string) *InstancePayloadBuilder

WithSSHCertificateAuthorityID sets the SSH CA trust anchor for the instance.

func (*InstancePayloadBuilder) WithSecurityGroups

func (b *InstancePayloadBuilder) WithSecurityGroups(securityGroupIDs ...string) *InstancePayloadBuilder

WithSecurityGroups sets the security group IDs applied to the instance.

type RegionAPIClient added in v1.14.0

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

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

func NewRegionClient added in v1.14.0

func NewRegionClient(baseURL string) (*RegionAPIClient, error)

func (*RegionAPIClient) CreateImage

func (c *RegionAPIClient) CreateImage(ctx context.Context, organizationID, regionID string, request regionopenapi.ImageCreate) (*regionopenapi.Image, error)

func (*RegionAPIClient) DeleteImage added in v1.14.0

func (c *RegionAPIClient) DeleteImage(ctx context.Context, organizationID, regionID, imageID string) error

func (*RegionAPIClient) DeleteSSHCertificateAuthority

func (c *RegionAPIClient) DeleteSSHCertificateAuthority(ctx context.Context, sshCertificateAuthorityID string) error

func (*RegionAPIClient) DeleteSecurityGroup

func (c *RegionAPIClient) DeleteSecurityGroup(ctx context.Context, securityGroupID string) error

func (*RegionAPIClient) ListImages

func (c *RegionAPIClient) ListImages(ctx context.Context, organizationID, regionID string) ([]regionopenapi.Image, error)

type RegionEndpoints added in v1.14.0

type RegionEndpoints struct{}

RegionEndpoints contains region API endpoint patterns used by integration tests.

func (*RegionEndpoints) DeleteImage added in v1.14.0

func (*RegionEndpoints) DeleteImage(organizationID, regionID, imageID string) string

func (*RegionEndpoints) ListImages

func (*RegionEndpoints) ListImages(organizationID, regionID string) string

func (*RegionEndpoints) SSHCertificateAuthoritiesV2

func (*RegionEndpoints) SSHCertificateAuthoritiesV2() string

func (*RegionEndpoints) SSHCertificateAuthorityV2

func (*RegionEndpoints) SSHCertificateAuthorityV2(sshCertificateAuthorityID string) string

func (*RegionEndpoints) SecurityGroupV2

func (*RegionEndpoints) SecurityGroupV2(securityGroupID string) string

func (*RegionEndpoints) SecurityGroupsV2

func (*RegionEndpoints) SecurityGroupsV2() string

type SSHKeyPair

type SSHKeyPair struct {
	AuthorizedKey    string
	PrivateKeyPEM    string
	PrivateKeySigner ssh.Signer
	PublicKeySSH     ssh.PublicKey
}

func NewSSHKeyPair

func NewSSHKeyPair() (*SSHKeyPair, error)

type TestConfig

type TestConfig struct {
	coreconfig.BaseConfig
	RegionBaseURL        string
	OrgID                string
	ProjectID            string
	RegionID             string
	FlavorID             string
	ImageID              string
	NetworkID            string
	EnableSSHIntegration bool
}

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