Categorygithub.com/elastic/uptd
modulepackage
1.0.2
Repository: https://github.com/elastic/uptd.git
Documentation: pkg.go.dev

# README

Up To Date Build Status

uptd (shorthand for up to date) is a Go package which provides primitives and mechanisms to check if a version is up to date according to the latest one published in a remote artifact repository.

Installation

To download the source, run: go get github.com/elastic/uptd.

Usage


import (
    "fmt"

    "github.com/elastic/uptd"
)

func main() {
    var githubToken = "your personal github token"

    provider, err := uptd.NewGithubProvider("elastic", "go-licenser", githubToken)
    if err != nil {
        panic(err)
    }

    uptodate, err := uptd.New(provider, version)
    if err != nil {
        panic(err)
    }

    res, err := uptodate.Check()
    if err != nil {
        panic(err)
    }

    if res.NeedsUpdate {
        fmt.Printf(
            "new version %s available, release URL is %s",
            res.Latest.Version.String(), res.Latest.URL,
        )
    }
}

Contributing

See CONTRIBUTING.md.

# Functions

New instantiates a new Uptd from the sent Provider and current version.
NewGithubProvider constructs a new GithubProvider from its parameters.

# Structs

CheckResponse is given back by the Check method of an updater.
GithubProvider is the implementation of an update Provider that is used by the Updater struct.
LatestResponse is given back by the Latest method of an update Provider.
Uptd checks if the current version is the latest one and thus up to date.

# Interfaces

Provider represents the remote artifact repository where the updater checks if there's a newer version.

# Type aliases

GetLatestFunc is used by the GithubProvider to discover newer releases.