cliconfig

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cliconfig manages the persistent CLI context (active cluster, region, AWS profile) used to avoid passing --cluster on every invocation.

Storage: $XDG_CONFIG_HOME/refresh/context.yaml (default ~/.config/refresh/context.yaml). The schema mirrors kubectx semantics: a named map of contexts, a current pointer, and a previous pointer for `refresh use -`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Path

func Path() (string, error)

Path returns the absolute path of the context file. The directory is not created here; Save creates it on demand.

func Save

func Save(f *File) error

Save writes the file atomically (write temp + rename) so a crash mid-write cannot corrupt an existing config.

Types

type Context

type Context struct {
	Cluster string `yaml:"cluster"`
	Region  string `yaml:"region,omitempty"`
	Profile string `yaml:"profile,omitempty"`
}

Context is a named pointer at an EKS cluster within a region/profile.

type File

type File struct {
	Current  string             `yaml:"current,omitempty"`
	Previous string             `yaml:"previous,omitempty"`
	Contexts map[string]Context `yaml:"contexts,omitempty"`
}

File is the persisted YAML document.

func Load

func Load() (*File, error)

Load reads the context file. A missing file returns an empty File and no error.

func (*File) Active

func (f *File) Active() (name string, ctx Context, ok bool)

Active returns the currently selected context, if any.

Resolution order: REFRESH_CONTEXT env var (per-shell override, kubectx-style) then File.Current. Returns ("", Context{}, false) when nothing is set.

func (*File) Names

func (f *File) Names() []string

Names returns a sorted list of context names.

func (*File) Remove

func (f *File) Remove(name string) error

Remove deletes a context entry. If it was current/previous, those pointers are cleared.

func (*File) Set

func (f *File) Set(name string, c Context) error

Set inserts or replaces a context entry. It does not change the active context.

func (*File) Use

func (f *File) Use(name string) error

Use sets `name` as current and rotates the previous pointer. "-" swaps current with previous (kubectx-style).

Jump to

Keyboard shortcuts

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