cmd

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const PKG_CMD = "cmd"

Variables

This section is empty.

Functions

func Run

func Run(version string, args []string) error

Run executes the CLI with the given version

Types

type CLI

type CLI struct {
	LogLevel  string              `kong:"help='Log level (trace,debug,info,warn,error)',default='info'"`
	LogFormat string              `kong:"help='Log format (console,json)',default='console'"`
	Version   VersionCmd          `kong:"cmd,help='Show version information'"`
	Snapshot  SnapshotCmd         `kong:"cmd,help='Take a snapshot of etcd and upload to S3'"`
	Restore   RestoreCmd          `kong:"cmd,help='Restore etcd from a snapshot stored in S3'"`
	List      ListCmd             `kong:"cmd,help='List snapshots stored locally and in S3'"`
	Cleanup   CleanupCmd          `kong:"cmd,help='Delete snapshots based on retention policies'"`
	Config    appconfig.AppConfig `kong:"embed"`
}

CLI represents the main CLI structure

func (*CLI) AfterApply

func (cli *CLI) AfterApply(ctx *kong.Context) error

AfterApply is called after Kong parses the CLI but before the command runs

type CLIContext

type CLIContext struct {
	Version string
	Config  *appconfig.AppConfig
	// contains filtered or unexported fields
}

CLIContext holds shared context for commands with S3 client caching

func NewCLIContext

func NewCLIContext(version string, config *appconfig.AppConfig) *CLIContext

NewCLIContext creates a new CLI context with S3 factory

func (*CLIContext) GetS3Client

func (ctx *CLIContext) GetS3Client() (*s3.Client, error)

GetS3Client returns a cached S3 client or creates a new one

func (*CLIContext) GetS3ClientOrNil

func (ctx *CLIContext) GetS3ClientOrNil() *s3.Client

GetS3ClientOrNil returns a cached S3 client or nil if creation fails

func (*CLIContext) GetS3Factory

func (ctx *CLIContext) GetS3Factory() *s3.ClientFactory

GetS3Factory returns the S3 client factory

type CleanupCmd

type CleanupCmd struct {
	Local   bool `kong:"help='Clean local snapshots only'"`
	Remote  bool `kong:"help='Clean S3 snapshots only'"`
	DryRun  bool `kong:"help='Show what would be deleted without actually deleting'"`
	Unified bool `kong:"help='Use unified retention evaluation across local and S3',default=true"`
}

CleanupCmd deletes snapshots based on retention policies

func (*CleanupCmd) Run

func (c *CleanupCmd) Run(ctx *CLIContext) error

type ListCmd

type ListCmd struct {
	Local   bool   `kong:"help='List local snapshots only'"`
	Remote  bool   `kong:"help='List S3 snapshots only'"`
	Format  string `kong:"help='Output format (table,json,yaml)',default='table'"`
	Unified bool   `kong:"help='Use unified retention evaluation across local and S3',default=true"`
}

ListCmd lists snapshots

func (*ListCmd) Run

func (l *ListCmd) Run(ctx *CLIContext) error

type RestoreCmd

type RestoreCmd struct {
	Source                   string `kong:"arg,required,help='Snapshot source (local path or S3 key)'"`
	DataDir                  string `kong:"help='etcd data directory for restore',default='/var/lib/etcd'"`
	Name                     string `kong:"help='etcd member name',default='default'"`
	InitialCluster           string `kong:"help='Initial cluster configuration',default='default=http://localhost:2380'"`
	InitialAdvertisePeerURLs string `kong:"help='Initial advertise peer URLs',default='http://localhost:2380'"`
	SkipHashCheck            bool   `kong:"help='Skip hash check during restore'"`
}

RestoreCmd restores etcd from a snapshot

func (*RestoreCmd) Run

func (r *RestoreCmd) Run(ctx *CLIContext) error

type SnapshotCmd

type SnapshotCmd struct {
	Name           string `kong:"help='Custom snapshot name',default=''"`
	UploadToS3     bool   `kong:"help='Upload snapshot to S3',default=true,name='upload-to-s3'"`
	RemoveLocal    bool   `kong:"help='Remove local snapshot after S3 upload'"`
	ApplyRetention bool   `kong:"help='Apply retention policies after snapshot',default=true"`
	Unified        bool   `kong:"help='Use unified retention evaluation across local and S3',default=true"`
	Compression    string `kong:"help='Compression algorithm for snapshot',default='zstd',enum='none,bzip2,gzip,lz4,zstd'"`
}

SnapshotCmd takes a snapshot of etcd and uploads to S3

func (*SnapshotCmd) Run

func (s *SnapshotCmd) Run(ctx *CLIContext) error

type SnapshotInfo

type SnapshotInfo struct {
	Name      string    `json:"name"`
	Location  string    `json:"location"`
	Size      int64     `json:"size"`
	Modified  time.Time `json:"modified"`
	Retention string    `json:"retention"` // "keep" or "delete"
}

type VersionCmd

type VersionCmd struct{}

VersionCmd shows version information

func (*VersionCmd) Run

func (v *VersionCmd) Run(ctx *CLIContext) error

Jump to

Keyboard shortcuts

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