config

package
v0.12.0 Latest Latest
Warning

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

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

Documentation

Overview

Package config provides configuration options for bundler implementations.

This package defines the configuration structure and functional options pattern for customizing bundler behavior. All bundlers receive a Config instance that controls their output generation.

Configuration Options

  • Deployer: Deployment method (DeployerHelm or DeployerArgoCD)
  • IncludeReadme: Generate deployment documentation
  • IncludeChecksums: Generate SHA256 checksums.txt file
  • Version: Bundler version string
  • ValueOverrides: Per-bundler value overrides from CLI --set flags
  • Verbose: Enable verbose output

Deployer Types

DeployerType constants define supported deployment methods:

  • DeployerHelm: Generates Helm per-component bundles (default)
  • DeployerArgoCD: Generates Argo CD App of Apps manifests

Use ParseDeployerType() to parse user input and GetDeployerTypes() for CLI help.

Usage

cfg := config.NewConfig(
    config.WithDeployer(config.DeployerHelm),
    config.WithIncludeChecksums(true),
)

Defaults

  • Deployer: DeployerHelm
  • IncludeReadme: true
  • IncludeChecksums: true
  • Version: "dev"

Config is immutable after creation, safe for concurrent use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDeployerTypes

func GetDeployerTypes() []string

GetDeployerTypes returns a sorted slice of all supported deployer types. This is useful for CLI flag validation and usage messages.

Types

type ComponentPath added in v0.12.0

type ComponentPath struct {
	Component string
	Path      string
	Value     *string
}

ComponentPath represents a user-supplied reference to a component's value path, used by --set (component:path=value) and --dynamic (component:path) flags. Value is nil when no "=" was present in the input.

func ParseDynamicValues added in v0.12.0

func ParseDynamicValues(inputs []string) ([]ComponentPath, error)

ParseDynamicValues parses dynamic value declarations in format "component:path.to.field". Returns a slice of ComponentPath where every entry has Value == nil. This function is used by both CLI and API handlers to parse --dynamic flags. Pass the result to WithComponentPaths to apply the declarations to a Config.

func ParseValueOverrides

func ParseValueOverrides(overrides []string) ([]ComponentPath, error)

ParseValueOverrides parses value override strings in format "bundler:path.to.field=value". Returns a slice of ComponentPath where every entry has Value != nil. This function is used by both CLI and API handlers to parse --set flags and query parameters. Pass the result to WithComponentPaths to apply the overrides to a Config.

func (*ComponentPath) HasValue added in v0.12.0

func (c *ComponentPath) HasValue() bool

HasValue reports whether the ComponentPath carries a value (Value != nil). Entries parsed from `--set` / `?set=` always return true; entries parsed from `--dynamic` / `?dynamic=` always return false.

func (*ComponentPath) Parse added in v0.12.0

func (c *ComponentPath) Parse(input string) error

Parse populates the ComponentPath from "component:path" or "component:path=value". Rejects empty component/path, rejects empty value when "=" is present, and rejects path segments that don't match safePathPattern (which guards against template injection and path traversal).

type Config

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

Config provides immutable configuration options for bundlers. All fields are read-only after creation to prevent accidental modifications. Use Clone() to create a modified copy or Merge() to combine configurations.

func NewConfig

func NewConfig(options ...Option) *Config

NewConfig returns a Config with default values.

func (*Config) AcceleratedNodeSelector

func (c *Config) AcceleratedNodeSelector() map[string]string

AcceleratedNodeSelector returns a copy of the accelerated node selector map.

func (*Config) AcceleratedNodeTolerations

func (c *Config) AcceleratedNodeTolerations() []corev1.Toleration

AcceleratedNodeTolerations returns a copy of the accelerated node tolerations.

func (*Config) Attest added in v0.8.0

func (c *Config) Attest() bool

Attest returns whether bundle attestation is enabled.

func (*Config) CertificateIdentityRegexp added in v0.8.0

func (c *Config) CertificateIdentityRegexp() string

CertificateIdentityRegexp returns the custom identity pinning pattern for binary attestation verification, or empty string for the default.

func (*Config) Deployer

func (c *Config) Deployer() DeployerType

Deployer returns the deployment method (DeployerHelm or DeployerArgoCD).

func (*Config) DynamicValues added in v0.12.0

func (c *Config) DynamicValues() map[string][]string

DynamicValues returns a deep copy of the dynamic value declarations.

func (*Config) EstimatedNodeCount added in v0.8.0

func (c *Config) EstimatedNodeCount() int

EstimatedNodeCount returns the estimated number of GPU nodes (0 means unset).

func (*Config) HasDynamicValues added in v0.12.0

func (c *Config) HasDynamicValues() bool

HasDynamicValues returns true if any dynamic value declarations exist.

func (*Config) IncludeChecksums

func (c *Config) IncludeChecksums() bool

IncludeChecksums returns the include checksums setting.

func (*Config) IncludeReadme

func (c *Config) IncludeReadme() bool

IncludeReadme returns the include readme setting.

func (*Config) RepoURL

func (c *Config) RepoURL() string

RepoURL returns the Git repository URL for Argo CD applications.

func (*Config) SystemNodeSelector

func (c *Config) SystemNodeSelector() map[string]string

SystemNodeSelector returns a copy of the system node selector map.

func (*Config) SystemNodeTolerations

func (c *Config) SystemNodeTolerations() []corev1.Toleration

SystemNodeTolerations returns a copy of the system node tolerations.

func (*Config) TargetRevision added in v0.12.0

func (c *Config) TargetRevision() string

TargetRevision returns the target revision for the Argo CD repo.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the Config has valid settings.

func (*Config) ValueOverrides

func (c *Config) ValueOverrides() map[string]map[string]string

ValueOverrides returns a deep copy of the value overrides to prevent modification.

func (*Config) Verbose

func (c *Config) Verbose() bool

Verbose returns the verbose setting.

func (*Config) Version

func (c *Config) Version() string

Version returns the bundler version.

func (*Config) WorkloadGateTaint

func (c *Config) WorkloadGateTaint() *corev1.Taint

WorkloadGateTaint returns a copy of the workload gate taint.

func (*Config) WorkloadSelector

func (c *Config) WorkloadSelector() map[string]string

WorkloadSelector returns a copy of the workload selector map.

type DeployerType

type DeployerType string

DeployerType represents the type of deployment method used for generated bundles.

const (
	// DeployerHelm generates Helm per-component bundles (default).
	DeployerHelm DeployerType = "helm"
	// DeployerArgoCD generates Argo CD App of Apps manifests.
	DeployerArgoCD DeployerType = "argocd"
	// DeployerArgoCDHelm generates a Helm chart app-of-apps for Argo CD.
	// All values are overridable at install time via helm --set.
	// Use --dynamic to pre-populate specific paths in root values.yaml.
	DeployerArgoCDHelm DeployerType = "argocd-helm"
)

Supported deployer types.

func ParseDeployerType

func ParseDeployerType(s string) (DeployerType, error)

ParseDeployerType parses a string into a DeployerType. Returns an error if the string is not a valid deployer type.

func (DeployerType) String

func (d DeployerType) String() string

String returns the string representation of the DeployerType.

type Option

type Option func(*Config)

func WithAcceleratedNodeSelector

func WithAcceleratedNodeSelector(selector map[string]string) Option

WithAcceleratedNodeSelector sets the node selector for accelerated/GPU nodes.

func WithAcceleratedNodeTolerations

func WithAcceleratedNodeTolerations(tolerations []corev1.Toleration) Option

WithAcceleratedNodeTolerations sets the tolerations for accelerated/GPU nodes.

func WithAttest added in v0.8.0

func WithAttest(attest bool) Option

WithAttest enables bundle attestation and binary verification.

func WithCertificateIdentityRegexp added in v0.8.0

func WithCertificateIdentityRegexp(pattern string) Option

WithCertificateIdentityRegexp overrides the default identity pinning pattern for binary attestation verification during bundle creation. The pattern must contain "github.com/NVIDIA/aicr/". This is intended for testing with binaries attested by non-release workflows (e.g., build-attested.yaml).

func WithDeployer

func WithDeployer(deployer DeployerType) Option

WithDeployer sets the deployment method.

func WithDynamicValuePaths added in v0.12.0

func WithDynamicValuePaths(paths []ComponentPath) Option

WithDynamicValuePaths applies a slice of ComponentPath as --dynamic-style declarations. Every entry is expected to have Value == nil; entries with Value != nil are skipped. This is the structured-form equivalent of WithDynamicValues and is typically called with the result of ParseDynamicValues.

func WithDynamicValues added in v0.12.0

func WithDynamicValues(dynamicValues map[string][]string) Option

WithDynamicValues sets the dynamic value declarations for the bundler. Dynamic values are paths that should be provided at install time rather than bundle time.

func WithEstimatedNodeCount added in v0.8.0

func WithEstimatedNodeCount(n int) Option

WithEstimatedNodeCount sets the estimated number of GPU nodes. 0 means unset. Negative values are clamped to 0 for defense-in-depth.

func WithIncludeChecksums

func WithIncludeChecksums(enabled bool) Option

WithIncludeChecksums sets whether a checksums file should be included in the bundle.

func WithIncludeReadme

func WithIncludeReadme(enabled bool) Option

WithIncludeReadme sets whether a README should be included in the bundle.

func WithRepoURL

func WithRepoURL(repoURL string) Option

WithRepoURL sets the Git repository URL for Argo CD applications.

func WithSystemNodeSelector

func WithSystemNodeSelector(selector map[string]string) Option

WithSystemNodeSelector sets the node selector for system components.

func WithSystemNodeTolerations

func WithSystemNodeTolerations(tolerations []corev1.Toleration) Option

WithSystemNodeTolerations sets the tolerations for system components.

func WithTargetRevision added in v0.12.0

func WithTargetRevision(targetRevision string) Option

WithTargetRevision sets the target revision for the Argo CD repo.

func WithValueOverridePaths added in v0.12.0

func WithValueOverridePaths(paths []ComponentPath) Option

WithValueOverridePaths wires the parsed `--set` / `?set=` entries into the config. Pass the result of ParseValueOverrides directly. Each entry must have Value != nil (that is what --set requires); entries with Value == nil are skipped. Map-shaped callers should use WithValueOverrides instead.

func WithValueOverrides

func WithValueOverrides(overrides map[string]map[string]string) Option

WithValueOverrides sets value overrides for the bundler.

func WithVerbose

func WithVerbose(enabled bool) Option

WithVerbose sets whether verbose logging is enabled for the bundler.

func WithVersion

func WithVersion(version string) Option

WithVersion sets the version for the bundler.

func WithWorkloadGateTaint

func WithWorkloadGateTaint(taint *corev1.Taint) Option

WithWorkloadGateTaint sets the taint for nodewright-operator runtime required feature.

func WithWorkloadSelector

func WithWorkloadSelector(selector map[string]string) Option

WithWorkloadSelector sets the label selector for nodewright-customizations to prevent eviction of running training jobs.

Jump to

Keyboard shortcuts

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