Documentation
¶
Index ¶
- Constants
- func BoolPointer(b bool) *bool
- func CmdError(cmd *cobra.Command, errorMessage string, additionalMessage string) error
- func CmdErrorFullUsage(cmd *cobra.Command, errorMessage string, additionalMessage string) error
- func GetContainerName(c container.Summary) string
- func GetEducatesHomeDir() string
- func PrintExportedDocuments(documents []ExportedYAMLDocument) error
- func PrintKeyValuesTable(rows [][]string) string
- func PrintTable(headers []string, rows [][]string) string
- func PrintYamlFilesInDir(w io.Writer, dir string, args []string) error
- func RenderResourceAsYAMLDocument(resource *unstructured.Unstructured) ([]byte, error)
- func SanitizeResourceForExport(resource *unstructured.Unstructured) *unstructured.Unstructured
- func SanitizeTrainingPortalResourceForExport(resource *unstructured.Unstructured) *unstructured.Unstructured
- func SanitizeWorkshopResourceForExport(resource *unstructured.Unstructured, cfg *WorkshopResourceExportConfig) *unstructured.Unstructured
- func ValidateAndResolveIP(bindIP string) (string, error)
- func WriteExportedDocuments(dir string, documents []ExportedYAMLDocument) error
- func WriteYamlByteArrayItemsToDir(files [][]byte, dir string) error
- func YesNoPrompt(label string, def bool) bool
- type ExportedYAMLDocument
- type WorkshopResourceExportConfig
Constants ¶
const EducatesCLIDataHomeEnv = "EDUCATES_CLI_DATA_HOME"
EducatesCLIDataHomeEnv overrides the on-disk home for all Educates CLI state. When set and non-empty, it takes precedence over the default xdg.DataHome/educates location. Useful for CI and tests.
A second data home is not a way to run several local clusters side by side: it still creates the default kind cluster, binds the same host ports and manages the same registry, resolver and mirror containers as the first. Named local clusters, which share one data home, run side by side instead.
Variables ¶
This section is empty.
Functions ¶
func BoolPointer ¶
func CmdError ¶
CmdError builds an error for a failed command-argument validation. It is meant to be returned from a cobra command's Args function so that an invalid invocation reports a clear message followed by the command path (with a usage hint) and a pointer to --help, rather than cobra's terse default ("accepts 1 arg(s), received 0").
additionalMessage is the positional-argument hint appended after the command path, e.g. "NAME" so the user sees the expected argument.
func CmdErrorFullUsage ¶
CmdErrorFullUsage is like CmdError but appends the command's full usage string instead of a single hint line. Prefer it for commands that take several positional arguments, where the full usage is clearer than a short hint.
func GetContainerName ¶
GetContainerName returns a container's primary name with the leading slash Docker prefixes stripped, or "unknown" when the container has no name.
func GetEducatesHomeDir ¶
func GetEducatesHomeDir() string
GetEducatesHomeDir returns the on-disk home for all Educates CLI state (the default local cluster's config.yaml and kind config file, clusters/ for named local clusters, secrets/, dnsmasq.conf, compose/, workshops/).
Resolution order:
- $EDUCATES_CLI_DATA_HOME if set and non-empty.
- $XDG_DATA_HOME/educates/ (default).
func PrintExportedDocuments ¶
func PrintExportedDocuments(documents []ExportedYAMLDocument) error
PrintExportedDocuments writes the documents to stdout as a single YAML stream, separating them with '---'.
func PrintKeyValuesTable ¶
PrintKeyValuesTable renders an aligned "Key: value" table (one row per key/value pair) as a string, without a trailing newline. Each row must be a two-element slice of {key, value}.
func PrintTable ¶
PrintTable renders a simple aligned text table with the given headers and rows, returning it as a string (without a trailing newline). Empty cells are rendered as blank while keeping their column, so callers can leave a value unset without breaking alignment.
func PrintYamlFilesInDir ¶
PrintYamlFilesInDir writes to w the YAML files in dir, each after a "---" line: all of them, or only those named, without the .yaml suffix, in args.
func RenderResourceAsYAMLDocument ¶
func RenderResourceAsYAMLDocument(resource *unstructured.Unstructured) ([]byte, error)
RenderResourceAsYAMLDocument marshals an unstructured resource to a YAML document.
func SanitizeResourceForExport ¶
func SanitizeResourceForExport(resource *unstructured.Unstructured) *unstructured.Unstructured
SanitizeResourceForExport returns a deep copy of resource with the cluster-managed fields removed (status, and the server-populated metadata fields) so the result is a clean, re-appliable manifest.
func SanitizeTrainingPortalResourceForExport ¶
func SanitizeTrainingPortalResourceForExport(resource *unstructured.Unstructured) *unstructured.Unstructured
SanitizeTrainingPortalResourceForExport removes portal fields that should not be carried across clusters, in addition to the common sanitization (currently the generated portal password).
func SanitizeWorkshopResourceForExport ¶
func SanitizeWorkshopResourceForExport(resource *unstructured.Unstructured, cfg *WorkshopResourceExportConfig) *unstructured.Unstructured
SanitizeWorkshopResourceForExport rewrites a Workshop resource for export: it substitutes the $(image_repository) and $(workshop_version) variables with the supplied values, records the version under spec.version when it isn't already set (and isn't "latest"), and drops the spec.publish block (a build-time concern that shouldn't ship in an exported workshop).
func ValidateAndResolveIP ¶
*
- This function is used to validate and resolve an IP address.
- It is used when creating a new local registry or registry mirror.
func WriteExportedDocuments ¶
func WriteExportedDocuments(dir string, documents []ExportedYAMLDocument) error
WriteExportedDocuments writes each document to dir/<doc.Name>, creating the directory if needed.
func YesNoPrompt ¶
YesNoPrompt prompts the user for a yes/no answer to a question. It returns true if the user answers yes, false if the user answers no, and the default value if the user does not answer.
Types ¶
type ExportedYAMLDocument ¶
ExportedYAMLDocument is a single named YAML document produced by an export. Name is used as the file name when writing to a directory; Data is the YAML body.
type WorkshopResourceExportConfig ¶
WorkshopResourceExportConfig controls how a Workshop resource is rewritten on export.