cli

package
v1.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package cli provides command-line interface utilities for ServiceRadar configuration management.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrInvalidIPFormat indicates an invalid IP address format was provided.
	ErrInvalidIPFormat    = errors.New("invalid IP address format")
	ErrRootCAExists       = errors.New("root CA already exists")
	ErrInvalidIPAddress   = errors.New("invalid IP address")
	ErrSettingOwnership   = errors.New("failed to set ownership")
	ErrInvalidUIDGID      = errors.New("failed to get UID/GID for user")
	ErrChownFailed        = errors.New("failed to set file ownership")
	ErrCertNotFound       = errors.New("no existing certificate found")
	ErrDecodeCertPEM      = errors.New("failed to decode certificate PEM")
	ErrDecodeRootCAKeyPEM = errors.New("failed to decode root CA key PEM")
)

Functions

func ErrUnknownAdminResource added in v1.0.79

func ErrUnknownAdminResource(resource string) error

ErrUnknownAdminResource returns a wrapped error for unknown admin resources.

func GenerateTLSCerts

func GenerateTLSCerts(cfg *CmdConfig) error

GenerateTLSCerts generates mTLS certificates for ServiceRadar components.

func IsInputFromTerminal

func IsInputFromTerminal() bool

IsInputFromTerminal determines if input is coming from a terminal or being piped/redirected.

func RunAdminNatsAccounts added in v1.0.79

func RunAdminNatsAccounts(cfg *CmdConfig) error

RunAdminNatsAccounts lists all NATS accounts.

func RunAdminNatsCommand added in v1.0.79

func RunAdminNatsCommand(cfg *CmdConfig) error

RunAdminNatsCommand dispatches admin nats subcommands.

func RunAdminNatsGenerateBootstrapToken added in v1.0.79

func RunAdminNatsGenerateBootstrapToken(cfg *CmdConfig) error

RunAdminNatsGenerateBootstrapToken generates a new platform bootstrap token.

func RunAdminNatsStatus added in v1.0.79

func RunAdminNatsStatus(cfg *CmdConfig) error

RunAdminNatsStatus retrieves the current NATS operator status.

func RunBcryptNonInteractive

func RunBcryptNonInteractive(args []string) error

RunBcryptNonInteractive handles non-interactive bcrypt generation.

func RunEdgeCommand added in v1.0.55

func RunEdgeCommand(cfg *CmdConfig) error

RunEdgeCommand dispatches multi-level `edge ...` invocations.

func RunEdgePackageCreate added in v1.0.55

func RunEdgePackageCreate(cfg *CmdConfig) error

RunEdgePackageCreate provisions a new onboarding package via the Core API.

func RunEdgePackageDownload added in v1.0.55

func RunEdgePackageDownload(cfg *CmdConfig) error

RunEdgePackageDownload calls the admin API to retrieve onboarding artifacts.

func RunEdgePackageList added in v1.0.55

func RunEdgePackageList(cfg *CmdConfig) error

RunEdgePackageList retrieves package summaries from the Core API.

func RunEdgePackageRevoke added in v1.0.55

func RunEdgePackageRevoke(cfg *CmdConfig) error

RunEdgePackageRevoke calls the admin API to revoke an onboarding package.

func RunEdgePackageShow added in v1.0.55

func RunEdgePackageShow(cfg *CmdConfig) error

RunEdgePackageShow fetches a single package record.

func RunEdgePackageToken added in v1.0.55

func RunEdgePackageToken(cfg *CmdConfig) error

RunEdgePackageToken emits an edgepkg-v1 token for use as ONBOARDING_TOKEN.

func RunEnroll added in v1.0.85

func RunEnroll(cfg *CmdConfig) error

RunEnroll handles the enroll subcommand.

func RunGenerateJWTKeys added in v1.0.55

func RunGenerateJWTKeys(cfg *CmdConfig) error

RunGenerateJWTKeys generates an RSA keypair and updates core.json auth config.

func RunGenerateJWTKeysCmd added in v1.0.55

func RunGenerateJWTKeysCmd(cfg *CmdConfig) error

RunGenerateJWTKeys handles the generate-jwt-keys subcommand.

func RunGenerateTLS

func RunGenerateTLS(cfg *CmdConfig) error

RunGenerateTLS handles the generate-tls subcommand.

func RunInteractive

func RunInteractive() error

RunInteractive runs the TUI for interactive mode.

func RunNatsBootstrap added in v1.0.79

func RunNatsBootstrap(cfg *CmdConfig) error

RunNatsBootstrap executes the NATS bootstrap process.

func RunSpireJoinToken added in v1.0.55

func RunSpireJoinToken(cfg *CmdConfig) error

RunSpireJoinToken executes the spire-join-token subcommand.

func RunUpdateConfig

func RunUpdateConfig(configFile, adminHash, dbPasswordFile string) error

RunUpdateConfig handles the update-config subcommand.

func RunUpdateGateway added in v1.0.79

func RunUpdateGateway(cfg *CmdConfig) error

RunUpdateGateway handles the update-gateway subcommand.

func ShowHelp

func ShowHelp()

ShowHelp displays the help message and exits.

Types

type AdminHandler added in v1.0.79

type AdminHandler struct{}

AdminHandler handles multi-level `admin ...` commands.

func (AdminHandler) Parse added in v1.0.79

func (AdminHandler) Parse(args []string, cfg *CmdConfig) error

Parse dispatches nested admin commands.

type AdminNatsBootstrapTokenHandler added in v1.0.79

type AdminNatsBootstrapTokenHandler struct{}

AdminNatsBootstrapTokenHandler handles generating a new bootstrap token.

func (AdminNatsBootstrapTokenHandler) Parse added in v1.0.79

Parse processes the command-line arguments for the admin nats generate-bootstrap-token subcommand.

type AdminNatsHandler added in v1.0.79

type AdminNatsHandler struct{}

AdminNatsHandler handles multi-level `admin nats ...` commands.

func (AdminNatsHandler) Parse added in v1.0.79

func (AdminNatsHandler) Parse(args []string, cfg *CmdConfig) error

Parse dispatches nested admin nats commands.

type AgentConfig

type AgentConfig struct {
	Address  string          `json:"address"`
	Checks   []CheckConfig   `json:"checks"`
	Security json.RawMessage `json:"security,omitempty"`
}

AgentConfig represents a subset of agent configuration.

type CheckConfig

type CheckConfig struct {
	ServiceType string `json:"service_type"`
	ServiceName string `json:"service_name"`
	Details     string `json:"details,omitempty"`
	Port        int32  `json:"port,omitempty"`
}

CheckConfig represents a service check configuration.

type CmdConfig

type CmdConfig struct {
	Help            bool
	SubCmd          string
	EdgeCommand     string
	ConfigFile      string
	AdminHash       string
	DBPasswordFile  string
	GatewayFile     string
	Action          string
	Agent           string
	ServiceType     string
	ServiceName     string
	ServiceDetails  string
	ServicePort     int32
	EnableAllOnInit bool
	Args            []string
	IPS             string
	CertDir         string
	AddIPs          bool
	NonInteractive  bool
	Components      []string
	// JWT key generation
	JWTKeyBits                 int
	JWTKeyID                   string
	JWTForce                   bool
	CoreAPIURL                 string
	APIKey                     string
	BearerToken                string
	TLSSkipVerify              bool
	JoinTokenTTLSeconds        int
	AgentSPIFFEID              string
	DownstreamSPIFFEID         string
	DownstreamSelectors        []string
	DownstreamX509TTLSeconds   int
	DownstreamJWTTTLSeconds    int
	DownstreamAdmin            bool
	DownstreamStoreSVID        bool
	DownstreamDNSNames         []string
	DownstreamFederates        []string
	NoDownstream               bool
	JoinTokenOutput            string
	EdgePackageID              string
	EdgePackageDownloadToken   string
	EdgePackageOutput          string
	EdgePackageReason          string
	EdgePackageAction          string
	EdgePackageFormat          string
	EdgePackageLabel           string
	EdgePackageComponentID     string
	EdgePackageComponentType   string
	EdgePackageParentType      string
	EdgePackageParentID        string
	EdgePackageGatewayID       string
	EdgePackageSite            string
	EdgePackageSelectors       []string
	EdgePackageMetadata        string
	EdgePackageMetadataMap     map[string]string
	EdgePackageNotes           string
	EdgePackageCheckerKind     string
	EdgePackageCheckerConfig   string
	EdgePackageDataSvc         string
	EdgePackageDownstreamID    string
	EdgePackageLimit           int
	EdgePackageStatuses        []string
	EdgePackageTypes           []string
	EdgePackageComponentFilter string
	EdgePackageParentFilter    string
	EdgePackageGatewayFilter   string
	EdgeOutputFormat           string
	EdgePackageReissueToken    bool
	EdgeJoinTTLSeconds         int
	EdgeDownloadTTLSeconds     int
	EnrollToken                string
	EnrollCoreURL              string
	EnrollHostIP               string
	EnrollConfigPath           string
	EnrollConfigDir            string
	EnrollConfigFile           string
	EnrollCertDir              string
	EnrollCredsDir             string
	EnrollForce                bool
	EnrollInsecure             bool
	EnrollCAFile               string
	// NATS bootstrap configuration
	NATSBootstrapToken   string
	NATSOutputDir        string
	NATSOperatorName     string
	NATSImportSeed       string
	NATSVerifyMode       bool
	NATSConfigPath       string
	NATSNoSystemAccount  bool
	NATSJetStream        bool
	NATSJetStreamDir     string
	NATSTLSCert          string
	NATSTLSKey           string
	NATSTLSCA            string
	NATSNoTLS            bool
	NATSOutputFormat     string
	NATSBootstrapExpires string
	NATSLocalBootstrap   bool
	NATSWriteSystemCreds bool
	NATSWritePlatform    bool
	NATSPlatformAccount  string
	NATSPlatformUser     string
	NATSSystemUser       string
	NATSAccountLimit     int
	AdminNatsAction      string
	AdminCommand         string
}

CmdConfig holds parsed command-line configuration.

func ParseFlags

func ParseFlags() (*CmdConfig, error)

ParseFlags parses command-line flags and subcommands

type EdgeHandler added in v1.0.55

type EdgeHandler struct{}

EdgeHandler handles multi-level `edge ...` commands.

func (EdgeHandler) Parse added in v1.0.55

func (EdgeHandler) Parse(args []string, cfg *CmdConfig) error

Parse dispatches nested edge commands (currently only packages).

type EdgePackageDownloadHandler added in v1.0.55

type EdgePackageDownloadHandler struct{}

EdgePackageDownloadHandler handles flags for downloading onboarding artifacts.

func (EdgePackageDownloadHandler) Parse added in v1.0.55

func (EdgePackageDownloadHandler) Parse(args []string, cfg *CmdConfig) error

Parse reads flags for the edge-package-download subcommand.

type EdgePackageRevokeHandler added in v1.0.55

type EdgePackageRevokeHandler struct{}

EdgePackageRevokeHandler handles flags for revoking onboarding packages.

func (EdgePackageRevokeHandler) Parse added in v1.0.55

func (EdgePackageRevokeHandler) Parse(args []string, cfg *CmdConfig) error

Parse reads flags for the edge-package-revoke subcommand.

type EdgePackageTokenHandler added in v1.0.55

type EdgePackageTokenHandler struct{}

EdgePackageTokenHandler handles flags for emitting structured onboarding tokens.

func (EdgePackageTokenHandler) Parse added in v1.0.55

func (EdgePackageTokenHandler) Parse(args []string, cfg *CmdConfig) error

Parse reads flags for the edge-package-token subcommand.

type EnrollHandler added in v1.0.85

type EnrollHandler struct{}

EnrollHandler handles flags for the enroll command.

func (EnrollHandler) Parse added in v1.0.85

func (EnrollHandler) Parse(args []string, cfg *CmdConfig) error

Parse reads flags for the enroll subcommand.

type GatewayConfig added in v1.0.79

type GatewayConfig struct {
	Agents       map[string]AgentConfig `json:"agents"`
	CoreAddress  string                 `json:"core_address"`
	ListenAddr   string                 `json:"listen_addr"`
	PollInterval string                 `json:"poll_interval"`
	GatewayID    string                 `json:"gateway_id"`
	Partition    string                 `json:"partition"`
	ServiceName  string                 `json:"service_name"`
	ServiceType  string                 `json:"service_type"`
	Security     json.RawMessage        `json:"security,omitempty"`
}

GatewayConfig represents a subset of the gateway configuration.

type GenerateJWTKeysHandler added in v1.0.55

type GenerateJWTKeysHandler struct{}

GenerateJWTKeysHandler handles flags for the generate-jwt-keys subcommand.

func (GenerateJWTKeysHandler) Parse added in v1.0.55

func (GenerateJWTKeysHandler) Parse(args []string, cfg *CmdConfig) error

Parse processes arguments for generate-jwt-keys.

type GenerateTLSHandler

type GenerateTLSHandler struct{}

GenerateTLSHandler handles flags for the generate-tls subcommand

func (GenerateTLSHandler) Parse

func (GenerateTLSHandler) Parse(args []string, cfg *CmdConfig) error

Parse processes the command-line arguments for the generate-tls subcommand.

type NatsBootstrapHandler added in v1.0.79

type NatsBootstrapHandler struct{}

NatsBootstrapHandler handles flags for the nats-bootstrap subcommand.

func (NatsBootstrapHandler) Parse added in v1.0.79

func (NatsBootstrapHandler) Parse(args []string, cfg *CmdConfig) error

Parse processes the command-line arguments for the nats-bootstrap subcommand.

type SpireJoinTokenHandler added in v1.0.55

type SpireJoinTokenHandler struct{}

SpireJoinTokenHandler handles flags for the spire-join-token subcommand.

func (SpireJoinTokenHandler) Parse added in v1.0.55

func (SpireJoinTokenHandler) Parse(args []string, cfg *CmdConfig) error

Parse processes the command-line arguments for the spire-join-token subcommand.

type SubcommandHandler

type SubcommandHandler interface {
	Parse(args []string, cfg *CmdConfig) error
}

SubcommandHandler defines the interface for parsing subcommand flags.

type UpdateConfigHandler

type UpdateConfigHandler struct{}

UpdateConfigHandler handles flags for the update-config subcommand.

func (UpdateConfigHandler) Parse

func (UpdateConfigHandler) Parse(args []string, cfg *CmdConfig) error

Parse processes the command-line arguments for the update-config subcommand.

type UpdateGatewayHandler added in v1.0.79

type UpdateGatewayHandler struct{}

UpdateGatewayHandler handles flags for the update-gateway subcommand

func (UpdateGatewayHandler) Parse added in v1.0.79

func (UpdateGatewayHandler) Parse(args []string, cfg *CmdConfig) error

Parse processes the command-line arguments for the update-gateway subcommand.

Jump to

Keyboard shortcuts

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