config

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func DefaultPath() (string, error)

DefaultPath returns the default credentials file location, ~/.cinc/credentials.

func ValidateSiteURL

func ValidateSiteURL(raw string) error

func WriteProfile

func WriteProfile(path, name string, p Profile) error

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

type Config struct {
	Profiles map[string]Profile
}

Config is the parsed contents of a cinc credentials file.

func Load

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

Load reads and parses the credentials file at path. Each top-level TOML section becomes a named profile.

func (*Config) Profile

func (c *Config) Profile(name string) (Profile, error)

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

func (p Profile) SupermarketIdentity() (name, keyPath string)

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

func (p Profile) Validate() error

Validate reports whether the profile has every field required to open a server connection.

func (Profile) ValidateIdentity

func (p Profile) ValidateIdentity() error

ValidateIdentity reports whether the profile has the fields needed to sign requests that target a Cinc Server organization.

func (Profile) ValidateSupermarketIdentity

func (p Profile) ValidateSupermarketIdentity() error

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.

Jump to

Keyboard shortcuts

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