Documentation
¶
Overview ¶
Package policyfile deploys an existing Policyfile.lock.json to a Cinc/Chef Server. It fetches and caches the cookbooks the lock pins (from the sources the lock records), then drives the server-side push via cinc-api, and assembles a standalone export bundle. It owns the local, multi-source concerns; every server call goes through cinc-api or cinc-supermarket.
Index ¶
- Constants
- func ArtifactsToUpload(ctx context.Context, c *cinc.Client, lock *cinc.PolicyRevision) (int, error)
- func DefaultCacheRoot() (string, error)
- func LoadBundleCookbooks(dir string, lock *cinc.PolicyRevision) (map[string]*cinc.LocalCookbook, error)
- func OpenBundle(path string) (string, func(), error)
- type ExportResult
- type Fetcher
Constants ¶
const BundleLockName = "Policyfile.lock.json"
BundleLockName is the Policyfile lock file Export writes at the root of a bundle. push-archive reads it back to discover the policy and its cookbooks.
Variables ¶
This section is empty.
Functions ¶
func ArtifactsToUpload ¶ added in v0.24.0
ArtifactsToUpload counts the lock's cookbooks the server does not hold yet as cookbook artifacts under the identifiers the lock records. That is how many cookbooks cinc-api's PushRevision uploads: it skips an artifact the server already has, so a lock pushed to a second group uploads none.
The count is read just before the push, so a concurrent push of the same artifacts can make it high by the ones the other push stored first.
func DefaultCacheRoot ¶
DefaultCacheRoot is ~/.cinc/cache/cookbooks.
func LoadBundleCookbooks ¶
func LoadBundleCookbooks(dir string, lock *cinc.PolicyRevision) (map[string]*cinc.LocalCookbook, error)
LoadBundleCookbooks reads each cookbook the lock pins from a bundle's cookbooks/<name>-<identifier>/ tree into an uploadable LocalCookbook, keyed by cookbook name. The directory layout matches what Export writes; the cookbook's upload name is taken from the lock (not the on-disk directory, which carries the identifier suffix).
func OpenBundle ¶
OpenBundle resolves a push-archive input — either a .tar.gz archive (as written by Export with --archive) or an already-extracted bundle directory — to an on-disk bundle directory holding the lock and a cookbooks/ tree. A tarball is extracted into a fresh temp directory; the returned cleanup removes it. cleanup is always non-nil and safe to defer (a no-op for a directory input).
Types ¶
type ExportResult ¶
type ExportResult struct {
Dir string `json:"dir"`
Archive string `json:"archive,omitempty"`
Policy string `json:"policy"`
}
ExportResult describes a completed export.
func Export ¶
func Export(ctx context.Context, fetcher *Fetcher, lock *cinc.PolicyRevision, lockJSON []byte, destDir string, archive bool) (ExportResult, error)
Export assembles a standalone, Chef-compatible bundle for an air-gapped `cinc-client -z` run: every pinned cookbook under cookbooks/<name>-<dotted_decimal_identifier>/, the lock under both policies/<name>-<revision>.json and Policyfile.lock.json, and a generated client.rb selecting the policy in local mode. With archive, the directory is also written as <dir>.tar.gz. Cookbooks are sourced through the fetcher (cache or fresh fetch).
type Fetcher ¶
type Fetcher struct {
// CacheRoot is the directory holding one subdirectory per cache_key for
// fetched (artifactserver/git) cookbooks.
CacheRoot string
// LockDir is the directory of the lock file, used to resolve relative
// path: sources.
LockDir string
// Chef is used for chef_server-sourced cookbooks. It may be nil when no
// lock uses a chef_server source.
Chef *cinc.Client
// contains filtered or unexported fields
}
Fetcher locates the cookbooks a Policyfile lock pins, fetching them from the source each lock records into a local cache and returning the on-disk directory that holds the cookbook root. It is safe to call repeatedly: a cached cookbook is returned without re-fetching.
func (*Fetcher) EnsureCookbook ¶
func (f *Fetcher) EnsureCookbook(ctx context.Context, name string, lock cinc.CookbookLock) (string, error)
EnsureCookbook returns the directory containing the cookbook for one lock, fetching and caching it first if necessary. path: cookbooks are read in place; artifactserver/chef_server cookbooks are cached under CacheRoot keyed by the lock's cache_key (a cache hit is a directory-exists check).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package resolver completes a Policyfile install: it takes the evaluated intent of a Policyfile.rb (from cli/policyfile/rubyeval) and produces a fully resolved, push-ready Policyfile.lock.json that is byte-for-byte compatible with what `chef install` writes.
|
Package resolver completes a Policyfile install: it takes the evaluated intent of a Policyfile.rb (from cli/policyfile/rubyeval) and produces a fully resolved, push-ready Policyfile.lock.json that is byte-for-byte compatible with what `chef install` writes. |
|
Package rubyeval evaluates arbitrary Policyfile.rb files by running CRuby compiled to WebAssembly (the official ruby/ruby.wasm WASI build) under the pure-Go wazero runtime — no system Ruby and no CGo required.
|
Package rubyeval evaluates arbitrary Policyfile.rb files by running CRuby compiled to WebAssembly (the official ruby/ruby.wasm WASI build) under the pure-Go wazero runtime — no system Ruby and no CGo required. |