policyfile

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 18 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 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

View Source
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

func DefaultCacheRoot() (string, error)

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

func OpenBundle(path string) (string, func(), error)

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.

Jump to

Keyboard shortcuts

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