setup

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 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

Overview

Package setup provides initialisation helpers for GTB-based tools, including configuration directory bootstrapping, default config file creation, and self-update orchestration.

The Initialiser interface supports a modular hook-based pattern for extending the init process — SSH key setup, authentication configuration, and custom post-init steps can be composed and ordered. Update checks use semantic version comparison against the configured release source (GitHub or GitLab).

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 GetChecks added in v1.4.0

func GetChecks() map[props.FeatureCmd][]CheckProvider

GetChecks returns all registered check providers.

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 RegisterChecks added in v1.4.0

func RegisterChecks(feature props.FeatureCmd, cps []CheckProvider)

RegisterChecks adds diagnostic check providers 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 CheckFunc added in v1.4.0

type CheckFunc func(ctx context.Context, props *props.Props) CheckResult

CheckFunc is the signature for individual diagnostic checks.

type CheckProvider added in v1.4.0

type CheckProvider func(p *props.Props) []CheckFunc

CheckProvider is a function that returns diagnostic checks for a feature.

type CheckResult added in v1.4.0

type CheckResult struct {
	Name    string `json:"name"`
	Status  string `json:"status"`
	Message string `json:"message"`
	Details string `json:"details,omitempty"`
}

CheckResult represents the outcome of a single diagnostic check.

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, flags, and checks 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
Package ai provides factory functions that construct chat.ChatClient instances from Props configuration, resolving the configured provider (Claude, OpenAI, Gemini) and wiring API keys, model selection, and token limits for use in documentation generation and agentic verification loops.
Package ai provides factory functions that construct chat.ChatClient instances from Props configuration, resolving the configured provider (Claude, OpenAI, Gemini) and wiring API keys, model selection, and token limits for use in documentation generation and agentic verification loops.
Package github provides GitHub-specific setup helpers including token resolution from configuration and environment, and authenticated HTTP client construction for use with the GitHub API.
Package github provides GitHub-specific setup helpers including token resolution from configuration and environment, and authenticated HTTP client construction for use with the GitHub API.

Jump to

Keyboard shortcuts

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