Documentation
¶
Overview ¶
Package kurelpackage provides a generator for creating kurel packages from Kubernetes manifests with support for values substitution, patches, and conditional extensions.
Overview ¶
The KurelPackage generator (v1alpha1) transforms a collection of Kubernetes manifests into a reusable kurel package. This enables:
- Parameterization via CEL expressions and .Values references
- Conditional resource inclusion via Extensions
- Patch application at build time
- Package dependencies and version management
Configuration ¶
A kurel package is defined using ConfigV1Alpha1:
apiVersion: generators.gokure.dev/v1alpha1
kind: KurelPackage
package:
name: my-app
version: 1.0.0
resources:
- source: ./manifests
includes:
- "*.yaml"
values:
schema:
replicas:
type: integer
default: 1
patches:
- target:
kind: Deployment
name: my-app
patch: |
spec:
replicas: {{ .Values.replicas }}
Values and CEL Expressions ¶
Values can be referenced in patches and extensions using CEL expressions:
# Simple value reference
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
# CEL expression with default
replicas: {{ .Values.replicas || 3 }}
# CEL conditional
{{ if .Values.autoscaling.enabled }}
enabled: true
{{ end }}
Extensions ¶
Extensions enable conditional resource inclusion:
extensions:
- name: ingress
condition: .Values.ingress.enabled
resources:
- source: ./ingress.yaml
When the condition evaluates to true, the extension's resources are included.
Resource Sources ¶
Resources can be loaded from directories or files with glob patterns:
resources:
- source: ./base # Directory
includes: ["*.yaml"] # Glob patterns
excludes: ["*test*"] # Exclusion patterns
recurse: true # Recurse into subdirectories
Generate ¶
The ConfigV1Alpha1.Generate method collects Kubernetes resource files from the package structure produced by ConfigV1Alpha1.GeneratePackageFiles and returns them as []*client.Object, making KurelPackage configs usable in the stack generation pipeline alongside other ApplicationConfig implementations.
GVK Registration ¶
The generator is automatically registered during package initialization:
Group: generators.gokure.dev Version: v1alpha1 Kind: KurelPackage
Usage with kurel CLI ¶
Build a package using the kurel command:
kurel build -f package.yaml -o ./dist
This generates the package directory structure with processed manifests.
Index ¶
- type BuildConfig
- type ConfigV1Alpha1
- func (c *ConfigV1Alpha1) Generate(app *stack.Application) ([]*client.Object, error)
- func (c *ConfigV1Alpha1) GeneratePackageFiles(app *stack.Application) (map[string][]byte, error)
- func (c *ConfigV1Alpha1) GetAPIVersion() string
- func (c *ConfigV1Alpha1) GetKind() string
- func (c *ConfigV1Alpha1) Validate() error
- type Dependency
- type Extension
- type PackageMetadata
- type PatchDefinition
- type PatchTarget
- type ResourceSource
- type ValuesConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildConfig ¶
type BuildConfig struct {
OutputDir string `yaml:"outputDir,omitempty" json:"outputDir,omitempty"` // Output directory for built package
Format string `yaml:"format,omitempty" json:"format,omitempty"` // "directory" or "oci"
Registry string `yaml:"registry,omitempty" json:"registry,omitempty"` // OCI registry for push
Repository string `yaml:"repository,omitempty" json:"repository,omitempty"` // OCI repository name
Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"` // Additional tags
Annotations map[string]string `yaml:"annotations,omitempty" json:"annotations,omitempty"` // OCI annotations
}
BuildConfig defines build-time configuration
type ConfigV1Alpha1 ¶
type ConfigV1Alpha1 struct {
generators.BaseMetadata `yaml:",inline" json:",inline"`
// Package metadata
Package PackageMetadata `yaml:"package" json:"package"`
// Resources to include in the package
Resources []ResourceSource `yaml:"resources,omitempty" json:"resources,omitempty"`
// Patches to apply to resources
Patches []PatchDefinition `yaml:"patches,omitempty" json:"patches,omitempty"`
// Values configuration
Values *ValuesConfig `yaml:"values,omitempty" json:"values,omitempty"`
// Extensions for conditional features
Extensions []Extension `yaml:"extensions,omitempty" json:"extensions,omitempty"`
// Package dependencies
Dependencies []Dependency `yaml:"dependencies,omitempty" json:"dependencies,omitempty"`
// Build configuration
Build *BuildConfig `yaml:"build,omitempty" json:"build,omitempty"`
}
ConfigV1Alpha1 generates a kurel package structure
func (*ConfigV1Alpha1) Generate ¶
func (c *ConfigV1Alpha1) Generate(app *stack.Application) ([]*client.Object, error)
Generate produces Kubernetes resource objects from the package structure. It delegates to ConfigV1Alpha1.GeneratePackageFiles, extracts files under the resources/ prefix, and parses each one into typed client.Object values. Non-resource files (kurel.yaml, patches, values, extensions) are excluded because they are package metadata, not Kubernetes objects.
func (*ConfigV1Alpha1) GeneratePackageFiles ¶
func (c *ConfigV1Alpha1) GeneratePackageFiles(app *stack.Application) (map[string][]byte, error)
GeneratePackageFiles generates the kurel package file structure This is a more appropriate interface for this generator type
func (*ConfigV1Alpha1) GetAPIVersion ¶
func (c *ConfigV1Alpha1) GetAPIVersion() string
GetAPIVersion returns the API version for this config
func (*ConfigV1Alpha1) GetKind ¶
func (c *ConfigV1Alpha1) GetKind() string
GetKind returns the kind for this config
func (*ConfigV1Alpha1) Validate ¶
func (c *ConfigV1Alpha1) Validate() error
Validate checks if the configuration is valid
type Dependency ¶
type Dependency struct {
Name string `yaml:"name" json:"name"`
Version string `yaml:"version" json:"version"` // Semantic version constraint
Repository string `yaml:"repository,omitempty" json:"repository,omitempty"` // OCI repository
Optional bool `yaml:"optional,omitempty" json:"optional,omitempty"`
}
Dependency defines a package dependency
type Extension ¶
type Extension struct {
Name string `yaml:"name" json:"name"`
When string `yaml:"when,omitempty" json:"when,omitempty"` // CEL expression
Resources []ResourceSource `yaml:"resources,omitempty" json:"resources,omitempty"` // Additional resources
Patches []PatchDefinition `yaml:"patches,omitempty" json:"patches,omitempty"` // Additional patches
}
Extension defines a conditional extension
type PackageMetadata ¶
type PackageMetadata struct {
Name string `yaml:"name" json:"name"`
Version string `yaml:"version" json:"version"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Authors []string `yaml:"authors,omitempty" json:"authors,omitempty"`
License string `yaml:"license,omitempty" json:"license,omitempty"`
Homepage string `yaml:"homepage,omitempty" json:"homepage,omitempty"`
Repository string `yaml:"repository,omitempty" json:"repository,omitempty"`
Keywords []string `yaml:"keywords,omitempty" json:"keywords,omitempty"`
Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
}
PackageMetadata contains kurel package metadata
type PatchDefinition ¶
type PatchDefinition struct {
Target PatchTarget `yaml:"target" json:"target"`
Patch string `yaml:"patch" json:"patch"` // JSONPatch or strategic merge patch
Type string `yaml:"type,omitempty" json:"type,omitempty"` // "json" or "strategic", default "json"
}
PatchDefinition defines a patch to apply
type PatchTarget ¶
type PatchTarget struct {
APIVersion string `yaml:"apiVersion,omitempty" json:"apiVersion,omitempty"`
Kind string `yaml:"kind" json:"kind"`
Name string `yaml:"name" json:"name"`
Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"`
Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
}
PatchTarget identifies what to patch
type ResourceSource ¶
type ResourceSource struct {
Source string `yaml:"source" json:"source"` // Directory or file path
Includes []string `yaml:"includes,omitempty" json:"includes,omitempty"` // Include patterns
Excludes []string `yaml:"excludes,omitempty" json:"excludes,omitempty"` // Exclude patterns
Recurse bool `yaml:"recurse,omitempty" json:"recurse,omitempty"` // Recurse into subdirectories
}
ResourceSource defines where to find resources
type ValuesConfig ¶
type ValuesConfig struct {
Schema string `yaml:"schema,omitempty" json:"schema,omitempty"` // Path to JSON schema
Defaults string `yaml:"defaults,omitempty" json:"defaults,omitempty"` // Path to default values
Values interface{} `yaml:"values,omitempty" json:"values,omitempty"` // Inline default values
}
ValuesConfig defines values schema and defaults