upstream

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package upstream defines how to check version info in upstream repositories.

Upstream types are identified by their _flavour_, represented as a string (see Flavour).

Different Upstream types can have their own parameters, but they must:

  • Include the BaseUpstream type
  • Define a LatestVersion() function that returns the latest available version as a string

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAWSClient

func NewAWSClient() *ec2.EC2

NewAWSClient return a new aws service client for ec2

Authentication is provided by the standard AWS credentials use the standard `~/.aws/config` and `~/.aws/credentials` files, and support environment variables. See AWS documentation for more details: https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/sessions.html

Types

type AMI

type AMI struct {
	Base `mapstructure:",squash"`

	// Either owner alias (e.g. "amazon") or owner id
	Owner string

	// Name predicate, as used in --filter
	// Supports wilcards
	Name string

	// ServiceClient is the AWS client to talk to AWS API
	ServiceClient ec2iface.EC2API
}

AMI is the Amazon Machine Image upstream

See: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html

func (AMI) LatestVersion

func (upstream AMI) LatestVersion() (string, error)

LatestVersion returns the latest version of an AMI.

Returns the latest ami id (e.g. `ami-1234567`) from all AMIs matching the predicates, sorted by CreationDate.

If images cannot be listed, or if no image matches the predicates, it will return an error instead.

type Base

type Base struct {
	Flavour Flavour `yaml:"flavour"`
}

Base only contains a flavour. "Concrete" upstreams each implement their own fields.

func (*Base) LatestVersion

func (u *Base) LatestVersion() (string, error)

LatestVersion will always return an error. Base is only used to determine which actual upstream needs to be called, so it cannot return a sensible value

type Container

type Container struct {
	Base `mapstructure:",squash"`
	// Registry URL, e.g. gcr.io/k8s-staging-kubernetes/conformance
	Registry string
	// Optional: semver constraints, e.g. < 2.0.0
	// Will have no effect if the dependency does not follow Semver
	Constraints string
}

Container upstream representation

func (Container) LatestVersion

func (upstream Container) LatestVersion() (string, error)

LatestVersion returns the latest tag for the given repository (depending on the Constraints if set).

type Dummy

type Dummy struct {
	Base
}

Dummy upstream needs no parameters and always returns a latest version of 1.0.0. Can be used for testing.

func (Dummy) LatestVersion

func (upstream Dummy) LatestVersion() (string, error)

LatestVersion always returns 1.0.0

type EKS

type EKS struct {
	Base `mapstructure:",squash"`

	// Optional: semver constraints, e.g. < 1.16.0
	Constraints string
}

EKS is the Elastic Kubernetes Service upstream

See: https://docs.aws.amazon.com/eks/index.html

func (EKS) LatestVersion

func (upstream EKS) LatestVersion() (string, error)

LatestVersion returns the latest available EKS version.

Retrieves all available EKS versions from the parsing HTML from AWS's documentation page This feels brittle and wrong, but AFAIK there is no better way to do this

type Flavour

type Flavour string

Flavour is an enum of all supported upstreams and their string representation

const (
	// GithubFlavour is for Github releases
	GithubFlavour Flavour = "github"

	// GitLabFlavour is for GitLab releases
	GitLabFlavour Flavour = "gitlab"

	// AMIFlavour is for Amazon Machine Images
	AMIFlavour Flavour = "ami"

	// HelmFlavour is for Helm Charts
	HelmFlavour Flavour = "helm"

	// ContainerFlavour is for Container Images
	ContainerFlavour Flavour = "container"

	// EKSFlavour is for Elastic Kubernetes Service
	EKSFlavour Flavour = "eks"

	// DummyFlavour is for testing
	DummyFlavour Flavour = "dummy"

	DefaultSemVerConstraints = ">= 0.0.0"
)

type GitLab

type GitLab struct {
	Base `mapstructure:",squash"`

	// GitLab Server if is a self-hosted GitLab instead, default to gitlab.com
	Server string

	// GitLab URL, e.g. hashicorp/terraform or helm/helm
	URL string

	// Optional: semver constraints, e.g. < 2.0.0
	// Will have no effect if the dependency does not follow Semver
	Constraints string

	// If branch is specified, the version should be a commit SHA
	// Will look for new commits on the branch
	Branch string
}

GitLab upstream representation

func (GitLab) LatestVersion

func (upstream GitLab) LatestVersion() (string, error)

LatestVersion returns the latest non-draft, non-prerelease GitLab Release for the given repository (depending on the Constraints if set).

To authenticate your requests, use the GITLAB_TOKEN environment variable.

type Github

type Github struct {
	Base `mapstructure:",squash"`

	// Github URL, e.g. hashicorp/terraform or helm/helm
	URL string

	// Optional: semver constraints, e.g. < 2.0.0
	// Will have no effect if the dependency does not follow Semver
	Constraints string

	// If branch is specified, the version should be a commit SHA
	// Will look for new commits on the branch
	Branch string
}

Github upstream representation

func (Github) LatestVersion

func (upstream Github) LatestVersion() (string, error)

LatestVersion returns the latest non-draft, non-prerelease Github Release for the given repository (depending on the Constraints if set).

Authentication

The Github API allows unauthenticated requests, but the API limits are very strict: https://developer.github.com/v3/#rate-limiting

To authenticate your requests, use the GITHUB_ACCESS_TOKEN environment variable.

type Helm

type Helm struct {
	Base `mapstructure:",squash"`

	// Helm repository URL, e.g. https://grafana.github.io/helm-charts
	Repo string

	// Helm chart name in this repository
	Chart string

	// Optional: semver constraints, e.g. < 2.0.0
	// Will have no effect if the dependency does not follow Semver
	Constraints string
}

Helm upstream representation

func (Helm) LatestVersion

func (upstream Helm) LatestVersion() (string, error)

LatestVersion returns the latest non-draft, non-prerelease Helm Release for the given repository (depending on the Constraints if set).

Jump to

Keyboard shortcuts

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