components

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package components reads and mutates the platform-components HelmRelease in a Podplane cluster, which is the single source of truth for which Podplane component charts are enabled/installed and which are core.

Index

Constants

View Source
const (
	HelmReleaseName      = "platform-components"
	HelmReleaseNamespace = "platform-components"
)

Helm release coordinates for the platform-components release that is the runtime source of truth for which components are enabled.

Variables

This section is empty.

Functions

func ReadInstallStatuses

func ReadInstallStatuses(ctx context.Context, kubeContext, kubeconfig string, items []InstallItem) (map[string]InstallStatus, error)

ReadInstallStatuses reads all Flux HelmRelease statuses once and returns the current status for the requested items. kubeContext and kubeconfig are optional; empty values use kubectl's defaults.

func RecommendedAddons

func RecommendedAddons() []string

RecommendedAddons returns addon components included by the recommended platform-components seed.

func RequiredItemsReady

func RequiredItemsReady(statuses map[string]InstallStatus, required []InstallItem) bool

RequiredItemsReady reports whether every named required item is Ready in the supplied status snapshot.

func SetEnabled

func SetEnabled(ctx context.Context, kubeContext, kubeconfig string, apps, crds []string, enabled bool) error

SetEnabled patches the platform-components HelmRelease so the given apps and CRDs have spec.values.platform.components.{apps,crds}.<name>.enabled set to the given value. Empty lists are no-ops. kubeContext and kubeconfig are optional; empty values use kubectl's defaults.

Types

type Config

type Config struct {
	Apps map[string]Entry
	CRDs map[string]Entry
}

Config is a snapshot of the platform-components Helm release values that determine which Podplane components are enabled in a cluster.

func Read

func Read(ctx context.Context, kubeContext, kubeconfig string) (*Config, error)

Read returns the platform-components Helm release values, merging chart defaults with any overrides applied by the platform-components HelmRelease. This is what makes `core: true` (declared as a chart default in podplane/components) visible to the CLI even though the HelmRelease only stores user overrides.

kubeContext and kubeconfig are optional; empty values use helm's defaults.

func (*Config) EnabledDependents

func (c *Config) EnabledDependents(name string) []string

EnabledDependents returns the names of currently enabled apps and CRDs whose dependsOn list contains name. Used by uninstall to refuse removing a component that other enabled components depend on.

func (*Config) Get

func (c *Config) Get(name string) (entry Entry, isApp bool, ok bool)

Get returns the entry for name. isApp is true when the entry is an app chart, false when it is a CRD chart. ok is false when name is not present.

func (*Config) Has

func (c *Config) Has(name string) bool

Has returns true when name exists in either Apps or CRDs.

func (*Config) InstallItems

func (c *Config) InstallItems(plan EnableSet) []InstallItem

InstallItems builds watch targets for every app and CRD in an enable plan.

func (*Config) ResolveEnable

func (c *Config) ResolveEnable(name string) (EnableSet, error)

ResolveEnable walks dependsOn transitively to compute the apps and CRDs that must be flipped to enabled=true so that name can be installed.

The returned set excludes entries that are already enabled. If name itself is already enabled and all of its (transitive) dependencies are too, the returned set is empty.

ResolveEnable returns an error when name is not present in the cluster's platform-components values, or when any (transitive) dependency cannot be found there.

type EnableSet

type EnableSet struct {
	Apps []string
	CRDs []string
}

EnableSet is the set of apps and CRDs that must be enabled to install a component. Names are sorted alphabetically.

func (EnableSet) IsEmpty

func (s EnableSet) IsEmpty() bool

IsEmpty reports whether the set is empty.

type Entry

type Entry struct {
	Enabled   bool
	Namespace string
	Core      bool
	DependsOn []string
}

Entry describes one component (app or CRD chart) entry as read from the platform-components Helm release values.

type HelmError

type HelmError struct {
	Stage  string
	Err    error
	Stderr string
}

HelmError is returned when a helm invocation fails. It captures the stage (so callers can format helpful messages) and the helm stderr.

func (*HelmError) Error

func (e *HelmError) Error() string

Error implements the error interface.

func (*HelmError) Unwrap

func (e *HelmError) Unwrap() error

Unwrap returns the underlying exec error so callers can use errors.Is/As.

type InstallItem

type InstallItem struct {
	Name      string
	Namespace string
	Kind      InstallItemKind
}

InstallItem identifies one component HelmRelease that is expected to exist after enabling a component install plan.

type InstallItemKind

type InstallItemKind string

InstallItemKind identifies whether an install status item is an app chart or a CRD chart managed by platform-components.

const (
	// InstallItemApp is a component app HelmRelease.
	InstallItemApp InstallItemKind = "app"
	// InstallItemCRD is a component CRD HelmRelease.
	InstallItemCRD InstallItemKind = "crd"
)

type InstallStatus

type InstallStatus struct {
	Item    InstallItem
	Exists  bool
	Ready   bool
	Status  string
	Message string
}

InstallStatus is the current observed status of one component HelmRelease.

type KubectlError

type KubectlError struct {
	Stage  string
	Err    error
	Stderr string
}

KubectlError is returned when a kubectl invocation fails.

func (*KubectlError) Error

func (e *KubectlError) Error() string

Error implements the error interface.

func (*KubectlError) Unwrap

func (e *KubectlError) Unwrap() error

Unwrap returns the underlying exec error.

Jump to

Keyboard shortcuts

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