v2

package
v1.27.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package v2 provides configuration structures for Caproni v2 format. This package contains the separated concerns architecture where repositories, deployers, and reloaders are separate top-level sections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CaproniConfig

type CaproniConfig struct {
	// Version is the configuration schema version (required, must be 2).
	Version int `yaml:"version"`

	Cluster      types.ClusterConfig                               `yaml:"cluster"`
	Repositories *orderedmap.OrderedMap[string, *RepositoryConfig] `yaml:"repositories"`

	// Deployers configuration (v2 only).
	Deployers *orderedmap.OrderedMap[string, *DeployerConfig] `yaml:"deployers,omitempty"`

	// Reloaders configuration (v2 only).
	Reloaders *orderedmap.OrderedMap[string, *ReloaderConfig] `yaml:"reloaders,omitempty"`

	// ConfigFile is the absolute path to the configuration file.
	// This field is populated by LoadCaproniConfig and is not part of the YAML.
	ConfigFile string `yaml:"-"`

	// ConfigDir is the absolute path to the directory containing the configuration file.
	// This field is populated by LoadCaproniConfig and is not part of the YAML.
	// Use this to resolve relative paths in repository configurations.
	ConfigDir string `yaml:"-"`

	// CopySleepImage is the Docker image used for deployment copies in edit mode.
	// Populated by LoadCaproniConfig from GL_COPY_SLEEP_IMAGE; not configurable in caproni.yaml.
	CopySleepImage string `yaml:"-"`
}

CaproniConfig is the root configuration (v2 format with separated concerns).

func (*CaproniConfig) AllDeployers

func (c *CaproniConfig) AllDeployers() iter.Seq2[string, *DeployerConfig]

AllDeployers returns an iterator over all deployers. If Deployers is nil, returns an empty iterator.

func (*CaproniConfig) AllReloaders

func (c *CaproniConfig) AllReloaders() iter.Seq2[string, *ReloaderConfig]

AllReloaders returns an iterator over all reloaders. If Reloaders is nil, returns an empty iterator.

func (*CaproniConfig) AllRepositories

func (c *CaproniConfig) AllRepositories() iter.Seq2[string, *RepositoryConfig]

AllRepositories returns an iterator over all repositories. If Repositories is nil, returns an empty iterator.

func (*CaproniConfig) ApplyDefaults

func (c *CaproniConfig) ApplyDefaults() error

ApplyDefaults applies schema-defined defaults to optional fields.

func (*CaproniConfig) DeployersLen

func (c *CaproniConfig) DeployersLen() int

DeployersLen returns the number of deployers. If Deployers is nil, returns 0.

func (*CaproniConfig) GetDeployer

func (c *CaproniConfig) GetDeployer(name string) (*DeployerConfig, bool)

GetDeployer retrieves a deployer by name. Returns the deployer config and true if found, or nil and false if not found or Deployers is nil.

func (*CaproniConfig) GetReloader

func (c *CaproniConfig) GetReloader(name string) (*ReloaderConfig, bool)

GetReloader retrieves a reloader by name. Returns the reloader config and true if found, or nil and false if not found or Reloaders is nil.

func (*CaproniConfig) GetRepository

func (c *CaproniConfig) GetRepository(name string) (*RepositoryConfig, bool)

GetRepository retrieves a repository by name. Returns the repository config and true if found, or nil and false if not found or Repositories is nil.

func (*CaproniConfig) ReloadersLen

func (c *CaproniConfig) ReloadersLen() int

ReloadersLen returns the number of reloaders. If Reloaders is nil, returns 0.

func (*CaproniConfig) RepositoriesLen

func (c *CaproniConfig) RepositoriesLen() int

RepositoriesLen returns the number of repositories. If Repositories is nil, returns 0.

func (*CaproniConfig) ResolvePath

func (c *CaproniConfig) ResolvePath(path string) string

ResolvePath resolves a path relative to the configuration file directory. If the path is already absolute, it is returned unchanged. If the path is relative, it is resolved relative to ConfigDir.

type DeployerConfig

type DeployerConfig struct {
	Type       string      `yaml:"type"`                 // Required: "helm", etc.
	Repository *string     `yaml:"repository,omitempty"` // Optional: reference to repository name
	EditMode   bool        `yaml:"edit_mode,omitempty"`  // Default: false
	Helm       *HelmConfig `yaml:"helm,omitempty"`       // Required if type=="helm"
}

DeployerConfig for each named deployer (v2 configuration).

type DynamicOverrideConfig

type DynamicOverrideConfig struct {
	Type             string `yaml:"type"`                         // Required: "gitlab_repo_version_files" or "release_manifest"
	GitLabSourceRepo string `yaml:"gitlab_source_repo,omitempty"` // Required if type=="gitlab_repo_version_files"
	VersionMap       string `yaml:"version_map,omitempty"`        // Required if type=="gitlab_repo_version_files"
}

DynamicOverrideConfig for dynamic value overrides. Conditional requirements based on type per schema.

type FilesystemConfig

type FilesystemConfig struct {
	Mode      string            `yaml:"mode,omitempty"`       // Optional: Filesystem mode ("write", "local", "localwithoverrides", "read"). Default: "write"
	ReadWrite []string          `yaml:"read_write,omitempty"` // Optional: Regex patterns for read-write paths
	ReadOnly  []string          `yaml:"read_only,omitempty"`  // Optional: Regex patterns for read-only paths
	Mapping   map[string]string `yaml:"mapping,omitempty"`    // Optional: Path remapping rules (regex pattern -> replacement string)
}

FilesystemConfig specifies filesystem mount configuration for remote filesystems.

type HelmConfig

type HelmConfig struct {
	Namespace        string                  `yaml:"namespace"` // Required
	ValuesFile       string                  `yaml:"values_file,omitempty"`
	DynamicOverrides []DynamicOverrideConfig `yaml:"dynamic_overrides,omitempty"`
	Repository       *HelmRepositoryConfig   `yaml:"repository,omitempty"` // Optional: for non-edit mode
	Release          *HelmReleaseConfig      `yaml:"release,omitempty"`    // Optional: for non-edit mode
}

HelmConfig for Helm chart repositories (namespace required per schema).

type HelmReleaseConfig

type HelmReleaseConfig struct {
	Name  string `yaml:"name"`  // Required: release name
	Chart string `yaml:"chart"` // Required: chart name (e.g., "gitlab/gitlab")
}

HelmReleaseConfig configures the Helm release for non-edit mode deployment.

type HelmRepositoryConfig

type HelmRepositoryConfig struct {
	Name string `yaml:"name"` // Required: name for helm repo add
	URL  string `yaml:"url"`  // Required: URL of the Helm repository
}

HelmRepositoryConfig configures a remote Helm repository for non-edit mode deployment.

type LifecycleHookConfig

type LifecycleHookConfig struct {
	Type         string `yaml:"type"` // Required: "edit_mode_prepare", "edit_mode_start", "edit_mode_stop", "edit_mode_shutdown"
	Script       string `yaml:"script,omitempty"`
	MirrorScript string `yaml:"mirror_script,omitempty"`
	Job          string `yaml:"job,omitempty"`
}

LifecycleHookConfig for lifecycle hooks. Must have exactly one of: script, mirror_script, or job (oneOf in schema).

type MirrorConfig

type MirrorConfig struct {
	Target            *MirrorTargetConfig                            `yaml:"target"`               // Required: Target resource configuration
	Filesystem        *FilesystemConfig                              `yaml:"filesystem,omitempty"` // Optional: Filesystem configuration
	Network           *MirrorNetworkConfig                           `yaml:"network,omitempty"`    // Optional: Network configuration
	EditModeProcesses *orderedmap.OrderedMap[string, *ProcessConfig] `yaml:"edit_mode_processes"`  // Required: At least one process must be defined
	LifecycleHooks    []LifecycleHookConfig                          `yaml:"lifecycle_hooks,omitempty"`
}

MirrorConfig for mirror repositories (target and edit_mode_processes required per schema).

type MirrorNetworkConfig

type MirrorNetworkConfig struct {
	Outgoing *MirrorOutgoingConfig `yaml:"outgoing,omitempty"`
}

MirrorNetworkConfig specifies network interception configuration for mirrord.

type MirrorOutgoingConfig

type MirrorOutgoingConfig struct {
	IgnoreLocalhost bool `yaml:"ignore_localhost,omitempty"`
}

MirrorOutgoingConfig specifies outgoing network interception options.

type MirrorTargetConfig

type MirrorTargetConfig struct {
	Namespace      string `yaml:"namespace"`           // Required: Kubernetes namespace
	KubernetesType string `yaml:"kubernetes_type"`     // Required: "deployment", "statefulset", "daemonset", or "pod"
	Name           string `yaml:"name"`                // Required: Resource name
	Container      string `yaml:"container,omitempty"` // Optional: Target a specific container within the resource
}

MirrorTargetConfig specifies the target Kubernetes resource for mirroring.

type ProcessConfig

type ProcessConfig struct {
	Command string `yaml:"command"`        // Required
	Port    int    `yaml:"port,omitempty"` // Optional (1-65535)
}

ProcessConfig for edit mode processes (command required per schema).

type ReloaderConfig

type ReloaderConfig struct {
	Name       string          `yaml:"-"`                   // Populated by ApplyDefaults from the config key
	Type       string          `yaml:"type"`                // Required: "mirror", "skaffold"
	Repository string          `yaml:"repository"`          // Required: reference to repository name
	EditMode   bool            `yaml:"edit_mode,omitempty"` // Default: false
	Mirror     *MirrorConfig   `yaml:"mirror,omitempty"`    // Required if type=="mirror"
	Skaffold   *SkaffoldConfig `yaml:"skaffold,omitempty"`  // Required if type=="skaffold"
}

ReloaderConfig for each named reloader (v2 configuration).

type RepositoryConfig

type RepositoryConfig struct {
	Repository string `yaml:"repository"` // Required (URI format)
	Directory  string `yaml:"directory"`  // Required
}

RepositoryConfig for each named repository (v2 format). In v2, repositories are simple git repositories without deployment concerns.

type SkaffoldConfig

type SkaffoldConfig struct {
	Namespace  string `yaml:"namespace"`   // Required: Kubernetes namespace
	ConfigFile string `yaml:"config_file"` // Required: Path to skaffold.yaml
}

SkaffoldConfig for skaffold repositories (namespace and config_file required per schema).

Jump to

Keyboard shortcuts

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