cmd

package
v0.0.0-...-5d3bb26 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = "dev"
	Commit  = "unknown"
	Date    = "unknown"
)

These variables are populated at build time via -ldflags. Defaults are for local dev builds (go run / go build).

Functions

func CheckAge

func CheckAge(encryptionBackend string, ageKeyFile string) error

CheckAge verifies that age is installed (if using age encryption).

func CheckArgoCDSync

func CheckArgoCDSync(ctx context.Context, client k8s.ClientInterface) (int, int, error)

CheckArgoCDSync checks if ArgoCD applications are syncing

func CheckFilePermissions

func CheckFilePermissions(filePath string, isSecret bool) error

CheckFilePermissions verifies that critical files have proper permissions.

func CheckGitCrypt

func CheckGitCrypt(encryptionBackend string) error

CheckGitCrypt verifies that git-crypt is installed (if using git-crypt encryption).

func CheckHelm

func CheckHelm() error

CheckHelm verifies that Helm is installed and accessible.

func CheckKubectlAvailable

func CheckKubectlAvailable(strict bool) error

CheckKubectlAvailable verifies that kubectl is installed and accessible. Returns nil if kubectl is available, but only logs a warning if not available (unless strict mode is enabled).

func CheckKubectlClusterAccess

func CheckKubectlClusterAccess() error

CheckKubectlClusterAccess verifies that kubectl can connect to the cluster. This checks if the current context is valid and accessible.

func CheckKubectlClusterAccessWithConfig

func CheckKubectlClusterAccessWithConfig(kubeconfig, kubeContext string) error

CheckKubectlClusterAccessWithConfig verifies that kubectl can connect to the cluster using the provided kubeconfig and context.

func CheckSOPS

func CheckSOPS(encryptionBackend string) error

CheckSOPS verifies that sops is installed and accessible (if using SOPS encryption).

func CheckSSHKey

func CheckSSHKey(keyPath string) error

CheckSSHKey verifies that SSH key file is readable and has proper permissions.

func Execute

func Execute()

func PreflightChecks

func PreflightChecks(encryption, ageKeyFile string, verbose bool, requireKubectl bool) error

PreflightChecks performs all prerequisite checks before bootstrap. strict mode is enabled when --wait-for-health is true, requiring kubectl cluster access.

func PrintHealthStatus

func PrintHealthStatus(status *HealthStatus)

PrintHealthStatus prints the health check results in a formatted way

func WrapNonZeroExitError

func WrapNonZeroExitError(command string, err error) error

WrapNonZeroExitError wraps errors from external commands with context.

Types

type ApplicationReport

type ApplicationReport struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Created   bool   `json:"created"` // true = created, false = updated
}

ApplicationReport captures ArgoCD Application info.

type ArgoCDAppInfo

type ArgoCDAppInfo struct {
	Name         string
	Namespace    string
	SyncStatus   string
	HealthStatus string
	Destination  string
	RepoURL      string
	Path         string
	SyncWave     string
}

ArgoCDAppInfo holds ArgoCD Application information

type BootstrapReport

type BootstrapReport struct {
	Environment   string         `json:"environment"`
	StartTime     time.Time      `json:"start_time"`
	EndTime       time.Time      `json:"end_time"`
	Duration      string         `json:"duration"`
	DurationMs    int64          `json:"duration_ms"`
	Success       bool           `json:"success"`
	Stages        []StageReport  `json:"stages"`
	Resources     ResourceReport `json:"resources"`
	Health        *HealthReport  `json:"health,omitempty"`
	Configuration ConfigReport   `json:"configuration"`
	Error         string         `json:"error,omitempty"`
}

BootstrapReport captures the complete state and metrics of a bootstrap operation.

func NewBootstrapReport

func NewBootstrapReport(env string) *BootstrapReport

NewBootstrapReport creates a new bootstrap report.

func (*BootstrapReport) AddStage

func (r *BootstrapReport) AddStage(stage StageReport)

AddStage adds a completed stage to the report.

func (*BootstrapReport) Complete

func (r *BootstrapReport) Complete(success bool, err error)

Complete finalizes the report with end time and duration.

func (*BootstrapReport) PrintSummary

func (r *BootstrapReport) PrintSummary()

PrintSummary prints a human-readable summary of the report.

func (*BootstrapReport) ToJSON

func (r *BootstrapReport) ToJSON() (string, error)

ToJSON serializes the report to JSON.

func (*BootstrapReport) WriteToFile

func (r *BootstrapReport) WriteToFile(path string) error

WriteToFile writes the report to a file in JSON format.

type ComponentHealth

type ComponentHealth struct {
	Name   string `json:"name"`
	Status string `json:"status"` // Ready, NotReady, NotInstalled, Unknown
}

ComponentHealth captures individual component health status.

type ComponentInfo

type ComponentInfo struct {
	Name            string
	Namespace       string
	Installed       bool
	Status          string
	ReadyReplicas   int
	DesiredReplicas int
	Version         string
	SyncWave        string
	Message         string
}

ComponentInfo holds information about a component

type ConfigReport

type ConfigReport struct {
	BaseDir           string `json:"base_dir"`
	AppPath           string `json:"app_path"`
	Encryption        string `json:"encryption"`
	SecretsFile       string `json:"secrets_file"`
	Kubeconfig        string `json:"kubeconfig,omitempty"`
	Context           string `json:"context,omitempty"`
	DryRun            bool   `json:"dry_run"`
	SkipArgoCDInstall bool   `json:"skip_argocd_install"`
	WaitForHealth     bool   `json:"wait_for_health"`
}

ConfigReport captures configuration used for bootstrap.

type HealthCheckResult

type HealthCheckResult struct {
	Component string
	Status    string
	Message   string
	Duration  time.Duration
}

HealthCheckResult holds the result of a health check

type HealthReport

type HealthReport struct {
	Checked    bool              `json:"checked"`
	Healthy    bool              `json:"healthy"`
	Components []ComponentHealth `json:"components"`
	Timeout    int               `json:"timeout_seconds"`
}

HealthReport captures post-bootstrap health check results.

type HealthStatus

type HealthStatus struct {
	Healthy     bool
	StartTime   time.Time
	EndTime     time.Time
	Results     []HealthCheckResult
	CheckedAt   time.Time
	Environment string
}

HealthStatus represents overall health

func WaitForHealth

func WaitForHealth(ctx context.Context, kubeconfig, kubeContext, environment string, timeoutSecs int) (*HealthStatus, error)

WaitForHealth waits for critical components to be ready after bootstrap. Timeout is in seconds. Returns detailed health status and any errors.

type HelmReleaseReport

type HelmReleaseReport struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Installed bool   `json:"installed"` // true = installed, false = upgraded
	Skipped   bool   `json:"skipped"`
}

HelmReleaseReport captures Helm release info.

type InfoResult

type InfoResult struct {
	Environment    string
	ClusterVersion string
	ArgoCDVersion  string
	Components     []ComponentInfo
	Applications   []ArgoCDAppInfo
	Health         *HealthStatus
	Timestamp      time.Time
}

InfoResult holds bootstrap status information

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger provides structured logging with optional timestamp support.

func NewLogger

func NewLogger(verbose bool) *Logger

NewLogger creates a new logger instance.

func (*Logger) GetStageSummary

func (l *Logger) GetStageSummary() string

GetStageSummary returns a summary of all stages with timings.

func (*Logger) PrintStageSummary

func (l *Logger) PrintStageSummary()

PrintStageSummary prints the stage summary if verbose is enabled.

func (*Logger) Stage

func (l *Logger) Stage(name string) *StageLogger

Stage starts logging a new stage.

type NamespaceReport

type NamespaceReport struct {
	Name    string `json:"name"`
	Created bool   `json:"created"`
}

NamespaceReport captures namespace creation info.

type ResourceReport

type ResourceReport struct {
	Namespace     NamespaceReport   `json:"namespace"`
	Secrets       []SecretReport    `json:"secrets"`
	ArgoCDRelease HelmReleaseReport `json:"argocd_release"`
	AppOfApps     ApplicationReport `json:"app_of_apps"`
}

ResourceReport captures information about created/updated resources.

type SecretReport

type SecretReport struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Created   bool   `json:"created"` // true = created, false = updated
}

SecretReport captures secret creation/update info.

type StageLog

type StageLog struct {
	Name      string
	StartTime time.Time
	Duration  time.Duration
	Details   []string
}

StageLog records information about a stage execution.

type StageLogger

type StageLogger struct {
	// contains filtered or unexported fields
}

StageLogger is a helper for logging a single stage.

func (*StageLogger) Detail

func (s *StageLogger) Detail(format string, args ...interface{})

Detail adds a detail line to the current stage.

func (*StageLogger) Done

func (s *StageLogger) Done()

Done marks the stage as complete and records its duration.

func (*StageLogger) SecretDetail

func (s *StageLogger) SecretDetail(operation, secretName, namespace string)

SecretDetail logs a secret-related operation without exposing values.

type StageReport

type StageReport struct {
	Name       string    `json:"name"`
	StartTime  time.Time `json:"start_time"`
	EndTime    time.Time `json:"end_time"`
	Duration   string    `json:"duration"`
	DurationMs int64     `json:"duration_ms"`
	Success    bool      `json:"success"`
	Details    []string  `json:"details,omitempty"`
	Error      string    `json:"error,omitempty"`
}

StageReport captures metrics for a single bootstrap stage.

Jump to

Keyboard shortcuts

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