Help us shape the future of Go! Take the 2026 Go Developer Survey

versioncheck

package
v1.21.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package versioncheck provides functions to check for the latest OPA release version from GitHub.

Index

Constants

This section is empty.

Variables

View Source
var ExternalServiceURL = "https://api.github.com"

ExternalServiceURL is the base HTTP URL for a github instance used to query for more recent version. If not otherwise specified, it will use the hard-coded default, api.github.com. GHRepo is the repository to use, and defaults to "open-policy-agent/opa"

Override at build time via:

-ldflags "-X github.com/open-policy-agent/opa/internal/versioncheck.ExternalServiceURL=<url>"
-ldflags "-X github.com/open-policy-agent/opa/internal/versioncheck.GHRepo=<url>"

ExternalServiceURL will be overridden if the OPA_VERSION_CHECK_SERVICE_URL environment variable is provided.

View Source
var GHRepo = "open-policy-agent/opa"

Functions

This section is empty.

Types

type Checker

type Checker interface {
	LatestVersion(ctx context.Context) (*DataResponse, error)
	RegisterGatherer(key string, f Gatherer)
}

Checker checks for the latest OPA release version

func New

func New(opts Options) (Checker, error)

New returns an instance of the Checker

type DataResponse

type DataResponse struct {
	Latest ReleaseDetails `json:"latest"`
}

DataResponse represents the data returned by the version check

func (*DataResponse) IsSet

func (dr *DataResponse) IsSet() bool

IsSet returns true if dr is populated.

func (*DataResponse) Pretty

func (dr *DataResponse) Pretty() string

Pretty returns OPA release information in a human-readable format.

func (*DataResponse) Slice

func (dr *DataResponse) Slice() [][2]string

Slice returns the dr as a slice of key-value string pairs. If dr is nil, this function returns an empty slice.

type Gatherer

type Gatherer func(ctx context.Context) (any, error)

Gatherer represents a mechanism to inject additional data (currently unused for version checking)

type GitHubRelease

type GitHubRelease struct {
	TagName      string `json:"tag_name,omitempty"`   // latest OPA release tag
	ReleaseNotes string `json:"html_url,omitempty"`   // link to the OPA release notes
	Download     string `json:"assets_url,omitempty"` // link to download the OPA release
}

type GitHubVersionChecker

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

func (*GitHubVersionChecker) LatestVersion

func (r *GitHubVersionChecker) LatestVersion(ctx context.Context) (*DataResponse, error)

LatestVersion queries the GitHub API to check for the latest OPA release version

func (*GitHubVersionChecker) RegisterGatherer

func (*GitHubVersionChecker) RegisterGatherer(_ string, _ Gatherer)

type Options

type Options struct {
	Logger logging.Logger
}

Options supplies parameters to the version checker.

type ReleaseDetails

type ReleaseDetails struct {
	Download      string `json:"download,omitempty"`       // link to download the OPA release
	ReleaseNotes  string `json:"release_notes,omitempty"`  // link to the OPA release notes
	LatestRelease string `json:"latest_release,omitempty"` // latest OPA released version
	OPAUpToDate   bool   `json:"opa_up_to_date,omitempty"` // is running OPA version greater than or equal to the latest released
}

ReleaseDetails holds information about the latest OPA release

Jump to

Keyboard shortcuts

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