config

package
v0.0.0-...-60784e1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DefaultLocalConfigModeline = `# yaml-language-server: $schema=` + v1alpha1.SchemaBaseURL + v1alpha1.KindEducatesLocalConfig + `.json`

DefaultLocalConfigModeline is the yaml-language-server modeline that points editors at the published EducatesLocalConfig schema for completion and validation.

View Source
const DefaultLocalConfigYAML = DefaultLocalConfigModeline + `
apiVersion: ` + v1alpha1.APIVersion + `
kind: ` + v1alpha1.KindEducatesLocalConfig + `
`

DefaultLocalConfigYAML is the minimal EducatesLocalConfig — modeline, apiVersion and kind only — written by `local config init` and by `local cluster create` when no config exists yet. Every other field takes its default at deploy time.

Variables

This section is empty.

Functions

func EnsureLocalConfigFile

func EnsureLocalConfigFile(dataHome string) error

EnsureLocalConfigFile is the single entry point for commands that read <data-home>/config.yaml. It composes the v3-to-v4 migration shim with the user-actionable missing-file diagnostic:

  • config.yaml exists → return nil (proceed to Load).
  • config.yaml missing → attempt v3 → v4 migration. If the v3 migration writes a fresh config.yaml, return nil. If migration refuses (provider isn't laptop-kind), surface that error.
  • config.yaml still missing after migration attempt → return MissingLocalConfigError (first-time user / partial init).

func EnsureOrInitLocalConfigFile

func EnsureOrInitLocalConfigFile(dataHome string) (created bool, err error)

EnsureOrInitLocalConfigFile is the cluster-create counterpart to EnsureLocalConfigFile: where the latter returns MissingLocalConfigError for a first-time user, this one writes the minimal default EducatesLocalConfig in its place so `local cluster create` runs end-to-end without a preceding `local config init`. It reports whether it created the file so the caller can tell the user.

The v3 → v4 migration still runs first and still wins: a laptop-kind v3 values.yaml is migrated (created=false), and a non-laptop v3 values.yaml still errors out of MaybeMigrateV3 — we never write a default over a real, if unmigratable, v3 install. The write below is reached only when there is genuinely no prior config to honour.

func Load

func Load(path string) (v1alpha1.Config, error)

Load reads a CLI config file, validates its apiVersion/kind, runs JSON schema validation, then strict-unmarshals into the typed struct. The returned value implements v1alpha1.Config; callers type-switch to the concrete kind.

func LoadBytes

func LoadBytes(data []byte, source string) (v1alpha1.Config, error)

LoadBytes is the path-free variant — useful for stdin and tests. The source string is woven into error messages so users can locate the file.

Single-pass: one yaml.Unmarshal → normalise → json.Marshal. The JSON bytes drive both schema validation and the typed strict decode (via json.Decoder.DisallowUnknownFields, which is the json equivalent of yaml.UnmarshalStrict's behaviour around unknown fields).

func LoadLocal

func LoadLocal(path string) (*v1alpha1.EducatesLocalConfig, error)

LoadLocal is the typed convenience wrapper for callers that only accept EducatesLocalConfig (e.g. `educates local config *` commands).

func MaybeMigrateV3

func MaybeMigrateV3(dataHome string) error

MaybeMigrateV3 attempts to translate a v3 values.yaml in dataHome into a v4 config.yaml in the same dir. Returns nil in three cases:

  1. dataHome has no values.yaml — nothing to migrate (first-time user).
  2. dataHome has config.yaml — already migrated (or never had v3).
  3. dataHome has values.yaml + provider ∈ {"", "kind"} — migration ran successfully (config.yaml written, values.yaml renamed to values.yaml.v3-backup).

Returns a user-actionable error when values.yaml is present without config.yaml AND the provider is anything else (gke, eks, openshift, etc.): the laptop translator only handles the kind case, so non-laptop installs need to be re-declared by hand against the v4 kind ladder.

Callers (render, deploy, cluster create) invoke this before falling through to MissingLocalConfigError so a successful migration is transparent — the user runs the same command they would have on v3, it just works on v4 going forward.

Prints a one-line notice on stderr-style output so the user knows the migration happened (the design calls for "silent" in the sense of "no prompt", not "invisible").

func MissingLocalConfigError

func MissingLocalConfigError(dataHome string) error

MissingLocalConfigError diagnoses why <data-home>/config.yaml is missing and returns a user-actionable error. Three cases:

  1. v3 `values.yaml` exists alongside the missing config.yaml — the user is on a pre-v4 data home and needs the migration shim.
  2. The data home directory itself doesn't exist — first-time user.
  3. The directory exists but config.yaml is missing — initialised data home (e.g. secrets/ present from past CLI runs) but no v4 config yet.

Returns nil if the data home looks healthy and config.yaml is present; callers should not invoke this in that case (the loader handles it).

Types

This section is empty.

Directories

Path Synopsis
Package explain renders kubectl-explain-style field documentation from a JSON Schema.
Package explain renders kubectl-explain-style field documentation from a JSON Schema.
Package hostinfo derives runtime host information used by laptop-mode CLI defaulting (e.g.
Package hostinfo derives runtime host information used by laptop-mode CLI defaulting (e.g.
Package translator converts a CLI config kind into the deployable outputs: operator chart values + the four platform CRs (EducatesClusterConfig, SecretsManager, LookupService, SessionManager).
Package translator converts a CLI config kind into the deployable outputs: operator chart values + the four platform CRs (EducatesClusterConfig, SecretsManager, LookupService, SessionManager).
Package v1alpha1 defines the CLI-facing configuration kinds for the Educates v4 installer.
Package v1alpha1 defines the CLI-facing configuration kinds for the Educates v4 installer.
schemas
Package schemas embeds the JSON schemas for the cli.educates.dev/v1alpha1 config kinds.
Package schemas embeds the JSON schemas for the cli.educates.dev/v1alpha1 config kinds.

Jump to

Keyboard shortcuts

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