Documentation
¶
Overview ¶
Package config loads and resolves the cinc CLI credentials file: a TOML document holding a set of named connection profiles, in the same shape as Chef's `~/.chef/credentials` file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
DefaultPath returns the default credentials file location, ~/.cinc/credentials.
func ValidateSiteURL ¶
func WriteProfile ¶
WriteProfile creates or updates one profile in the credentials file at path. Other profiles are left untouched, and within the profile being written only the keys cinc manages are rewritten; anything else the file holds is carried across verbatim. Comments and original key ordering are not retained, because the file is re-encoded as TOML.
Types ¶
type Config ¶
Config is the parsed contents of a cinc credentials file.
func Load ¶
Load reads and parses the credentials file at path. Each top-level TOML section becomes a named profile.
func (*Config) Profile ¶
Profile resolves a connection profile by name. An empty name selects the profile named by $CINC_PROFILE, then $CHEF_PROFILE, falling back to "default". When both env vars are set CINC_PROFILE wins.
func (*Config) Validate ¶
func (c *Config) Validate() []ValidationIssue
Validate reports configuration problems across every loaded profile. It is intentionally local-only: it validates TOML shape and URL/profile fields but does not perform network calls or authenticate.
type Profile ¶
type Profile struct {
ServerURL string
Org string
SupermarketSite string
ClientName string
KeyPath string
SSLVerifyMode string
// SupermarketClientName and SupermarketKey optionally override the
// identity used to sign Chef Supermarket uploads, so a user can
// publish to the public Supermarket under a different username or key
// than the one they use against their Cinc Server. Each field falls
// back independently: the effective Supermarket username is
// SupermarketClientName or, when empty, ClientName; the effective key
// is SupermarketKey or, when empty, KeyPath. These are cinc-only keys
// (knife has no equivalent). See SupermarketIdentity.
SupermarketClientName string
SupermarketKey string
// SecretFile is the path to the encrypted data bag secret used to
// encrypt and decrypt `cinc databag secret` items. The on-disk key
// is `secret_file`, matching knife's `knife[:secret_file]`, so the
// same key serves cinc and chef users.
SecretFile string
// RawServerURL is the server URL exactly as written in the config, before
// it is split into ServerURL + Org. It is preserved even when the URL is
// malformed (ServerURL/Org are then empty) so validation can report the
// precise problem instead of the whole load failing.
RawServerURL string
}
Profile describes how to connect to a single Cinc Server. It is the resolved form of an on-disk credentials entry: the configured server URL has already been split into a bare server URL and an organization name.
func NewProfile ¶
func NewProfile(serverURL, clientName, clientKey, sslVerifyMode, supermarketSite string) (Profile, error)
NewProfile builds a Profile from user-supplied configure values.
func (Profile) SupermarketIdentity ¶
SupermarketIdentity returns the username and key path used to sign Chef Supermarket uploads. Each field falls back independently: the username is supermarket_client_name or, when unset, client_name; the key is supermarket_key or, when unset, client_key. This lets a user publish to the public Supermarket under a different identity than their Cinc Server client while overriding only the field that differs.
func (Profile) Validate ¶
Validate reports whether the profile has every field required to open a server connection.
func (Profile) ValidateIdentity ¶
ValidateIdentity reports whether the profile has the fields needed to sign requests that target a Cinc Server organization.
func (Profile) ValidateSupermarketIdentity ¶
ValidateSupermarketIdentity reports whether the profile resolves to an identity that can sign Supermarket uploads, accounting for the supermarket_client_name/supermarket_key overrides and their fallback to client_name/client_key.
type ValidationIssue ¶
type ValidationIssue struct {
Profile string `json:"profile"`
Field string `json:"field"`
Message string `json:"message"`
}
ValidationIssue describes one profile-level configuration problem.