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 ¶
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 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. PushRevision uploads each one under its lock name, so the identifier suffix on the directory never reaches the server.
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. |