updateutils

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Organization        = "projectdiscovery"
	UpdateCheckEndpoint = "https://api.pdtm.sh/api/v1/tools/%v"
)

Variables

View Source
var (
	ErrNoAssetFound = errorutil.NewWithFmt("update: could not find release asset for your platform (%s/%s)")
	GHAssetName     = ""
)
View Source
var (
	// By default when tool is updated release notes of latest version are printed
	HideReleaseNotes      = false
	HideProgressBar       = false
	VersionCheckTimeout   = time.Duration(5) * time.Second
	DownloadUpdateTimeout = time.Duration(30) * time.Second
	// Note: DefaultHttpClient is only used in VersionCheck Callback
	DefaultHttpClient *http.Client
)

Functions

func GetUpdateToolCallback

func GetUpdateToolCallback(toolName, version string) func()

GetUpdateToolCallback returns a callback function that updates given tool if given version is older than latest gh release and exits

func GetVersionCheckCallback

func GetVersionCheckCallback(toolName string) func() (string, error)

GetVersionCheckCallback retuns a callback function that returns latest version of tool

func GetVersionDescription

func GetVersionDescription(current string, latest string) string

GetVersionDescription returns tags like (latest) or (outdated) or (dev)

Types

type AssetFormat

type AssetFormat uint
const (
	Zip AssetFormat = iota
	Tar
)

type GHReleaseDownloader

type GHReleaseDownloader struct {
	ToolName  string // we assume toolname and ToolName are always same
	Format    AssetFormat
	AssetID   int
	AssetName string
	// contains filtered or unexported fields
}

GHReleaseDownloader fetches and reads release of a gh repo

func NewghReleaseDownloader

func NewghReleaseDownloader(toolName string) *GHReleaseDownloader

NewghReleaseDownloader instance

func (*GHReleaseDownloader) DownloadAssetFromID

func (d *GHReleaseDownloader) DownloadAssetFromID() (*bytes.Buffer, error)

DownloadAssetFromID downloads and returns a buffer or a descriptive error

func (*GHReleaseDownloader) GetAssetIDFromRelease

func (d *GHReleaseDownloader) GetAssetIDFromRelease(latest *github.RepositoryRelease) error

getAssetIDFromRelease finds AssetID from release or returns a descriptive error

func (*GHReleaseDownloader) GetExecutableFromAsset

func (d *GHReleaseDownloader) GetExecutableFromAsset() ([]byte, error)

GetExecutableFromAsset downloads and only returns tool Binary

func (*GHReleaseDownloader) GetLatestRelease

func (d *GHReleaseDownloader) GetLatestRelease() (*github.RepositoryRelease, error)

getLatestRelease returns latest release of error

type Tool

type Tool struct {
	Name    string            `json:"name"`
	Repo    string            `json:"repo"`
	Version string            `json:"version"`
	Assets  map[string]string `json:"assets"`
}

Tool

Jump to

Keyboard shortcuts

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