userconfig

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package userconfig reads and writes the installer's per-user state file at ~/.confighub/installer/state.yaml. The file records which "bootstrap" packages (notably kubernetes-resources) the user has already installed into ConfigHub, keyed by organization, so `installer new` can pull from them without re-installing on every invocation.

The file is scoped to one operator, not one organization — entries carry their organizationID so a single laptop signed into multiple orgs has a stable record per (org, package) pair.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns the path the installer writes to: ~/.confighub/installer/state.yaml. Honors $HOME for testing.

func Save

func Save(path string, s *State) error

Save writes state to path, creating the parent directory if needed. Permissions: 0700 on the directory, 0600 on the file — state contains organization IDs but no secrets; defensive nonetheless.

Types

type InstallRecord

type InstallRecord struct {
	Package        string `yaml:"package" json:"package"`
	PackageVersion string `yaml:"packageVersion,omitempty" json:"packageVersion,omitempty"`
	OrganizationID string `yaml:"organizationID" json:"organizationID"`
	Server         string `yaml:"server,omitempty" json:"server,omitempty"`
	SpaceSlug      string `yaml:"spaceSlug" json:"spaceSlug"`
	InstalledAt    string `yaml:"installedAt,omitempty" json:"installedAt,omitempty"`
}

InstallRecord captures one bootstrap install. Keyed on (Package, OrganizationID); ServerURL is informational. SpaceSlug is where the package was uploaded.

type Metadata

type Metadata struct {
	Name string `yaml:"name" json:"name"`
}

type State

type State struct {
	APIVersion string    `yaml:"apiVersion" json:"apiVersion"`
	Kind       string    `yaml:"kind" json:"kind"`
	Metadata   Metadata  `yaml:"metadata" json:"metadata"`
	Spec       StateSpec `yaml:"spec" json:"spec"`
}

State is the on-disk shape of ~/.confighub/installer/state.yaml.

func Load

func Load(path string) (*State, error)

Load reads state from path. Returns an empty State (no installs, not an error) if the file does not exist — a fresh laptop has no prior installs.

func (*State) FindInstall

func (s *State) FindInstall(pkg, orgID string) *InstallRecord

FindInstall returns the install record matching (pkg, orgID), or nil if no such record exists. Empty orgID matches any.

func (*State) UpsertInstall

func (s *State) UpsertInstall(r InstallRecord)

UpsertInstall replaces the existing record matching (pkg, orgID) or appends a new one. InstalledAt is set to now.

type StateSpec

type StateSpec struct {
	// Installs records each (organizationID, package) → Space slug
	// the operator has bootstrapped. `installer new` consults this
	// before pulling so the kubernetes-resources package only gets
	// uploaded once per org.
	Installs []InstallRecord `yaml:"installs,omitempty" json:"installs,omitempty"`
}

Jump to

Keyboard shortcuts

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