cli

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(ctx context.Context, args []string, options Options) int

Execute runs a fresh command tree and renders any error at the process boundary.

func NewCommand

func NewCommand(options Options) *cobra.Command

NewCommand constructs a fresh Cobra command tree.

Types

type BootstrapInput

type BootstrapInput struct {
	Handle      string
	DisplayName string
	TokenLabel  string
}

BootstrapInput describes the first human operator and token.

type Config

type Config struct {
	Endpoint                      string `mapstructure:"endpoint" json:"endpoint"`
	Output                        string `mapstructure:"output" json:"output"`
	Listen                        string `mapstructure:"listen" json:"listen"`
	BrowserCookieMode             string `mapstructure:"browser_cookie_mode" json:"browser_cookie_mode"`
	APITokenFile                  string `mapstructure:"api_token_file" json:"api_token_file"`
	DatabaseURLFile               string `mapstructure:"database_url_file" json:"database_url_file"`
	PowerDNSURL                   string `mapstructure:"powerdns_url" json:"powerdns_url"`
	PowerDNSUnixSocket            string `mapstructure:"powerdns_unix_socket" json:"powerdns_unix_socket"`
	PowerDNSUpstream              string `mapstructure:"powerdns_upstream" json:"powerdns_upstream"`
	PowerDNSTimeout               string `mapstructure:"powerdns_timeout" json:"powerdns_timeout"`
	PowerDNSAPIKeyFile            string `mapstructure:"powerdns_api_key_file" json:"powerdns_api_key_file"`
	PowerDNSConfigFile            string `mapstructure:"powerdns_config_file" json:"powerdns_config_file"`
	DatabaseMaxConnections        string `mapstructure:"database_max_connections" json:"database_max_connections"`
	DatabaseAuthenticationReserve string `mapstructure:"database_authentication_reserve" json:"database_authentication_reserve"`
	DatabaseReadinessReserve      string `mapstructure:"database_readiness_reserve" json:"database_readiness_reserve"`
	DatabaseConnectTimeout        string `mapstructure:"database_connect_timeout" json:"database_connect_timeout"`
	DatabaseStatementTimeout      string `mapstructure:"database_statement_timeout" json:"database_statement_timeout"`
	DatabaseLockTimeout           string `mapstructure:"database_lock_timeout" json:"database_lock_timeout"`
	DatabaseTransactionTimeout    string `mapstructure:"database_transaction_timeout" json:"database_transaction_timeout"`
	MaxBodyBytes                  string `mapstructure:"max_body_bytes" json:"max_body_bytes"`
	RequestTimeout                string `mapstructure:"request_timeout" json:"request_timeout"`
	MaxConcurrentRequests         string `mapstructure:"max_concurrent_requests" json:"max_concurrent_requests"`
	MaxHeaderBytes                string `mapstructure:"max_header_bytes" json:"max_header_bytes"`
	ReadHeaderTimeout             string `mapstructure:"read_header_timeout" json:"read_header_timeout"`
	ReadTimeout                   string `mapstructure:"read_timeout" json:"read_timeout"`
	WriteTimeout                  string `mapstructure:"write_timeout" json:"write_timeout"`
	IdleTimeout                   string `mapstructure:"idle_timeout" json:"idle_timeout"`
	HealthTimeout                 string `mapstructure:"health_timeout" json:"health_timeout"`
	ShutdownTimeout               string `mapstructure:"shutdown_timeout" json:"shutdown_timeout"`
	RateLimitEnabled              string `mapstructure:"rate_limit_enabled" json:"rate_limit_enabled"`
	RateLimitRedisTimeout         string `mapstructure:"rate_limit_redis_timeout" json:"rate_limit_redis_timeout"`
	RateLimitPolicyFile           string `mapstructure:"rate_limit_policy_file" json:"rate_limit_policy_file"`
	RedisURLFile                  string `mapstructure:"redis_url_file" json:"redis_url_file"`
}

Config is the immutable configuration resolved for one command invocation.

type DatabaseMaintenance

type DatabaseMaintenance struct{}

DatabaseMaintenance adapts the offline Cobra workflows to PostgreSQL application services. Each command owns exactly one short-lived connection.

func NewDatabaseMaintenance

func NewDatabaseMaintenance() *DatabaseMaintenance

NewDatabaseMaintenance constructs the production offline-maintenance adapter.

func (*DatabaseMaintenance) Bootstrap

func (*DatabaseMaintenance) Bootstrap(ctx context.Context, databaseURL httpapi.Secret, input BootstrapInput) (OneTimeCredential, error)

func (*DatabaseMaintenance) FinalizeRestore

func (*DatabaseMaintenance) Migrate

func (*DatabaseMaintenance) Migrate(ctx context.Context, databaseURL httpapi.Secret) error

func (*DatabaseMaintenance) MigrationStatus

func (*DatabaseMaintenance) MigrationStatus(ctx context.Context, databaseURL httpapi.Secret) (MigrationState, error)

func (*DatabaseMaintenance) RecoverOperator

func (*DatabaseMaintenance) RecoverOperator(ctx context.Context, databaseURL httpapi.Secret, input OperatorRecoveryInput) (OneTimeCredential, error)

type Maintenance

Maintenance is the narrow adapter from Cobra commands to database application services.

type MigrationState

type MigrationState struct {
	CurrentVersion int  `json:"current_version"`
	LatestVersion  int  `json:"latest_version"`
	Compatible     bool `json:"compatible"`
}

MigrationState is the stable CLI representation of database schema status.

type OneTimeCredential

type OneTimeCredential struct {
	IdentityID string `json:"identity_id"`
	Handle     string `json:"handle"`
	TokenID    string `json:"token_id"`
	TokenLabel string `json:"token_label"`
	Secret     string `json:"secret"`
}

OneTimeCredential is printed once after an offline credential-issuance workflow.

type OperatorRecoveryInput

type OperatorRecoveryInput struct {
	IdentityID string
	Handle     string
	TokenLabel string
}

OperatorRecoveryInput identifies an existing operator and the new token label.

type Options

type Options struct {
	Version     string
	Streams     Streams
	HTTPClient  api.HttpRequestDoer
	Maintenance Maintenance
	Server      Server
}

Options configures one independent command tree.

type RestoreFinalizationInput

type RestoreFinalizationInput struct {
	IdentityID string
	Handle     string
	TokenLabel string
}

RestoreFinalizationInput selects the operator that receives the sole replacement token.

type RuntimeServer

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

RuntimeServer assembles and owns one production API instance.

func NewRuntimeServer

func NewRuntimeServer(logOutput io.Writer) *RuntimeServer

NewRuntimeServer creates a production server whose structured runtime and access logs are written to logOutput.

func (*RuntimeServer) Serve

func (runtime *RuntimeServer) Serve(ctx context.Context, config ServeConfig) error

type ServeConfig

type ServeConfig struct {
	Address                       string
	DevelopmentHTTP               bool
	DatabaseURL                   httpapi.Secret
	DatabaseMaxConnections        int32
	DatabaseAuthenticationReserve int32
	DatabaseReadinessReserve      int32
	DatabaseConnectTimeout        time.Duration
	DatabaseStatementTimeout      time.Duration
	DatabaseLockTimeout           time.Duration
	DatabaseTransactionTimeout    time.Duration
	PowerDNSURL                   string
	PowerDNSUnixSocket            string
	PowerDNSUpstream              string
	PowerDNSAPIKey                httpapi.Secret
	PowerDNSTimeout               time.Duration
	MaxBodyBytes                  int64
	RequestTimeout                time.Duration
	MaxConcurrentRequests         int
	MaxHeaderBytes                int
	ReadHeaderTimeout             time.Duration
	ReadTimeout                   time.Duration
	WriteTimeout                  time.Duration
	IdleTimeout                   time.Duration
	HealthTimeout                 time.Duration
	ShutdownTimeout               time.Duration
	RateLimitEnabled              bool
	RateLimitRedisTimeout         time.Duration
	// RedisURL, RateLimitPolicy, and RateLimitWarnings are resolved only when
	// rate limiting is enabled.
	RedisURL          httpapi.Secret
	RateLimitPolicy   *ratelimit.Table
	RateLimitWarnings []string
}

ServeConfig is the immutable, secret-aware runtime configuration passed to the production server after Viper and every secret source have been read.

type Server

type Server interface {
	Serve(context.Context, ServeConfig) error
}

Server owns the long-running API runtime for the serve command.

type Streams

type Streams struct {
	In  io.Reader
	Out io.Writer
	Err io.Writer
}

Streams are the command's standard input, output, and error streams.

Jump to

Keyboard shortcuts

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