auxiliary

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package auxiliary provides shared testcontainer-based services for E2E tests. These run the same regardless of deployment (K8s or Quadlet): registry, git server, prometheus, jaeger. For deployment-specific infrastructure (where Flight Control runs), see the parent infra package and infra/k8s, infra/quadlet.

Index

Constants

View Source
const (

	// KeycloakE2EClientSecret is the client secret for flightctl-client in the e2e realm.
	KeycloakE2EClientSecret = "e2e-flightctl-client-secret" //nolint:gosec // G101: e2e test client secret only
	// KeycloakE2EOAuth2ClientSecret is the client secret for the suite-owned OAuth2 client in the e2e realm.
	KeycloakE2EOAuth2ClientSecret = "e2e-flightctl-oauth2-client-secret" //nolint:gosec // G101: e2e test client secret only
)
View Source
const E2EAuxHostEnv = containers.E2EAuxHostEnv

E2EAuxHostEnv is the env var to override the host used for registry/git/prometheus (e.g. when the test VM has multiple NICs and the cluster is on a different interface).

Variables

AllServices is the default set of shared aux services (started by Get(ctx)). Does not include ServiceTracing, ServiceFileServer, ServiceKeycloak, ServiceTrustify; start on-demand.

View Source
var WithHostAccess = containers.WithHostAccess

WithHostAccess adds host.containers.internal for Podman.

View Source
var WithNetwork = containers.WithNetwork

WithNetwork sets the container network.

Functions

func ConfigureDockerHost

func ConfigureDockerHost()

ConfigureDockerHost sets up the container runtime environment for testcontainers.

func CreateContainer

CreateContainer creates and starts a container, registering it for cleanup.

func GetContainerHostname

func GetContainerHostname() string

GetContainerHostname returns the hostname for host access from inside containers.

func GetDockerNetwork

func GetDockerNetwork() string

GetDockerNetwork returns the network name for testcontainers (kind, host, podman, bridge).

func GetHostIP

func GetHostIP() string

GetHostIP returns the host's external IP for container access.

func GetProviderType

func GetProviderType() testcontainers.ProviderType

GetProviderType returns the testcontainers provider type based on the detected runtime.

func QueryPrometheus

func QueryPrometheus(prometheusURL, query string) (*http.Response, error)

QueryPrometheus runs a PromQL query.

func RegisterContainer

func RegisterContainer(c testcontainers.Container)

RegisterContainer adds a container to the cleanup registry.

func ReloadPrometheusConfig

func ReloadPrometheusConfig(prometheusURL string) error

ReloadPrometheusConfig triggers a config reload via the lifecycle API.

func ShutdownAll

func ShutdownAll(ctx context.Context)

ShutdownAll terminates all registered containers.

func StopServices

func StopServices(services []Service) error

StopServices force-removes the containers for the requested aux services.

func StopTrustifyContainers

func StopTrustifyContainers()

StopTrustifyContainers force-removes Trustify containers and network by name. Used by StopServices for cleanup when the Trustify instance is not available.

Types

type AuthenticatedEndpoint

type AuthenticatedEndpoint struct {
	HostPort string
	Port     string
	Username string
	Password string
}

AuthenticatedEndpoint holds connection details for the credential-required view of this registry (same backend, nginx + basic auth on another port). HostPort is for docker:// / oci:// style refs (host:port), not an OAuth issuer or login URL.

type ContainerRequestOption

type ContainerRequestOption = containers.ContainerRequestOption

ContainerRequestOption is an alias for the shared containers package option type.

type FileServer

type FileServer struct {
	URL         string
	InternalURL string
	Host        string
	Port        string
	DataDir     string
	// contains filtered or unexported fields
}

FileServer holds connection info and the container for the aux HTTP file server.

func (*FileServer) PushFile

func (f *FileServer) PushFile(relativePath, content string) error

PushFile writes content to a file relative to the data directory, creating parent dirs as needed.

func (*FileServer) Start

func (f *FileServer) Start(ctx context.Context, network string, reuse bool) error

Start starts the file server container and sets URL, Host, Port, DataDir.

type GitServer

type GitServer struct {
	URL          string
	Host         string
	Port         int
	InternalHost string
	InternalPort int
	// contains filtered or unexported fields
}

GitServer holds connection info, SSH key path, and the container for the aux git server.

func (*GitServer) GetGitSSHPrivateKey

func (g *GitServer) GetGitSSHPrivateKey() (util.SSHPrivateKeyContent, error)

GetGitSSHPrivateKey returns the SSH private key content for the git server.

func (*GitServer) GetGitSSHPrivateKeyPath

func (g *GitServer) GetGitSSHPrivateKeyPath() (util.SSHPrivateKeyPath, error)

GetGitSSHPrivateKeyPath returns the path to the SSH private key for the git server.

func (*GitServer) Start

func (g *GitServer) Start(ctx context.Context, network string, reuse bool) error

Start starts the git server container and sets URL, Host, Port, etc.

type Jaeger

type Jaeger struct {
	URL          string
	Host         string
	Port         string
	OTLPEndpoint string
	// contains filtered or unexported fields
}

Jaeger holds connection info and the container for the aux Jaeger.

func (*Jaeger) Start

func (j *Jaeger) Start(ctx context.Context, network string, reuse bool) error

Start starts the Jaeger container and sets URL, Host, Port, OTLPEndpoint.

type Keycloak

type Keycloak struct {
	URL  string
	Host string
	Port string
	// contains filtered or unexported fields
}

Keycloak holds connection info and the container for the aux Keycloak.

func (*Keycloak) IssuerURL

func (k *Keycloak) IssuerURL() string

IssuerURL returns the OIDC issuer URL for the flightctl realm (e.g. http://host:port/realms/flightctl).

func (*Keycloak) Start

func (k *Keycloak) Start(ctx context.Context, network string, reuse bool) error

Start starts the Keycloak container and sets URL, Host, Port.

type Prometheus

type Prometheus struct {
	URL  string
	Host string
	Port string
	// contains filtered or unexported fields
}

Prometheus holds connection info and the container for the aux Prometheus.

func (*Prometheus) Start

func (p *Prometheus) Start(ctx context.Context, network string, reuse bool) error

Start starts the Prometheus container and sets URL, Host, Port.

type Registry

type Registry struct {
	URL  string
	Host string
	Port string
	// Reused is true when reuse=true and registryContainerName is already running (not merely
	// present or stopped); auxiliary.Get skips artifact upload when Reused (see containers.ContainerRunningByName).
	Reused        bool
	Authenticated AuthenticatedEndpoint
	// contains filtered or unexported fields
}

Registry holds connection info and the container for the aux registry.

func (*Registry) Start

func (r *Registry) Start(ctx context.Context, network string, reuse bool) error

Start starts the TLS registry container, then the authenticated (nginx + basic auth) endpoint, and sets URL, Host, Port, Reused, Authenticated.

type Service

type Service string

Service identifies an aux service that can be started individually.

const (
	ServiceRegistry   Service = "registry"
	ServiceGitServer  Service = "git-server"
	ServicePrometheus Service = "prometheus"
	ServiceTracing    Service = "tracing"
	ServiceKeycloak   Service = "keycloak"
	ServiceTrustify   Service = "trustify"
	ServiceFileServer Service = "file-server"
)

type Services

type Services struct {
	Registry   *Registry
	GitServer  *GitServer
	Prometheus *Prometheus
	Jaeger     *Jaeger
	Keycloak   *Keycloak
	Trustify   *Trustify
	FileServer *FileServer
	// contains filtered or unexported fields
}

Services holds the E2E aux services (registry, git, prometheus, jaeger, keycloak, trustify, file server). Same for all deployment types; created once and reused. Each service is nil until started. reuse is kept so Cleanup can no-op when reuse=true (containers stay running for the next run).

func Get

func Get(ctx context.Context) *Services

Get returns the aux services, starting all of them if needed (singleton).

func StartServices

func StartServices(ctx context.Context, services []Service) (*Services, error)

StartServices starts only the requested aux services with reuse=true. For registry, image bundles are uploaded when the container is freshly created (not reused).

func (*Services) Cleanup

func (s *Services) Cleanup(ctx context.Context)

Cleanup terminates containers when not reusing; with reuse=true containers stay running.

func (*Services) GetGitSSHPrivateKey

func (s *Services) GetGitSSHPrivateKey() (util.SSHPrivateKeyContent, error)

GetGitSSHPrivateKey returns the SSH private key content for git operations.

func (*Services) GetGitSSHPrivateKeyPath

func (s *Services) GetGitSSHPrivateKeyPath() (util.SSHPrivateKeyPath, error)

GetGitSSHPrivateKeyPath returns the path to the SSH private key for git operations. The key is always the one from the aux git server container (Podman); no deployment secrets.

func (*Services) GetRegistrySSHPrivateKeyPath

func (s *Services) GetRegistrySSHPrivateKeyPath() (util.SSHPrivateKeyPath, error)

GetRegistrySSHPrivateKeyPath returns the path to the pre-generated SSH private key in bin/.ssh. For registry use only. Created by create_e2e_certs.sh.

func (*Services) GetRegistrySSHPublicKeyPath

func (s *Services) GetRegistrySSHPublicKeyPath() (string, error)

GetRegistrySSHPublicKeyPath returns the path to the pre-generated SSH public key in bin/.ssh. For registry use only. Created by create_e2e_certs.sh.

func (*Services) UploadCharts

func (s *Services) UploadCharts() error

UploadCharts uploads helm charts to the registry.

func (*Services) UploadImages

func (s *Services) UploadImages() error

UploadImages uploads all image bundles to the registry.

func (*Services) UploadQuadlets

func (s *Services) UploadQuadlets() error

UploadQuadlets uploads quadlet artifacts to the registry.

type Trustify

type Trustify struct {
	URL          string
	Host         string
	Port         string
	InternalHost string
	InternalPort string
	// contains filtered or unexported fields
}

Trustify holds connection info and containers for the aux Trustify service.

func (*Trustify) InternalURL

func (t *Trustify) InternalURL() string

InternalURL returns the URL for container-to-container access (e.g., from flightctl-periodic).

func (*Trustify) LoadTestData

func (t *Trustify) LoadTestData(ctx context.Context) error

LoadTestData uploads SBOMs and advisories from the testdata directory to Trustify.

func (*Trustify) Start

func (t *Trustify) Start(ctx context.Context, network string, reuse bool) error

Start starts the Trustify containers (postgres + api + importer) with an internal network.

func (*Trustify) Stop

func (t *Trustify) Stop(ctx context.Context) error

Stop terminates the Trustify containers and removes the internal network.

Jump to

Keyboard shortcuts

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