Documentation
¶
Index ¶
- Constants
- Variables
- func GetDefaultConfigDir(fs afero.Fs, name string) string
- func GetFeatureFlags() map[props.FeatureCmd][]FeatureFlag
- func GetInitialisers() map[props.FeatureCmd][]InitialiserProvider
- func GetSubcommands() map[props.FeatureCmd][]SubcommandProvider
- func GetTimeSinceLast(fs afero.Fs, name string, status timeSinceKey) time.Duration
- func Initialise(props *props.Props, opts InitOptions) (string, error)
- func Register(feature props.FeatureCmd, ips []InitialiserProvider, sps []SubcommandProvider, ...)
- func SetTimeSinceLast(fs afero.Fs, name string, status timeSinceKey) error
- func SkipUpdateCheck(fs afero.Fs, name string, cmd *cobra.Command) bool
- type FeatureFlag
- type FeatureRegistry
- type InitOptions
- type Initialiser
- type InitialiserProvider
- type SelfUpdater
- func (s *SelfUpdater) DownloadAsset(ctx context.Context, asset release.ReleaseAsset) (bytes.Buffer, error)
- func (s *SelfUpdater) GetLatestRelease(ctx context.Context) (release.Release, error)
- func (s *SelfUpdater) GetLatestVersionString(ctx context.Context) (string, error)
- func (s *SelfUpdater) GetReleaseNotes(ctx context.Context, from string, to string) (string, error)
- func (s *SelfUpdater) IsLatestVersion(ctx context.Context) (bool, string, error)
- func (s *SelfUpdater) Update(ctx context.Context) (string, error)
- type SubcommandProvider
Constants ¶
const ( UpdatedKey = timeSinceKey("updated") CheckedKey = timeSinceKey("checked") )
const (
DefaultConfigFilename = "config.yaml"
)
Variables ¶
var DefaultConfig []byte
Functions ¶
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 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.
Types ¶
type FeatureFlag ¶
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 (*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 (*SelfUpdater) GetLatestVersionString ¶
func (s *SelfUpdater) GetLatestVersionString(ctx context.Context) (string, error)
func (*SelfUpdater) GetReleaseNotes ¶
GetReleaseNotes retrieves the release notes for releases between the specified 'from' and 'to' versions (inclusive).
func (*SelfUpdater) IsLatestVersion ¶
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.