configedit

package
v0.10.257 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package configedit provides reusable config mutation helpers.

This package owns pure config data transforms only. Keep command parsing, Cobra/view dependencies, keyring operations, and exit-code mapping in command packages such as configcmd.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRouteHostRequired means a repository route host was omitted.
	ErrRouteHostRequired = errors.New("route host is required")
	// ErrRouteNamespaceRequired means a repository route namespace was omitted.
	ErrRouteNamespaceRequired = errors.New("route namespace is required")
	// ErrRouteRepoRequired means an explicitly supplied repository route repo was blank.
	ErrRouteRepoRequired = errors.New("route repo is required")
	// ErrAgentSourcePathRequired means an agent source path was omitted.
	ErrAgentSourcePathRequired = errors.New("agent source path is required")
	// ErrProfileNameRequired means a profile name was omitted.
	ErrProfileNameRequired = errors.New("profile name is required")
	// ErrProfileExists means the destination profile already exists.
	ErrProfileExists = errors.New("profile already exists")
)
View Source
var (
	// ErrSecretsStoreIDRequired means a credential-store id was omitted.
	ErrSecretsStoreIDRequired = errors.New("secrets-profile id is required")
	// ErrSecretsStoreReserved means the caller targeted a reserved projected id.
	ErrSecretsStoreReserved = errors.New("secrets-profile id is reserved")
	// ErrSecretsStoreBackendRequired means a create operation omitted the backend.
	ErrSecretsStoreBackendRequired = errors.New("secrets-profile backend is required")
	// ErrSecretsStoreMutationRequired means an update operation omitted mutation flags.
	ErrSecretsStoreMutationRequired = errors.New("secrets-profile mutation is required")
	// ErrSecretsStoreLabelConflict means both set and clear label were requested.
	ErrSecretsStoreLabelConflict = errors.New("secrets-profile label flags conflict")
	// ErrSecretsStoreLabelRequired means a provided label was blank after trim.
	ErrSecretsStoreLabelRequired = errors.New("secrets-profile label is required")
)

Functions

func AddAgentSource

func AddAgentSource(existing []string, raw string) ([]string, bool, error)

AddAgentSource appends raw when an equivalent normalized path is absent.

func CanonicalRepositoryRoutes

func CanonicalRepositoryRoutes(routes []config.RepositoryProfile) []config.RepositoryProfile

CanonicalRepositoryRoutes returns normalized repository routes in stable order.

func FirstProfileName

func FirstProfileName(profiles map[string]config.Profile) string

FirstProfileName returns the lexicographically first profile name.

func FormatRepositoryRouteSpec

func FormatRepositoryRouteSpec(spec RepositoryRouteSpec) string

FormatRepositoryRouteSpec returns a stable domain representation of a route.

func NormalizeAgentSourcePath

func NormalizeAgentSourcePath(raw string) (string, error)

NormalizeAgentSourcePath trims and cleans an agent source path.

func NormalizeRepositoryRouteRepos

func NormalizeRepositoryRouteRepos(raw []string) ([]string, error)

NormalizeRepositoryRouteRepos trims, dedupes, and sorts repository names.

func NormalizeSecretsStoreID added in v0.10.238

func NormalizeSecretsStoreID(raw string) (string, error)

NormalizeSecretsStoreID trims and validates one credential-store id.

func PruneRepositoryProfileRoutes

func PruneRepositoryProfileRoutes(routes []config.RepositoryProfile, profileName string) []config.RepositoryProfile

PruneRepositoryProfileRoutes removes all repository routes pointing at profileName.

func RemoveAgentSource

func RemoveAgentSource(existing []string, raw string) ([]string, bool, error)

RemoveAgentSource removes entries that normalize to raw.

func RemoveSecretsStore added in v0.10.238

func RemoveSecretsStore(cfg config.File, rawID string) (config.File, bool, error)

RemoveSecretsStore removes one explicit named credential store.

func RenameProfile

func RenameProfile(cfg config.File, oldName string, newName string) (config.File, bool, error)

RenameProfile renames a profile and updates route references.

func SetRepositoryRoutes

func SetRepositoryRoutes(routes []config.RepositoryProfile, profileName string, spec RepositoryRouteSpec) ([]config.RepositoryProfile, error)

SetRepositoryRoutes assigns the specified routes to profileName.

func SetSecretsStore added in v0.10.238

func SetSecretsStore(cfg config.File, rawID string, patch SecretsStorePatch) (config.File, bool, bool, error)

SetSecretsStore creates or updates one named credential store.

func UnsetRepositoryRoutes

func UnsetRepositoryRoutes(routes []config.RepositoryProfile, spec RepositoryRouteSpec) ([]config.RepositoryProfile, bool, error)

UnsetRepositoryRoutes removes the specified routes.

func UnsetRepositoryRoutesForProfile added in v0.9.192

func UnsetRepositoryRoutesForProfile(routes []config.RepositoryProfile, profileName string, spec RepositoryRouteSpec) ([]config.RepositoryProfile, bool, error)

UnsetRepositoryRoutesForProfile removes the specified routes only for profileName.

func UpdateRepositoryProfileReferences

func UpdateRepositoryProfileReferences(routes []config.RepositoryProfile, oldName string, newName string) ([]config.RepositoryProfile, bool)

UpdateRepositoryProfileReferences renames route profile references.

Types

type RepositoryRouteSpec

type RepositoryRouteSpec struct {
	Host      string
	Namespace string
	Repos     []string
}

RepositoryRouteSpec identifies one namespace route or one set of repo routes.

func NormalizeRepositoryRouteSpec

func NormalizeRepositoryRouteSpec(spec RepositoryRouteSpec) (RepositoryRouteSpec, error)

NormalizeRepositoryRouteSpec returns a normalized copy of spec.

type SecretsStorePatch added in v0.10.238

type SecretsStorePatch struct {
	Backend    *config.SecretsStoreBackend
	Label      *string
	ClearLabel bool
}

SecretsStorePatch describes a config-only update to one named credential store.

Jump to

Keyboard shortcuts

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