extras

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package extras loads raw Kubernetes manifests and CRDs from .deployah/, merges Deployah identity metadata into extra manifests, injects those manifests into a Helm release via a post-renderer, and copies CRD source files unchanged into the generated chart crds/ directory. CRD YAML is parsed only for presentation identity (kind and metadata.name).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CRDDisplayPath added in v0.9.0

func CRDDisplayPath(path string) string

CRDDisplayPath returns the stable .deployah/crds/<basename> path shown in plan output for a CRD source file.

Types

type Bundle

type Bundle struct {
	// Manifests are objects from .deployah/manifests/ for the selected environment.
	Manifests []Object
	// CRDs are one entry per source file under .deployah/crds/. Bytes are
	// the exact file contents Helm copies into the chart.
	CRDs []RawFile
	// CRDDocs is presentation identity for every non-empty CRD document.
	// Load parses only kind and metadata.name.
	CRDDocs []CRDDoc
}

Bundle holds the deploy-ready extras for one environment.

func Load

func Load(cfg LoadConfig) (*Bundle, error)

Load reads .deployah/manifests and .deployah/crds under SpecDir and returns a deploy-ready Bundle. It validates extra manifests and merges Deployah identity metadata into them. Chart CRD files are kept as exact bytes for Helm. Each CRD YAML document is parsed only for presentation identity (kind and metadata.name). Missing directories yield an empty Bundle with a nil error.

func LoadFromSpec

func LoadFromSpec(specPath string, spc *spec.Spec, platform *spec.PlatformConfig, environment, releaseNamespace string, cfg *rest.Config) (*Bundle, error)

LoadFromSpec loads extras for a deploy/plan of the given spec. specPath is the path to deployah.yaml. When cfg is non-nil, live discovery is used for scope resolution; otherwise Offline is set so unknown types are not rejected. Scope comes from the built-in table and live discovery, not from .deployah/crds/ content.

func (*Bundle) PostRendererFor

func (b *Bundle) PostRendererFor() postrenderer.PostRenderer

PostRendererFor returns a Helm post-renderer for the bundle's manifests, or a true nil interface when there are none (avoids a typed-nil *PostRenderer).

type CRDDoc added in v0.9.0

type CRDDoc struct {
	Path  string
	Index int
	Kind  string
	Name  string
	YAML  []byte
}

CRDDoc is presentation identity for one YAML document in a RawFile. Index is the 0-based non-empty document number in that file. YAML is the original document bytes; it is never marshaled back for Helm.

type DiscoveryResolver

type DiscoveryResolver struct {
	Mapper meta.RESTMapper
	Table  TableResolver
}

DiscoveryResolver wraps a RESTMapper and falls back to TableResolver.

func (*DiscoveryResolver) Known

Known implements ScopeResolver.

func (*DiscoveryResolver) Namespaced

func (r *DiscoveryResolver) Namespaced(gvk schema.GroupVersionKind) (bool, error)

Namespaced implements ScopeResolver.

type Identity

type Identity struct {
	APIVersion string
	Kind       string
	Namespace  string
	Name       string
}

Identity uniquely identifies a Kubernetes object for collision checks.

func (Identity) Key

func (id Identity) Key() string

Key returns a stable map key for identity comparisons.

func (Identity) String

func (id Identity) String() string

String returns a human-readable identity for error messages.

type LoadConfig

type LoadConfig struct {
	// SpecDir is the directory containing deployah.yaml (and .deployah/).
	SpecDir string
	// Project is the project name for identity annotations/labels.
	Project string
	// Environment is the runtime environment (e.g. review/pr-123).
	Environment string
	// DeclaredEnvs are the registry keys used to validate manifests/<env>/ dirs.
	DeclaredEnvs []string
	// ReleaseNamespace fills empty metadata.namespace on namespaced objects.
	ReleaseNamespace string
	// Scope resolves namespaced vs cluster-scoped. Required.
	Scope ScopeResolver
	// Offline is true when no REST config is available. Unknown types are
	// then allowed and default to namespaced scope.
	Offline bool
}

LoadConfig configures Load.

type Object

type Object struct {
	Path string
	Raw  []byte
	Obj  *unstructured.Unstructured
}

Object is one Kubernetes document loaded from an extras file.

func (*Object) GVK

func (o *Object) GVK() schema.GroupVersionKind

GVK returns the object's GroupVersionKind.

func (*Object) Identity

func (o *Object) Identity() Identity

Identity returns the object's identity, using an empty namespace for cluster-scoped resources that have none set.

func (*Object) MarshalYAML

func (o *Object) MarshalYAML() ([]byte, error)

MarshalYAML serializes the object back to YAML bytes.

type PostRenderer

type PostRenderer struct {
	Manifests []Object
}

PostRenderer appends literal extra manifests to Helm's rendered stream. Extra YAML never passes through the template engine, so `{{ }}` is preserved.

func (*PostRenderer) Run

func (p *PostRenderer) Run(renderedManifests *bytes.Buffer) (*bytes.Buffer, error)

Run implements helm.sh/helm/v4/pkg/postrenderer.PostRenderer.

type RawFile added in v0.9.0

type RawFile struct {
	Path string
	Raw  []byte
}

RawFile is one source file under .deployah/crds/. Raw is the exact file bytes Helm copies into the chart. Presentation identity lives on CRDDoc, not here, so Helm transport cannot consult spec fields.

type ScopeResolver

type ScopeResolver interface {
	// Known reports whether gvk is a built-in kind or present in live
	// discovery.
	Known(gvk schema.GroupVersionKind) (bool, error)
	// Namespaced reports whether gvk is namespaced. When Known is false and
	// discovery is unavailable, callers may still use this; unknown kinds
	// default to namespaced.
	Namespaced(gvk schema.GroupVersionKind) (bool, error)
}

ScopeResolver reports whether a GVK is known and whether it is namespaced.

func NewDiscoveryResolver

func NewDiscoveryResolver(cfg *rest.Config) (ScopeResolver, error)

NewDiscoveryResolver builds a ScopeResolver from a rest.Config. When cfg is nil, it returns a table-only resolver.

type TableResolver

type TableResolver struct{}

TableResolver resolves scope from a built-in group/kind table. Unknown kinds are not Known; Namespaced defaults them to namespaced when called anyway.

func (*TableResolver) Known

func (r *TableResolver) Known(gvk schema.GroupVersionKind) (bool, error)

Known implements ScopeResolver.

func (*TableResolver) Namespaced

func (r *TableResolver) Namespaced(gvk schema.GroupVersionKind) (bool, error)

Namespaced implements ScopeResolver.

Jump to

Keyboard shortcuts

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