update

package
v0.0.0-...-0bde480 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MetadataURL = "https://docs.slack.dev/tools/metadata.json"

Functions

func AutoUpdate

func AutoUpdate(ctx context.Context, clients *shared.ClientFactory, currentVersion string, targetVersion string) error

AutoUpdate installs the targetVersion of the CLI over the currentVersion and records the result for the next command to report. It returns without installing or recording while another update holds the lock next to the binary, or when the binary is already updated.

func ExtractArchive

func ExtractArchive(src, dest string) (string, error)

ExtractArchive extracts the contents of the archive of the archive at src into the dest directory and returns the extracted file that it believes is the newly upgraded binary. Supports zip and tar.gz formats, which is determined by the file extension.

func IsHomebrew

func IsHomebrew(binary string) bool

IsHomebrew will check if the binary is found under the Homebrew prefix.

Borrowed from https://github.com/cli/cli/blob/6b9a8608f6211f9f46f745b610021492c79c3482/cmd/gh/main.go

func SemVerGreaterThan

func SemVerGreaterThan(release string, current string) (bool, error)

SemVerGreaterThan returns true if release is greater than current, ignoring prerelease and development suffixes of current

func UpgradeFromLocalFile

func UpgradeFromLocalFile(cliUpgradeData cliUpgrade) error

UpgradeFromLocalFile performs an upgrade given an upgrade configuration.

Types

type AutoUpdateResult

type AutoUpdateResult struct {
	From  string `json:"from"`
	To    string `json:"to"`
	Error string `json:"error,omitempty"`
}

AutoUpdateResult is the outcome of a background update of the Slack CLI

type CLIDependency

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

CLIDependency contains information about the current version and the latest CLI release version from Slack CLI metadata

func NewCLIDependency

func NewCLIDependency(clients *shared.ClientFactory, version string) *CLIDependency

NewCLIDependency creates and returns a new instance of CLIDependency

func (*CLIDependency) CheckForUpdate

func (c *CLIDependency) CheckForUpdate(ctx context.Context) error

CheckForUpdate retrieves and sets the LatestCLIRelease that describes the latest update available directly to the CLIDependency instance Synchronous version of CheckForUpdateInBackground

func (*CLIDependency) HasUpdate

func (c *CLIDependency) HasUpdate() (bool, error)

func (*CLIDependency) InstallUpdate

func (c *CLIDependency) InstallUpdate(ctx context.Context) error

InstallUpdate grabs the latest version of the CLI binary and installs it onto the system

func (*CLIDependency) PrintUpdateNotification

func (c *CLIDependency) PrintUpdateNotification(cmd *cobra.Command) (bool, error)

PrintUpdateNotification notifies the user that a new version is available and provides upgrade instructions for Homebrew. Returns a bool representing whether the user wants the self-update to run

type CLIReleaseInfo

type CLIReleaseInfo struct {
	SlackCLI struct {
		Title       string `json:"title"`
		Description string `json:"description"`
		Releases    []struct {
			Version     string `json:"version"`
			ReleaseDate string `json:"release_date"`
		} `json:"releases"`
	} `json:"slack-cli"`
}

CLIReleaseInfo stores information about most recent release's version and release date

type Dependency

type Dependency interface {
	CheckForUpdate(ctx context.Context) error
	PrintUpdateNotification(cmd *cobra.Command) (bool, error)
	HasUpdate() (bool, error)
	InstallUpdate(ctx context.Context) error
}

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient interface

type LatestCLIRelease

type LatestCLIRelease struct {
	Version string
}

type Metadata

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

func (*Metadata) CheckForUpdate

func (md *Metadata) CheckForUpdate(ctx context.Context, url, currentVersion string) (*LatestCLIRelease, error)

checkForUpdate returns the release info from CLI meta including the most recent CLI version that is an upgrade to the currentVersion parameter or nil if no upgrade is available.

type SDKDependency

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

SDKDependency contains the latest release information for dependencies used by a given project

func NewSDKDependency

func NewSDKDependency(clients *shared.ClientFactory) *SDKDependency

NewSDKDependency creates and returns a new instance of SDKDependency

func (*SDKDependency) CheckForUpdate

func (c *SDKDependency) CheckForUpdate(ctx context.Context) error

CheckForUpdate executes the `check-update` hook, if available, and sets the release information to the SDKDependency instance

func (*SDKDependency) HasUpdate

func (c *SDKDependency) HasUpdate() (bool, error)

HasUpdate returns true if the SDK has an update available

func (*SDKDependency) InstallUpdate

func (c *SDKDependency) InstallUpdate(ctx context.Context) error

InstallUpdate executes the `install-update` hook, if available, and prints information about the execution of available updates

func (*SDKDependency) PrintUpdateNotification

func (c *SDKDependency) PrintUpdateNotification(cmd *cobra.Command) (bool, error)

PrintUpdateNotification prints out the update message returned from the SDK, including formatting and language that indicates if a breaking change is included or an error has occurred

type SDKInstallUpdateComponent

type SDKInstallUpdateComponent struct {
	Name             string `json:"name"`
	PreviousVersion  string `json:"previous"`
	InstalledVersion string `json:"installed"`
	Error            struct {
		Message string `json:"message,omitempty"`
	} `json:"error"`
}

SDKInstallUpdateComponent contains the information about a given SDK dependency's install update

type SDKInstallUpdateResponse

type SDKInstallUpdateResponse struct {
	Name    string                      `json:"name"`
	Updates []SDKInstallUpdateComponent `json:"updates"`
	Error   struct {
		Message string `json:"message,omitempty"`
	} `json:"error"`
}

SDKInstallUpdateResponse contains information following the attempted updating of dependencies used within a given project

type SDKReleaseComponent

type SDKReleaseComponent struct {
	Name     string `json:"name"`
	Current  string `json:"current"`
	Latest   string `json:"latest"`
	Breaking bool   `json:"breaking"`
	Update   bool   `json:"update"`
	Message  string `json:"message"`
	URL      string `json:"url"`
	Error    struct {
		Message string `json:"message"`
	} `json:"error"`
}

SDKReleaseComponent contains the information about a given SDK dependency's update status

type SDKReleaseInfo

type SDKReleaseInfo struct {
	Name     string `json:"name"`
	Breaking bool
	Update   bool
	Releases []SDKReleaseComponent `json:"releases"`
	Message  string                `json:"message"`
	URL      string                `json:"url"`
	Error    struct {
		Message string `json:"message"`
	} `json:"error"`
}

SDKReleaseInfo contains the information about updates available for the dependencies used within a given project

func CheckUpdateHook

func CheckUpdateHook(ctx context.Context, clients *shared.ClientFactory) (SDKReleaseInfo, error)

CheckUpdateHook returns the response from the check update hook

type UpdateNotification

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

UpdateNotification checks for an update (non-blocking in the background or blocking). It provides the release information for the latest update of each dependency.

func New

func New(clients *shared.ClientFactory, cliVersion string) *UpdateNotification

New is the constructor for UpdateNotification that sets good defaults.

func (*UpdateNotification) CheckForUpdate

func (u *UpdateNotification) CheckForUpdate(ctx context.Context, shouldForceUpdateCheck bool) error

CheckForUpdate has each dependency perform a self-check for available updates. This is the synchronous version of CheckForUpdateInBackground

func (*UpdateNotification) CheckForUpdateInBackground

func (u *UpdateNotification) CheckForUpdateInBackground(ctx context.Context)

CheckForUpdateInBackground starts a Go routine that checks for an update every hoursSinceLastUpdateCheck (e.g. 24 hours).

func (*UpdateNotification) Dependencies

func (u *UpdateNotification) Dependencies() []Dependency

Dependencies returns the dependencies to check for updates.

func (*UpdateNotification) HasUpdate

func (u *UpdateNotification) HasUpdate() bool

HasUpdate returns true if any dependency has an update available.

func (*UpdateNotification) PrintAndPromptUpdates

func (u *UpdateNotification) PrintAndPromptUpdates(cmd *cobra.Command) error

PrintAndPromptUpdates displays an update message and prompts the user if they want to update, if applicable Invoked from root command's post-run method and the upgrade command. If an error occurs, we return it so it is raised to the user.

Jump to

Keyboard shortcuts

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