scafctl

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 63 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDefaults added in v0.7.0

func RegisterDefaults()

RegisterDefaults registers the default CEL environment, cache, and Go template factories required before calling Root(). Embedders that need the standard scafctl behaviour should call this once at startup. Individual factories can still be overridden afterwards by calling the corresponding Set*Factory functions directly.

func Root

func Root(opts *RootOptions) (*cobra.Command, func())

Root creates and returns the root cobra.Command for the scafctl CLI tool. It sets up persistent flags, configures logging, handles profiler options, validates command arguments, and adds subcommands. The command provides configuration discovery and scaffolding functionality.

opts may be nil, in which case production defaults are used. Each invocation creates its own isolated state so multiple Root() calls can execute concurrently without data races.

The returned cleanup function releases auth handler plugins and telemetry resources. Callers must defer it after Execute() returns so that resources are released even when RunE returns an error (cobra skips PersistentPostRun in that case). The function is idempotent and safe to call multiple times.

Types

type RootOptions added in v0.3.0

type RootOptions struct {
	// IOStreams overrides the default os.Stdin/Stdout/Stderr streams.
	// When nil, standard OS streams are used.
	IOStreams *terminal.IOStreams

	// ExitFunc overrides os.Exit. When non-nil it is passed through
	// writer.WithExitFunc so that ErrorWithCode/ErrorWithExit call
	// this function instead of terminating the process. Useful for
	// in-process test execution where panicking or returning an error
	// is preferred over killing the process.
	ExitFunc func(code int)

	// ConfigPath overrides the --config flag default.
	ConfigPath string

	// BinaryName overrides the default CLI binary name used by this command
	// tree: root command Use field, subcommand Short descriptions, env var
	// prefix, telemetry service name, and version output. Solution discovery
	// and cache paths are wired through settings.Run.BinaryName.
	// When empty, defaults to settings.CliBinaryName ("scafctl").
	BinaryName string

	// PreRunHook is called within PersistentPreRun after scafctl's standard
	// setup (config, logger, auth, telemetry) is complete but before the
	// command's own RunE executes. The context on cmd is fully initialized.
	// When nil, no additional hook runs.
	PreRunHook func(cmd *cobra.Command, args []string) error

	// VersionExtra is additional version info displayed alongside scafctl's
	// own version. When non-nil, the version command shows both the
	// embedder's and scafctl's versions.
	VersionExtra *settings.VersionInfo

	// ConfigDefaults is an optional YAML byte slice providing embedder-level
	// configuration defaults. These are merged after scafctl's built-in
	// defaults but before the user's config file, environment variables,
	// and CLI flags.
	//
	// Merge precedence (lowest to highest):
	//  1. scafctl built-in defaults (setDefaults)
	//  2. ConfigDefaults (this field)
	//  3. User config file (~/.config/<binary>/config.yaml)
	//  4. Environment variables
	//  5. CLI flags
	ConfigDefaults []byte

	// AuthPluginDirs specifies directories to scan for auth handler plugin
	// binaries. Discovered plugins are registered in the auth.Registry
	// alongside built-in handlers during PersistentPreRunE.
	AuthPluginDirs []string

	// BuiltinAuthHandlers are pre-built auth handler instances that the
	// embedder compiles into the binary. They are registered eagerly at
	// startup before config-based or plugin handlers, and appear in
	// 'auth list' immediately.
	BuiltinAuthHandlers []auth.Handler

	// ActionDiscoveryFileNames overrides the file names used by "run action"
	// auto-discovery. When empty, the defaults from
	// settings.ActionFileNamesFor are used.
	ActionDiscoveryFileNames []string

	// OfficialProviders overrides the default official provider registry used
	// for auto-resolution. When nil and DisableOfficialProviders is false,
	// the default registry (all first-party providers) is used.
	// Embedders can supply a custom registry via official.NewRegistryFrom to
	// extend or replace the default set.
	OfficialProviders *official.Registry

	// OfficialAuthHandlers overrides the default official auth handler registry
	// used for auto-resolution. When nil and DisableOfficialAuthHandlers is
	// false, the default registry (4 extracted first-party auth handlers) is
	// used. Embedders can supply a custom registry via
	// authofficial.NewRegistryFrom to extend or replace the default set.
	OfficialAuthHandlers *authofficial.Registry

	// PluginSignaturePolicy overrides the plugin signature verification policy.
	// When nil, the policy is derived from the app configuration
	// (config.Plugins.Signatures). Embedders can supply a policy directly
	// to enforce stricter verification without relying on user config.
	PluginSignaturePolicy *plugin.SignaturePolicy

	// ClusterResolver resolves Kubernetes/OpenShift cluster names to
	// connection details. When non-nil it is attached to the command context
	// so cluster-aware commands can map a positional cluster name to its API
	// server URL, auth type, and OIDC audience. When nil, those commands fall
	// back to explicit --server flags and auto-detection. scafctl ships no
	// cluster data; embedders with a cluster registry provide the
	// implementation.
	ClusterResolver kube.ClusterResolver
}

RootOptions configures a Root() invocation. All fields are optional; nil values use production defaults. Passing a non-nil RootOptions enables fully parallel in-process execution because each call to Root() creates its own isolated state.

func NewRootOptions added in v0.3.0

func NewRootOptions() *RootOptions

NewRootOptions returns a RootOptions with production defaults (nil IOStreams, nil ExitFunc, empty ConfigPath).

Directories

Path Synopsis
Package aliassave provides the shared post-login "--save-alias" persistence flow used by both `auth login` and `kube login`.
Package aliassave provides the shared post-login "--save-alias" persistence flow used by both `auth login` and `kube login`.
Package auth provides CLI commands for authentication management.
Package auth provides CLI commands for authentication management.
Package cache provides commands for managing the scafctl cache.
Package cache provides commands for managing the scafctl cache.
Package catalog provides commands for inspecting and managing the local catalog.
Package catalog provides commands for inspecting and managing the local catalog.
Package config provides commands for managing scafctl configuration.
Package config provides commands for managing scafctl configuration.
Package credentialhelper implements the scafctl credential-helper CLI commands, exposing scafctl's encrypted credential store via the Docker credential helper protocol.
Package credentialhelper implements the scafctl credential-helper CLI commands, exposing scafctl's encrypted credential store via the Docker credential helper protocol.
Package diff provides the polymorphic top-level `diff` command verb, with subcommands for comparing solutions, bundles, and snapshots.
Package diff provides the polymorphic top-level `diff` command verb, with subcommands for comparing solutions, bundles, and snapshots.
Package eval provides commands for evaluating and validating CEL expressions and Go templates.
Package eval provides commands for evaluating and validating CEL expressions and Go templates.
Package extract provides the polymorphic top-level `extract` command verb, with subcommands for extracting files from different scafctl artifact kinds.
Package extract provides the polymorphic top-level `extract` command verb, with subcommands for extracting files from different scafctl artifact kinds.
get
cel
snapshot
Package snapshot provides the `get snapshot` subcommand, which loads and displays the contents of a resolver execution snapshot file.
Package snapshot provides the `get snapshot` subcommand, which loads and displays the contents of a resolver execution snapshot file.
Package kube provides the 'kube' command group and its 'login' / 'logout' subcommands that authenticate to a Kubernetes / OpenShift cluster and write a kubeconfig exec-credential entry.
Package kube provides the 'kube' command group and its 'login' / 'logout' subcommands that authenticate to a Kubernetes / OpenShift cluster and write a kubeconfig exec-credential entry.
Package lint provides the lint command for validating solutions.
Package lint provides the lint command for validating solutions.
Package newcmd provides commands for creating new scafctl resources.
Package newcmd provides commands for creating new scafctl resources.
Package packagecmd provides the "package" command for packaging artifacts into the local catalog.
Package packagecmd provides the "package" command for packaging artifacts into the local catalog.
Package plugins provides commands for managing scafctl plugins.
Package plugins provides commands for managing scafctl plugins.
Package run provides the CLI run commands.
Package run provides the CLI run commands.
Package secrets provides commands for managing scafctl secrets.
Package secrets provides commands for managing scafctl secrets.
Package state provides commands for managing scafctl state files.
Package state provides commands for managing scafctl state files.
Package vendor provides CLI commands for managing vendored solution dependencies.
Package vendor provides CLI commands for managing vendored solution dependencies.

Jump to

Keyboard shortcuts

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