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(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 WriteYamlDocSetItemsToDir(fileSet *yamlmeta.DocumentSet, 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, multi-instance laptop workflows, and tests.
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 (config.yaml, secrets/, kind/, resolver/, 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 ¶
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 WriteYamlDocSetItemsToDir ¶
func WriteYamlDocSetItemsToDir(fileSet *yamlmeta.DocumentSet, dir string) error
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.