deployer

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Package deployer provides pluggable service deployment backends.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidEndpoint ...
	ErrInvalidEndpoint = errors.New("invalid endpoint format: expected host:port")
	// ErrMissingEndpoint ...
	ErrMissingEndpoint = errors.New("local mode requires endpoint to be set")
)
View Source
var Providers = registry.New[Deployer]("deployer")

Providers is the registry of available Deployer implementations.

Functions

This section is empty.

Types

type ArgoDeployer

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

ArgoDeployer implements Deployer using Argo CD Application CRs. It delegates to the existing argocd.Client and argocd.Generator.

func NewArgoDeployer

func NewArgoDeployer(client argocd.Applicator, generator *argocd.Generator, serviceConfigs map[string]argocd.ServiceConfig) *ArgoDeployer

NewArgoDeployer creates a new ArgoDeployer.

func (*ArgoDeployer) Deploy

func (d *ArgoDeployer) Deploy(ctx context.Context, env *v1alpha1.Environment) error

Deploy creates or updates Argo CD Application CRs for the environment.

func (*ArgoDeployer) Status

Status returns the sync status of ArgoCD Applications for this environment, mapped to the deployer-agnostic ServiceStatus type.

func (*ArgoDeployer) Teardown

func (d *ArgoDeployer) Teardown(ctx context.Context, env *v1alpha1.Environment) error

Teardown deletes the Argo CD Application CRs for the environment.

type ConfigMapFetcher

type ConfigMapFetcher struct {
	Client client.Client
}

ConfigMapFetcher reads pre-rendered YAML manifests from ConfigMaps created by CI pipelines. It looks for ConfigMaps with the labels divergedev.com/manifests=true and divergedev.com/environment=<envName>.

func (*ConfigMapFetcher) Fetch

Fetch performs its designated operation.

type Deployer

type Deployer interface {
	Deploy(ctx context.Context, env *v1alpha1.Environment) error
	Teardown(ctx context.Context, env *v1alpha1.Environment) error
	// Status returns the current deployment status for the environment.
	// An empty slice indicates no active deployments remain.
	Status(ctx context.Context, env *v1alpha1.Environment) ([]ServiceStatus, error)
}

Deployer deploys and tears down services for a preview environment.

type DirectDeployer

type DirectDeployer struct {
	Client  client.Client
	Fetcher ManifestFetcher
}

DirectDeployer applies pre-rendered Kubernetes manifests directly via Server-Side Apply, without requiring ArgoCD.

func (*DirectDeployer) Deploy

func (d *DirectDeployer) Deploy(ctx context.Context, env *v1alpha1.Environment) error

Deploy fetches pre-rendered manifests and applies them via Server-Side Apply.

func (*DirectDeployer) Status

Status returns the deployment status of resources managed by this deployer.

func (*DirectDeployer) Teardown

func (d *DirectDeployer) Teardown(ctx context.Context, env *v1alpha1.Environment) error

Teardown cleans up deployed resources. For 'create' namespace mode: no-op — the controller deletes the namespace. For 'same' namespace mode: no-op — OwnerReferences trigger automatic GC when the Environment CR is deleted.

type DotDivergeConfig

type DotDivergeConfig struct {
	// APIVersion is the API version of the configuration format.
	APIVersion string `yaml:"apiVersion"`
	// Kind is the configuration resource type.
	Kind string `yaml:"kind"`
	// Metadata holds the resource metadata.
	Metadata struct {
		// Name is the name of the service configuration.
		Name string `yaml:"name"`
	} `yaml:"metadata"`
	// Spec defines the desired preview configuration.
	Spec DotDivergeSpec `yaml:"spec"`
}

DotDivergeConfig represents the .diverge.yaml file found in service repositories.

func ParseDotDivergeConfig

func ParseDotDivergeConfig(data []byte) (*DotDivergeConfig, error)

ParseDotDivergeConfig parses the raw bytes of a .diverge.yaml file.

func (*DotDivergeConfig) ToServicePreviewConfig

func (c *DotDivergeConfig) ToServicePreviewConfig(image string) *v1alpha1.ServicePreviewConfig

ToServicePreviewConfig converts a parsed .diverge.yaml into the CRD type.

type DotDivergeContainer

type DotDivergeContainer struct {
	// Env contains a list of environment variables.
	Env []struct {
		// Name is the environment variable name.
		Name string `yaml:"name"`
		// Value is the environment variable value.
		Value string `yaml:"value"`
	} `yaml:"env"`
}

DotDivergeContainer configures the preview container.

type DotDivergeRouting

type DotDivergeRouting struct {
	// ParentRef specifies the Gateway API parent reference.
	ParentRef string `yaml:"parentRef"`
	// HeaderKey is the routing header key.
	HeaderKey string `yaml:"headerKey"`
}

DotDivergeRouting configures preview routing.

type DotDivergeSpec

type DotDivergeSpec struct {
	// Namespace is the target namespace for the preview environment.
	Namespace string `yaml:"namespace"`
	// ServiceName is the name of the service to deploy.
	ServiceName string `yaml:"serviceName"`
	// Port is the container port the service listens on.
	Port int32 `yaml:"port"`
	// Routing configures the ingress routing for the service.
	Routing DotDivergeRouting `yaml:"routing"`
	// WebSocket configures WebSocket proxy settings.
	WebSocket *v1alpha1.WebSocketSpec `yaml:"websocket"`
	// Container configures the container execution environment.
	Container DotDivergeContainer `yaml:"container"`
}

DotDivergeSpec is the spec section of .diverge.yaml.

type InstrumentedDeployer

type InstrumentedDeployer struct {
	Inner Deployer
	Name  string
}

InstrumentedDeployer wraps a Deployer with Prometheus metrics.

func (*InstrumentedDeployer) Deploy

Deploy performs its designated operation.

func (*InstrumentedDeployer) Status

Status performs its designated operation.

func (*InstrumentedDeployer) Teardown

Teardown performs its designated operation.

type KEDAConfig

type KEDAConfig struct {
	MinReplicas int64
	MaxReplicas int64
	Cooldown    int64
}

KEDAConfig holds controller-level CLI defaults for KEDA autoscaling. Per-service CRD config (KEDASpec) overrides these when set.

type KEDADeployer

type KEDADeployer struct {
	Inner  Deployer
	Client client.Client
	Config KEDAConfig
}

KEDADeployer represents the configuration or state for this type.

func (*KEDADeployer) Deploy

func (d *KEDADeployer) Deploy(ctx context.Context, env *v1alpha1.Environment) error

Deploy performs its designated operation.

func (*KEDADeployer) Status

Status performs its designated operation.

func (*KEDADeployer) Teardown

func (d *KEDADeployer) Teardown(ctx context.Context, env *v1alpha1.Environment) error

Teardown performs its designated operation.

type LocalDeployer

type LocalDeployer struct {
	Client client.Client
}

LocalDeployer represents the configuration or state for this type.

func (*LocalDeployer) Deploy

func (d *LocalDeployer) Deploy(ctx context.Context, env *v1alpha1.Environment) error

Deploy performs its designated operation.

func (*LocalDeployer) Status

Status performs its designated operation.

func (*LocalDeployer) Teardown

func (d *LocalDeployer) Teardown(ctx context.Context, env *v1alpha1.Environment) error

Teardown performs its designated operation.

type ManifestFetcher

type ManifestFetcher interface {
	Fetch(ctx context.Context, env *v1alpha1.Environment) ([]unstructured.Unstructured, error)
}

ManifestFetcher retrieves pre-rendered Kubernetes manifests for deployment.

type NoopDeployer

type NoopDeployer struct{}

NoopDeployer is a Deployer that does nothing. Used when deployment is managed externally or for testing.

func (*NoopDeployer) Deploy

func (n *NoopDeployer) Deploy(ctx context.Context, env *v1alpha1.Environment) error

Deploy does nothing.

func (*NoopDeployer) Status

Status returns no active deployments.

func (*NoopDeployer) Teardown

func (n *NoopDeployer) Teardown(ctx context.Context, env *v1alpha1.Environment) error

Teardown does nothing.

type OTelAnnotationDeployer added in v0.7.0

type OTelAnnotationDeployer struct {
	Inner       Deployer
	Annotations map[string]string // e.g. {"instrumentation.opentelemetry.io/inject-java": "true"}
}

OTelAnnotationDeployer wraps a Deployer and injects OTel Operator auto-instrumentation annotations into deployed workloads.

func (*OTelAnnotationDeployer) Deploy added in v0.7.0

Deploy performs its designated operation, injecting annotations into the Environment so that inner deployers can propagate them to workloads.

func (*OTelAnnotationDeployer) Status added in v0.7.0

Status delegates to the inner deployer.

func (*OTelAnnotationDeployer) Teardown added in v0.7.0

Teardown delegates to the inner deployer.

type ServiceConfigFetcher

type ServiceConfigFetcher struct{}

ServiceConfigFetcher generates Kubernetes Deployment and Service manifests from the ServicePreviewConfig on the Environment CR. This is used for multi-repo preview mode where we deploy a single preview pod based on the .diverge.yaml configuration rather than fetching pre-rendered manifests.

func (*ServiceConfigFetcher) Fetch

Fetch generates a Deployment and Service for the preview pod.

type ServiceStatus

type ServiceStatus struct {
	// Name is the unique resource identifier (e.g., ArgoCD Application name
	// or Kubernetes Deployment name).
	Name string
	// Service is the Diverge service name this status belongs to.
	Service string
	// SyncStatus indicates whether the desired state has been applied.
	// Values: "Synced", "OutOfSync", "Applied", "Unknown".
	SyncStatus string
	// Health indicates the runtime health of the deployed service.
	// Values: "Healthy", "Progressing", "Degraded", "Missing",
	// "Current", "InProgress", "Failed", "Terminating".
	Health string
	// URL is an optional endpoint where this service can be reached.
	URL string
	// Message provides additional context about the current status.
	Message string
}

ServiceStatus reports the deployment state of a single service within a preview environment. This is the deployer-agnostic status type returned by all Deployer implementations.

type URLFetcher

type URLFetcher struct {
	HTTPClient *http.Client
	AuthToken  string
	// SkipURLValidation disables SSRF protection (HTTPS enforcement,
	// private IP blocking). Only set to true for development/testing.
	SkipURLValidation bool
}

URLFetcher downloads pre-rendered YAML manifests from an HTTP endpoint. The URL is read from env.Spec.Deploy.Manifests.URL. An optional auth token can be set via the AuthToken field.

func (*URLFetcher) Fetch

Fetch performs its designated operation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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