scaffolder

package
v5.5.3 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package scaffolder provides utilities for scaffolding KSail project files and configuration.

This package handles the generation and initialization of KSail project structures, including creating cluster configuration files, directory structures, and registry configurations for different Kubernetes distributions (Kind, K3d).

Key functionality:

  • Scaffold: Main orchestration for project file generation
  • GenerateContainerdPatches: Kind mirror registry configuration
  • GenerateK3dRegistryConfig: K3d mirror registry configuration
  • CreateK3dConfig: K3d-specific configuration with CNI and metrics-server settings
  • Distribution-specific config generation (kind.yaml, k3d.yaml, ksail.yaml)
  • Kustomization file generation for GitOps workflows

The Scaffolder struct manages generators for different configuration types and handles the orchestration of file generation with force/overwrite logic.

Index

Constants

View Source
const (

	// KindConfigFile is the default filename for Kind distribution configuration.
	KindConfigFile = "kind.yaml"

	// K3dConfigFile is the default filename for K3d distribution configuration.
	K3dConfigFile = "k3d.yaml"
)

Variables

View Source
var (

	// ErrUnknownDistribution indicates an unsupported distribution was requested.
	ErrUnknownDistribution = errors.New("unknown distribution")

	// ErrKSailConfigGeneration wraps failures when creating ksail.yaml.
	ErrKSailConfigGeneration = errors.New("failed to generate ksail configuration")

	// ErrKindConfigGeneration wraps failures when creating Kind configuration.
	ErrKindConfigGeneration = errors.New("failed to generate kind configuration")

	// ErrK3dConfigGeneration wraps failures when creating K3d configuration.
	ErrK3dConfigGeneration = errors.New("failed to generate k3d configuration")

	// ErrKustomizationGeneration wraps failures when creating kustomization.yaml.
	ErrKustomizationGeneration = errors.New("failed to generate kustomization configuration")
)

Functions

This section is empty.

Types

type GenerationParams

type GenerationParams[T any] struct {
	Gen         generator.Generator[T, yamlgenerator.Options]
	Model       T
	Opts        yamlgenerator.Options
	DisplayName string
	Force       bool
	WrapErr     func(error) error
}

GenerationParams groups parameters for generateWithFileHandling.

type Scaffolder

type Scaffolder struct {
	KSailConfig            v1alpha1.Cluster
	KSailYAMLGenerator     generator.Generator[v1alpha1.Cluster, yamlgenerator.Options]
	KindGenerator          generator.Generator[*v1alpha4.Cluster, yamlgenerator.Options]
	K3dGenerator           generator.Generator[*k3dv1alpha5.SimpleConfig, yamlgenerator.Options]
	KustomizationGenerator generator.Generator[*ktypes.Kustomization, yamlgenerator.Options]
	Writer                 io.Writer
	MirrorRegistries       []string // Format: "name=upstream" (e.g., "docker.io=https://registry-1.docker.io")
}

Scaffolder is responsible for generating KSail project files and configurations.

func NewScaffolder

func NewScaffolder(cfg v1alpha1.Cluster, writer io.Writer, mirrorRegistries []string) *Scaffolder

NewScaffolder creates a new Scaffolder instance with the provided KSail cluster configuration.

func (*Scaffolder) CreateK3dConfig

func (s *Scaffolder) CreateK3dConfig() k3dv1alpha5.SimpleConfig

CreateK3dConfig creates a K3d configuration with distribution-specific settings.

func (*Scaffolder) GenerateContainerdPatches

func (s *Scaffolder) GenerateContainerdPatches() []string

GenerateContainerdPatches generates containerd config patches for Kind mirror registry. Input format: "name=upstream" (e.g., "docker.io=https://registry-1.docker.io") Container names match the registry host after sanitization to align with runtime provisioning.

func (*Scaffolder) GenerateK3dRegistryConfig

func (s *Scaffolder) GenerateK3dRegistryConfig() k3dv1alpha5.SimpleConfigRegistries

GenerateK3dRegistryConfig generates K3d registry configuration for mirror registry. Input format: "name=upstream" (e.g., "docker.io=https://registry-1.docker.io") K3d requires one registry per proxy, so we generate multiple create configs.

func (*Scaffolder) Scaffold

func (s *Scaffolder) Scaffold(output string, force bool) error

Scaffold generates project files and configurations.

This method orchestrates the generation of:

  • ksail.yaml configuration
  • Distribution-specific configuration (kind.yaml or k3d.yaml)
  • kustomization.yaml in the source directory

Parameters:

  • output: The output directory for generated files
  • force: If true, overwrites existing files; if false, skips existing files

Returns:

  • error: Any error encountered during scaffolding

Jump to

Keyboard shortcuts

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