cmd

package
v0.0.0-...-2170ac4 Latest Latest
Warning

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

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

Documentation

Overview

Copyright 2025 Victor Palma <victor.palma@rackspace.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law of a agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package cmd implements the command-line interface for opencenter.

It provides commands for managing cluster configurations, including initialization, validation, and GitOps scaffolding.

When to use

Use the commands in this package to interact with opencenter from the command line. The main entry point is the `opencenter` command, which has several subcommands for managing clusters.

Examples

To list all available clusters:

opencenter cluster list

To initialize a new cluster configuration:

opencenter cluster init my-cluster

To validate a cluster configuration:

opencenter cluster validate my-cluster

Index

Constants

View Source
const (
	AppKey       contextKey = "app"
	ContainerKey contextKey = "container"
)

Variables

View Source
var (
	// Version is the semantic version (e.g., "1.0.0" or "0.0.1")
	Version = "dev"
	// GitCommit is the git commit SHA
	GitCommit = "unknown"
	// GitBranch is the git branch name
	GitBranch = "unknown"
	// GitTag is the git tag (if building from a tag)
	GitTag = ""
	// BuildDate is the build timestamp
	BuildDate = "unknown"
)

Build information variables set at compile time via ldflags

Functions

func ExecuteWithContext

func ExecuteWithContext(ctx context.Context, version string) error

ExecuteWithContext runs the root command with a context containing the DI container.

Inputs:

  • ctx: Context containing the DI container
  • version: The version string for the application.

Outputs:

  • error: An error if one occurred during execution.

func GetApp

func GetApp(ctx context.Context) (*di.App, error)

GetApp retrieves the typed application graph from the context.

func GetContainer

func GetContainer(ctx context.Context) (di.Container, error)

GetContainer retrieves the DI container from the context

func GetRootCmd

func GetRootCmd() *cobra.Command

GetRootCmd returns the root cobra command.

func NewClusterCmd

func NewClusterCmd() *cobra.Command

NewClusterCmd creates the top-level "cluster" command. It has several subcommands defined in separate files. Running "opencenter cluster" without subcommand prints help.

func NewPluginsCmd

func NewPluginsCmd() *cobra.Command

func NewSecretsCmd

func NewSecretsCmd() *cobra.Command

func NewSecretsKeysCmd

func NewSecretsKeysCmd() *cobra.Command

NewSecretsKeysCmd creates the keys subcommand group for secrets management

func NewSettingsCmd

func NewSettingsCmd() *cobra.Command

NewSettingsCmd creates the top-level "settings" command for CLI settings management. It provides subcommands for viewing, setting, getting, resetting, and locating the CLI settings file.

func NewShellInitCmd

func NewShellInitCmd() *cobra.Command

func NewVersionCmd

func NewVersionCmd() *cobra.Command

NewVersionCmd creates the version command

Types

type ClusterMetadata

type ClusterMetadata struct {
	Name         string `yaml:"name"`
	Environment  string `yaml:"env"`
	Region       string `yaml:"region"`
	Status       string `yaml:"status"`
	Organization string `yaml:"organization"`
}

ClusterMetadata represents cluster metadata for display in cluster use.

type ClusterSelectOutput

type ClusterSelectOutput struct {
	Metadata       ClusterMetadata
	Paths          *paths.ClusterPaths
	ExportCommands []string
	GitOpsInfo     GitOpsInfo
	Shell          string
}

ClusterSelectOutput represents the complete output for cluster use command.

type CreationRule

type CreationRule struct {
	PathRegex      string `yaml:"path_regex,omitempty"`
	EncryptedRegex string `yaml:"encrypted_regex,omitempty"`
	Age            string `yaml:"age,omitempty"`
	PGP            string `yaml:"pgp,omitempty"`
	KMS            string `yaml:"kms,omitempty"`
	AzureKV        string `yaml:"azure_kv,omitempty"`
	GCPKMS         string `yaml:"gcp_kms,omitempty"`
	HashiCorpVault string `yaml:"hc_vault,omitempty"`
}

CreationRule represents a SOPS creation rule

type FluxKustomization

type FluxKustomization struct {
	Name      string
	Namespace string
	Ready     bool
	Message   string
}

FluxKustomization represents a Flux Kustomization resource

type GitOpsInfo

type GitOpsInfo struct {
	GitDir            string
	ApplicationsDir   string
	InfrastructureDir string
	SecretsDir        string
}

GitOpsInfo represents GitOps repository information.

type GlobalFlags

type GlobalFlags struct {
	Config     string   // legacy alternative cluster configuration file path
	DryRun     bool     // --dry-run: enable dry-run mode
	LogLevel   string   // --log-level: set log level explicitly
	Set        []string // legacy configuration overrides using dot notation
	ShowActive bool     // legacy active-cluster display toggle
	BreakLock  bool     // --break-lock: force removal of existing lock before operation
}

GlobalFlags represents the global flags available across all commands.

type GlobalOptions

type GlobalOptions struct {
	ConfigDir string
	LogLevel  string
	Output    OutputFormat
	Quiet     bool
	Yes       bool
	DryRun    bool
}

type LockAcquisitionResult

type LockAcquisitionResult struct {
	Lock          resilience.Lock
	LockManager   resilience.LockManager
	ExistingLock  *resilience.LockState
	WasBroken     bool
	UserConfirmed bool
}

LockAcquisitionResult contains the result of attempting to acquire a lock

func AcquireLockWithPrompt

func AcquireLockWithPrompt(ctx context.Context, cmd *cobra.Command, resource string, operation string, ttl time.Duration, metadata map[string]string) (*LockAcquisitionResult, error)

AcquireLockWithPrompt attempts to acquire a lock on a cluster resource. If a lock already exists, it checks the --break-lock flag or prompts the user for confirmation before breaking the lock.

Parameters:

  • ctx: Context for the operation
  • cmd: The cobra command (for flags and I/O)
  • resource: The resource name to lock (typically cluster name)
  • operation: Description of the operation (e.g., "destroy", "bootstrap")
  • ttl: Time-to-live for the lock
  • metadata: Additional metadata to store with the lock

Returns:

  • *LockAcquisitionResult: Contains the acquired lock and related info
  • error: An error if lock acquisition fails

type OutputFormat

type OutputFormat string
const (
	OutputText OutputFormat = "text"
	OutputJSON OutputFormat = "json"
	OutputYAML OutputFormat = "yaml"
)

type SOPSConfig

type SOPSConfig struct {
	CreationRules []CreationRule `yaml:"creation_rules"`
}

SOPSConfig represents the structure of .sops.yaml

type SOPSPathMatcher

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

SOPSPathMatcher handles path matching based on SOPS configuration

func NewSOPSPathMatcher

func NewSOPSPathMatcher(configPath string) (*SOPSPathMatcher, error)

NewSOPSPathMatcher creates a new path matcher from SOPS configuration

func (*SOPSPathMatcher) ShouldEncryptPath

func (m *SOPSPathMatcher) ShouldEncryptPath(path string) bool

ShouldEncryptPath checks if a path should be encrypted based on SOPS rules

func (*SOPSPathMatcher) ShouldSkipPath

func (m *SOPSPathMatcher) ShouldSkipPath(path string) bool

ShouldSkipPath checks if a path should be skipped (excluded from encryption)

type SOPSPathRule

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

SOPSPathRule represents a compiled SOPS creation rule

type ServiceOption

type ServiceOption struct {
	Name        string
	Type        string
	Description string
	Required    bool
}

ServiceOption represents a configuration option for a service

type ServiceSyncResult

type ServiceSyncResult struct {
	Name      string `json:"name"`
	OldStatus string `json:"old_status"`
	NewStatus string `json:"new_status"`
	Changed   bool   `json:"changed"`
	Error     string `json:"error,omitempty"`
}

ServiceSyncResult holds the result of syncing a single service's status.

type SyncStatusResult

type SyncStatusResult struct {
	ClusterName    string              `json:"cluster_name"`
	ServicesTotal  int                 `json:"services_total"`
	Servicessynced int                 `json:"services_synced"`
	ServicesFailed int                 `json:"services_failed"`
	Results        []ServiceSyncResult `json:"results"`
}

SyncStatusResult holds the overall result of the sync-status operation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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