configedit

package
v0.4.163 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 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")
	// ErrReviewerCredentialsNotConfigured means reviewer credentials are absent.
	ErrReviewerCredentialsNotConfigured = errors.New("reviewer credentials are not configured")
)
View Source
var (
	// ErrSecretsProfileIDRequired means a secrets-profile id was omitted.
	ErrSecretsProfileIDRequired = errors.New("secrets-profile id is required")
	// ErrSecretsProfileReserved means the caller targeted a reserved projected id.
	ErrSecretsProfileReserved = errors.New("secrets-profile id is reserved")
	// ErrSecretsProfileBackendRequired means a create operation omitted the backend.
	ErrSecretsProfileBackendRequired = errors.New("secrets-profile backend is required")
	// ErrSecretsProfileMutationRequired means an update operation omitted mutation flags.
	ErrSecretsProfileMutationRequired = errors.New("secrets-profile mutation is required")
	// ErrSecretsProfileLabelConflict means both set and clear label were requested.
	ErrSecretsProfileLabelConflict = errors.New("secrets-profile label flags conflict")
	// ErrSecretsProfileLabelRequired means a provided label was blank after trim.
	ErrSecretsProfileLabelRequired = errors.New("secrets-profile label is required")
	// ErrSecretsProfileDefaultConfigured means the target profile is still the configured default.
	ErrSecretsProfileDefaultConfigured = errors.New("secrets-profile is the configured default")
)

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 ClearLLMCredentialRef

func ClearLLMCredentialRef(profile config.Profile) (config.Profile, bool)

ClearLLMCredentialRef clears the optional LLM credential ref.

func ClearReviewerCredentials

func ClearReviewerCredentials(profile config.Profile) (config.Profile, bool)

ClearReviewerCredentials removes the optional reviewer credential section.

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 NormalizeSecretsProfileID added in v0.3.147

func NormalizeSecretsProfileID(raw string) (string, error)

NormalizeSecretsProfileID trims and validates one secrets-profile 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 RemoveSecretsProfile added in v0.3.147

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

RemoveSecretsProfile removes one explicit named secrets-management profile.

func RenameProfile

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

RenameProfile renames a profile and updates default-profile and route references.

func ResetAgentSources

func ResetAgentSources(existing []string) ([]string, bool)

ResetAgentSources clears agent sources while reporting whether anything changed.

func ResetModelMap

func ResetModelMap(profile config.Profile) (config.Profile, bool)

ResetModelMap clears profile-specific model mappings.

func SetDefaultProfile

func SetDefaultProfile(cfg config.File, profileName string) (config.File, bool, error)

SetDefaultProfile updates cfg.default_profile after verifying the profile exists.

func SetDefaultSecretsProfile added in v0.3.147

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

SetDefaultSecretsProfile updates cfg.secrets.default_profile after verifying the profile exists.

func SetGitCredentialRef

func SetGitCredentialRef(profile config.Profile, ref string) (config.Profile, bool)

SetGitCredentialRef updates the profile's required git credential ref.

func SetLLMCredentialRef

func SetLLMCredentialRef(profile config.Profile, ref string) (config.Profile, bool)

SetLLMCredentialRef updates the profile's LLM credential ref.

func SetRepositoryRoutes

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

SetRepositoryRoutes assigns the specified routes to profileName.

func SetReviewerCredentialRef

func SetReviewerCredentialRef(profile config.Profile, ref string) (config.Profile, bool, error)

SetReviewerCredentialRef updates the reviewer credential ref when the section exists.

func SetSecretsProfile added in v0.3.147

func SetSecretsProfile(cfg config.File, rawID string, patch SecretsProfilePatch) (config.File, bool, bool, error)

SetSecretsProfile creates or updates one named secrets-management profile.

func UnsetDefaultSecretsProfile added in v0.3.147

func UnsetDefaultSecretsProfile(cfg config.File) (config.File, bool, error)

UnsetDefaultSecretsProfile clears cfg.secrets.default_profile.

func UnsetRepositoryRoutes

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

UnsetRepositoryRoutes removes the specified routes.

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 SecretsProfilePatch added in v0.3.147

type SecretsProfilePatch struct {
	Backend    *config.SecretsProfileBackend
	Label      *string
	ClearLabel bool
}

SecretsProfilePatch describes a config-only update to one named secrets-management profile.

Jump to

Keyboard shortcuts

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