Help us shape the future of Go! Take the 2026 Go Developer Survey

cli

package
v0.4.2 Latest Latest
Warning

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

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

Documentation

Overview

Package cli implements karactl, the Karakoram REST API command-line client. Credentials live in ~/.config/karakoram/config.yaml, never in command output. Context values are overridden by KARAKORAM_SERVER/KARAKORAM_TOKEN and then explicit flags. Resource create/set commands accept API-shaped YAML or JSON with -f; '-' reads stdin. Cluster patch files use {spec: {...}} merge patches.

SPDX-License-Identifier: Apache-2.0 Copyright 2026 The Karakoram Authors

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigPath

func ConfigPath() (string, error)

ConfigPath returns the default credential file (independent of XDG overrides).

func ExitCode

func ExitCode(err error) int

ExitCode maps failures to stable shell exit statuses.

func NewCommand

func NewCommand(o Options) *cobra.Command

NewCommand constructs a fresh command tree. ExecuteContext controls waits and SSE.

func Run

func Run(ctx context.Context, o Options, args []string) int

Run executes a fresh command and reports errors on stderr, including usage for command-line mistakes. A nil argument slice uses the process arguments.

func SaveConfig

func SaveConfig(path string, c Config) error

SaveConfig atomically saves credentials with owner-only permissions.

Types

type Config

type Config struct {
	CurrentContext string             `yaml:"currentContext"`
	Contexts       map[string]Context `yaml:"contexts"`
}

Config records the selected context and named connections.

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig loads saved contexts; an absent file is an empty configuration.

type Context

type Context struct {
	Server    string `yaml:"server"`
	Token     string `yaml:"token"`
	TokenID   string `yaml:"tokenID,omitempty"`
	Namespace string `yaml:"namespace,omitempty"`
}

Context is a named server and its API credential.

type Options

type Options struct {
	ConfigPath string
	In         io.Reader
	Out, Err   io.Writer
	// IsTerminal overrides stdin TTY detection for embedding and tests.
	IsTerminal func(io.Reader) bool
}

Options supplies streams and a config location for embedding and testing.

Jump to

Keyboard shortcuts

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