setup

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 29 Imported by: 0

README

Setup

Bootstrapping logic for tool initialization and self-updating capabilities.

Features

  • Interactive tool initialization (init flow)
  • GitHub & GitLab authentication and SSH key management
  • Automated self-update system with pluggable release providers
  • Semantic version management

For detailed documentation and integration guides, see the Setup Component Documentation.

Documentation

Index

Constants

View Source
const (
	UpdatedKey = timeSinceKey("updated")
	CheckedKey = timeSinceKey("checked")
)
View Source
const (
	DefaultConfigFilename = "config.yaml"
)

Variables

View Source
var DefaultConfig []byte

Functions

func GetDefaultConfigDir

func GetDefaultConfigDir(fs afero.Fs, name string) string

func GetFeatureFlags

func GetFeatureFlags() map[props.FeatureCmd][]FeatureFlag

GetFeatureFlags returns all registered feature flag providers.

func GetInitialisers

func GetInitialisers() map[props.FeatureCmd][]InitialiserProvider

GetInitialisers returns all registered initialiser providers.

func GetSubcommands

func GetSubcommands() map[props.FeatureCmd][]SubcommandProvider

GetSubcommands returns all registered subcommand providers.

func GetTimeSinceLast

func GetTimeSinceLast(fs afero.Fs, name string, status timeSinceKey) time.Duration

func Initialise

func Initialise(props *props.Props, opts InitOptions) (string, error)

Initialise creates the default configuration file in the specified directory.

func Register

func Register(feature props.FeatureCmd, ips []InitialiserProvider, sps []SubcommandProvider, fps []FeatureFlag)

Register adds initialisers, subcommands, and flags for a specific feature.

func SetTimeSinceLast

func SetTimeSinceLast(fs afero.Fs, name string, status timeSinceKey) error

func SkipUpdateCheck

func SkipUpdateCheck(fs afero.Fs, name string, cmd *cobra.Command) bool

Types

type FeatureFlag

type FeatureFlag func(cmd *cobra.Command)

FeatureFlag is a function that registers flags on a cobra command.

type FeatureRegistry

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

FeatureRegistry holds the registered initialisers, subcommands, and flags for features.

type InitOptions

type InitOptions struct {
	Dir          string
	Clean        bool
	SkipLogin    bool
	SkipKey      bool
	SkipAI       bool
	Initialisers []Initialiser
}

InitOptions holds the options for the Initialise function.

type Initialiser

type Initialiser interface {
	// Name returns a human-readable name for logging.
	Name() string
	// IsConfigured returns true if this initialiser's config is already present.
	IsConfigured(cfg config.Containable) bool
	// Configure runs the interactive config and writes values into cfg.
	Configure(p *props.Props, cfg config.Containable) error
}

Initialiser is an optional config step that can check if it's already configured and, if not, interactively populate the shared viper config.

type InitialiserProvider

type InitialiserProvider func(p *props.Props) Initialiser

InitialiserProvider is a function that creates an Initialiser.

type SelfUpdater

type SelfUpdater struct {
	Tool props.Tool

	CurrentVersion string
	NextRelease    release.Release
	Fs             afero.Fs
	// contains filtered or unexported fields
}

func NewUpdater

func NewUpdater(props *props.Props, version string, force bool) (*SelfUpdater, error)

func (*SelfUpdater) DownloadAsset

func (s *SelfUpdater) DownloadAsset(ctx context.Context, asset release.ReleaseAsset) (bytes.Buffer, error)

DownloadFileFromGitLab Download raw bytes from gitlab url, using authenticated client. DownloadFileFromGitLab Download raw bytes from gitlab url, using authenticated client.

func (*SelfUpdater) GetLatestRelease

func (s *SelfUpdater) GetLatestRelease(ctx context.Context) (release.Release, error)

func (*SelfUpdater) GetLatestVersionString

func (s *SelfUpdater) GetLatestVersionString(ctx context.Context) (string, error)

func (*SelfUpdater) GetReleaseNotes

func (s *SelfUpdater) GetReleaseNotes(ctx context.Context, from string, to string) (string, error)

GetReleaseNotes retrieves the release notes for releases between the specified 'from' and 'to' versions (inclusive).

func (*SelfUpdater) IsLatestVersion

func (s *SelfUpdater) IsLatestVersion(ctx context.Context) (bool, string, error)

IsLatestVersion Check if the current running binary is the latest version. IsLatestVersion Check if the current running binary is the latest version.

func (*SelfUpdater) Update

func (s *SelfUpdater) Update(ctx context.Context) (string, error)

SelfUpdate Install the latest version of the binary to the given targetPath If targetPath is empty, the current running executable path will be treated as targetPath. SelfUpdate Install the latest version of the binary to the given targetPath If targetPath is empty, the current running executable path will be treated as targetPath.

type SubcommandProvider

type SubcommandProvider func(p *props.Props) []*cobra.Command

SubcommandProvider is a function that creates a slice of cobra subcommands.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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