Documentation
¶
Overview ¶
Package cmd is where the commands for cargoship
Index ¶
- Constants
- Variables
- func AnsibleModule(ctx context.Context, argv []string) (int, bool)
- func Execute(ctx context.Context) error
- func ExecuteArgs(ctx context.Context, args []string) error
- func ExitCode(err error) int
- func NewCargoshipCommand() *cobra.Command
- func ParseRegistryOverrides(overrides []string) ([]images.RegistryOverride, error)
- func PrintFindings(ctx context.Context, lintErr *lint.LintError)
- func PrintViperConfigUsed(ctx context.Context) error
- type InstallCommon
Constants ¶
const ( // DevRenderTemplate flag DevRenderTemplate = "template" // DevRenderValues flag DevRenderValues = "values" // DevRenderOut flag DevRenderOut = "out" // DevRenderNoValidate flag DevRenderNoValidate = "no-validate" )
const ( // ExitOK is a run that did what it was asked. ExitOK = 0 // ExitFailure is anything not classified below. A retry is unlikely to help on its own. ExitFailure = 1 // ExitUsage is a malformed invocation: an unknown flag or command, the wrong number of // arguments, a missing required flag. The fix is to the command line, so retrying it is // pointless. ExitUsage = 2 // ExitInvalidInput is a file cargoship was pointed at that does not hold what it must: a // document that fails its schema, or a config file with a key the schema does not define. // The fix is to the file. ExitInvalidInput = 3 // ExitConfirmRequired is a host-changing command run without --confirm. Nothing happened, // and the same command with --confirm would proceed. ExitConfirmRequired = 4 // ExitHostUnreachable is a fleet cargoship could not reach or authenticate to. This is the // code worth retrying, and the one worth distinguishing: it means no phase did any work, so // a scripted retry is safe in a way that a mid-apply failure is not. ExitHostUnreachable = 5 // ExitInterrupted is a run stopped by SIGINT, following the conventional 128 + signal. ExitInterrupted = 130 )
Exit codes cargoship promises. A wrapper script on an air-gapped management node decides whether to retry, re-stage, or stop from these, so each one is a compatibility promise: renumbering one breaks every caller that reads it. Add a code rather than repurposing one, and document it in README.md and AGENTS.md at the same time.
const ( // CmdInventoryOutput flag CmdInventoryOutput = "output" // CmdInventoryName flag CmdInventoryName = "name" // CmdInventoryLoadBalancer flag CmdInventoryLoadBalancer = "loadbalancer" )
const ( // FlagAgeIdentityFile names the flag holding an age identity file, which decrypts FlagAgeIdentityFile = "age-identity-file" // FlagAgeRecipient names the flag holding an age public key, which encrypts FlagAgeRecipient = "age-recipient" // FlagAgeRecipientsFile names the flag holding a file of age public keys, which encrypt FlagAgeRecipientsFile = "age-recipients-file" )
const ( // RootLoggingLevel command flag log level RootLoggingLevel = "log-level" // RootLoggingFormat command flag log format RootLoggingFormat = "log-format" // RootTimeout command flag timeout RootTimeout = "timeout" // RootZarfCache command flag zarf-cache RootZarfCache = "zarf-cache" // RootArchitecture command flag architecture RootArchitecture = "architecture" // RootPlainHTTP is the config-file key behind the --plain-http flag. It is a viper key, not // a flag name, which is why it is spelled in the snake_case the config file uses. RootPlainHTTP = "plain_http" // RootInsecureSkipTLSVerify is the config-file key behind the --insecure-skip-tls-verify // flag, spelled as the config file spells it for the same reason as RootPlainHTTP. RootInsecureSkipTLSVerify = "insecure_skip_tls_verify" )
const ( // InstallConfig flag InstallConfig = "config" // InstallTargetHosts flag InstallTargetHosts = "target-hosts" // InstallConfirm flag InstallConfirm = "confirm" // InstallDistro flag. Named directly by the commands that load no package -- reset and // kube-config -- which have nothing else to read the engine's identity from. InstallDistro = "distro" // InstallDryRun flag InstallDryRun = "dry-run" // InstallConcurrency flag InstallConcurrency = "concurrency" // InstallWorkConcurrency flag InstallWorkConcurrency = "work-concurrency" // InstallUpdateHost flag InstallUpdateHost = "hosts" // InstallUpdateFirewall flag InstallUpdateFirewall = "firewall" // InstallLabelNodes flag InstallLabelNodes = "label-nodes" // InstallAllowUnmanagedNodes flag InstallAllowUnmanagedNodes = "allow-unmanaged-nodes" // InstallAllowDowngrade flag InstallAllowDowngrade = "allow-downgrade" // InstallUpdateKubeConfig flag InstallUpdateKubeConfig = "update-kubeconfig" // InstallKubeConfigPath flag InstallKubeConfigPath = "kubeconfig" // InstallVaultPasswordFile flag InstallVaultPasswordFile = "vault-password-file" // InstallValues flag InstallValues = "values" // InstallReceiptPath flag InstallReceiptPath = "receipt-path" )
const ( // PackageOCIConcurrency flag PackageOCIConcurrency = "oci-concurrency" // PackageTag flag PackageTag = "tag" )
const ( // MiscOutput flag MiscOutput = "output" // MiscPackage flag MiscPackage = "package" )
const MiscRedactReceiptOutput = "output"
MiscRedactReceiptOutput flag
const (
// MiscValidateKind flag
MiscValidateKind = "kind"
)
const MiscVaultForce = "force"
MiscVaultForce flag
const (
// MiscVaultKeygenPublicKey flag
MiscVaultKeygenPublicKey = "public-key"
)
const MiscVaultNewPasswordFile = "new-vault-password-file"
MiscVaultNewPasswordFile flag
const MiscVaultPasswordFile = "vault-password-file"
MiscVaultPasswordFile flag
Variables ¶
var ( // ErrUsage marks an error caused by how the command was invoked rather than by what it was // asked to do. Cobra reports these as plain errors, so they are tagged at the two points // they arise: the flag error hook, and the argument validators. ErrUsage = errors.New("invalid usage") // ErrInvalidInput marks a file whose contents cargoship rejected. ErrInvalidInput = errors.New("invalid input file") // ErrConfirmRequired marks the --confirm gate in requireConfirm. ErrConfirmRequired = errors.New("confirmation required") )
var ( // IsColorDisabled whether to show the colored output IsColorDisabled bool // LogFormat format of the log output LogFormat string // LogLevelCLI log level LogLevelCLI string // LogFile enables always writing a full-verbosity debug log to a file LogFile bool // Timeout for how long a task runs Timeout string )
var ( // OutputWriter is where the human-facing summary tables go -- the lint findings below and // the per-host receipt summary in receipt.go. It is stderr, not stdout: both are diagnostics // an operator reads, not documents a caller parses, and sending them to stdout meant // "cargoship apply > out" captured a box-drawing table instead of nothing. OutputWriter = os.Stderr )
Functions ¶
func AnsibleModule ¶
AnsibleModule runs the binary as an Ansible module when it was invoked as one, and reports whether it was.
It lives here rather than in main because src/internal is only importable from inside src/, and because this is where the argument vector a module renders is executed. The caller exits with the status returned; a module always exits 0 and reports failure inside its JSON result.
func ExecuteArgs ¶
ExecuteArgs runs the root command against an explicit argument vector instead of os.Args.
It exists for the Ansible module mode in internal/ansiblemod, which turns a module's JSON parameters into the flags an operator would have typed and then runs the ordinary command. Building an argument vector rather than calling into src/pkg/action directly is the point of the arrangement: keyring resolution, timeout parsing, package loading, and phase construction stay on one path, so what a playbook does and what an operator does cannot drift apart.
func ExitCode ¶ added in v0.41.0
ExitCode maps an error from Execute to the process exit code. Order matters: the most specific classification wins, and anything unrecognised stays at ExitFailure so that a new error type cannot silently change what a caller sees.
func NewCargoshipCommand ¶
NewCargoshipCommand is the root command
func ParseRegistryOverrides ¶
func ParseRegistryOverrides(overrides []string) ([]images.RegistryOverride, error)
ParseRegistryOverrides converts registry overrides to a structured type. The result is sorted in descending order by Source, which guarantees the longest prefix will be sorted toward the beginning -- so that e.g. docker.io/library overrides win over a broader docker.io override.
Input is of the following form: []string{"docker.io/library=docker.example.com", "docker.io=docker.example.com"}
func PrintFindings ¶
PrintFindings prints the findings in the LintError as a table.
func PrintViperConfigUsed ¶
PrintViperConfigUsed informs users when Zarf has detected a config file.
Types ¶
type InstallCommon ¶
type InstallCommon struct {
// contains filtered or unexported fields
}
InstallCommon common args
Source Files
¶
- ansible.go
- common.go
- common_schema.go
- common_verify.go
- dev.go
- dev_apply.go
- dev_render.go
- exit.go
- flag.go
- install_apply.go
- install_engine_config_sync.go
- install_kube-config.go
- install_prepare.go
- install_reset.go
- inventory.go
- inventory_from_ansible.go
- keyring.go
- misc_clean_cache.go
- misc_redact_receipt.go
- misc_schema.go
- misc_sha.go
- misc_validate.go
- misc_vault_decrypt.go
- misc_vault_decrypt_file.go
- misc_vault_decrypt_path.go
- misc_vault_encrypt.go
- misc_vault_encrypt_file.go
- misc_vault_encrypt_path.go
- misc_vault_keygen.go
- misc_vault_rekey.go
- misc_version.go
- package_create.go
- package_import.go
- package_ls.go
- package_mirror.go
- package_publish.go
- package_pull.go
- package_sign.go
- package_verify.go
- receipt.go
- receipt_table.go
- registry_target.go
- root.go
- table.go
- usage.go
- vault.go
- viper.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package main is the entry point for the cargoship binary
|
Package main is the entry point for the cargoship binary |
|
Package flags provides shell completion functions for cargoship CLI flags.
|
Package flags provides shell completion functions for cargoship CLI flags. |