release

package
v0.0.0-...-e4c3a4d Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MetadataFileName is the name of the file in the root of a staged
	// release.
	MetadataFileName = "metadata.json"

	// TarsBazelTarget is the Bazel target used to build release tar files in
	// the cert-manager repository.
	TarsBazelTarget = "//build/release-tars"

	// DefaultBucketName is the default GCS bucket used to store release
	// artifacts. This is re-used throughout the cmd/ package and used as the
	// default value for flags.
	DefaultBucketName = "cert-manager-release"

	// DefaultReleaseProject is the default project to run Cloud Build jobs in
	// to stage and publish releases.
	DefaultReleaseProject = "cert-manager-release"

	// DefaultBucketPathPrefix is the default prefix prepended to paths written
	// to Google Cloud Storage.
	DefaultBucketPathPrefix = "stage/gcb"

	// DefaultImageRepository is the default image repository used for artifact
	// images.
	DefaultImageRepository = "quay.io/jetstack"

	// DefaultGitHubOrg is the default organisation containing the cert-manager
	// repository.
	DefaultGitHubOrg = "cert-manager"

	// DefaultGitHubRepo is the default repository containing the cert-manager
	// code.
	DefaultGitHubRepo = "cert-manager"

	// DefaultHelmChartGitHubOwner is the name of the owner of the default
	// GitHub repository for Helm charts.
	DefaultHelmChartGitHubOwner = "jetstack"

	// DefaultHelmChartGitHubRepo is the name of the default GitHub repository
	// for Helm charts.
	DefaultHelmChartGitHubRepo = "jetstack-charts"

	// DefaultHelmChartGitHubBranch is the name of the main branch in the GitHub
	// repository for Helm charts.
	DefaultHelmChartGitHubBranch = "main"

	// BuildTypeRelease denotes that a build is targeting an actual named
	// release and is not just a development build that has been created using
	// the release tool.
	BuildTypeRelease = "release"

	// BuildTypeDevel denotes that a build did not explicitly set a
	// --release-version and so it is not suitable for being used as part of a
	// published release.
	BuildTypeDevel = "devel"

	// BuildSourceMake indicates that the files were built by make, rather than Bazel
	BuildSourceMake = "make"
)

Variables

View Source
var (
	// ServerPlatforms is the list of OSes and architectures to build docker images
	// for during the release.
	// This is used to drive the `--platforms` flag passed to 'bazel build' as
	// well as to determine which image artifacts should be uploaded.
	ServerPlatforms = map[string][]string{
		"linux": []string{"amd64", "arm", "arm64", "ppc64le", "s390x"},
	}

	// ClientPlatforms is the list of OSes and architectures to build client CLI tools
	// for during the release.
	// This is used to determine which artifacts should be uploaded.
	ClientPlatforms = map[string][]string{
		"linux":   []string{"amd64", "arm", "arm64", "ppc64le", "s390x"},
		"darwin":  []string{"amd64", "arm64"},
		"windows": []string{"amd64"},
	}

	// ArchitecturesPerOS is the list of OSes and architectures that we can build
	// This is used to drive the `--platforms` flag passed to 'bazel build'
	ArchitecturesPerOS = map[string][]string{
		"linux":   []string{"amd64", "arm", "arm64", "ppc64le", "s390x"},
		"darwin":  []string{"amd64", "arm64"},
		"windows": []string{"amd64"},
	}
)

Functions

func AllArchesForOSes

func AllArchesForOSes(osList sets.String) sets.String

AllArchesForOSes returns all architectures targetted by any of the given OSes. Panics if any of the OSes are unknown

func AllOSes

func AllOSes() sets.String

AllOSes returns a slice of all known operating systems which cert-manager targets including both server and client targets.

func ArchListFromString

func ArchListFromString(targetArches string, osList sets.String) (sets.String, error)

ArchListFromString parses and validates a comma-separated list of arches, returning a slice of valid arches if all are OK. Returns an error on an unknown architecture or an architecture which isn't a valid target for the given OSes for this invocation (e.g. will error if osList == []string{"windows"} and targetArches == "s390x") Panics if given an unknown OS

func BucketPathForRelease

func BucketPathForRelease(bucketPrefix, buildType, releaseVersion, gitRef string) string

BucketPathForRelease will assemble an output directory path for the given release parameters.

func CmctlIsShipped

func CmctlIsShipped(releaseVersion string) bool

Cmctl is only shipped with v1.14.X and below.

func IsClientOS

func IsClientOS(os string) bool

IsClientOS returns true if cert-manager builds client binaries for the given platform

func IsServerOS

func IsServerOS(os string) bool

IsServerOS returns true if cert-manager can be deployed to the given OS on the server side

func LookupBranchRef

func LookupBranchRef(org, repo, branch string) (string, error)

LookupBranchRef will lookup the git commit ref of the HEAD of the branch in the given repository. It does this by querying the GitHub v3 API at: https://api.github.com/repos/{org}/{repo}/git/ref/heads/{branch}

func LookupRefSHA

func LookupRefSHA(org, repo, ref string) (string, error)

LookupRefSHA will lookup the git commit SHA of the given ref in the given repository. It does this by querying the GitHub v3 API at: https://api.github.com/repos/{org}/{repo}/commits/{ref} Works with branches (will fetch the SHA of HEAD) or tags

func NameForObjectPath

func NameForObjectPath(path, prefix string) string

NameForObjectPath will return the name of the release that a given object path is a member of by inspecting the path and trimming the prefix.

func OSListFromString

func OSListFromString(targetOSes string) (sets.String, error)

OSListFromString parses and validates a comma-separated list of OSes, returning an error if any are invalid or a slice of valid OSes if all are OK.

Types

type ArtifactMetadata

type ArtifactMetadata struct {
	// Name of the artifact within the release directory.
	Name string `json:"name"`

	// SHA256 is a hash of the artifact, computed during the staging process.
	SHA256 string `json:"sha256"`

	// OS, if specified, is the OS parameter that this artifact was built for.
	// This could be 'linux', 'darwin', 'windows' etc.
	OS string `json:"os,omitempty"`

	// Architecture, if specified, is the architecture that this artifact was
	// built for.
	// This could be 'amd64', 'arm', 'arm64' etc.
	Architecture string `json:"architecture,omitempty"`
}

type Bucket

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

func NewBucket

func NewBucket(bucket *storage.BucketHandle, prefix, releaseType string) *Bucket

func (*Bucket) GetRelease

func (b *Bucket) GetRelease(ctx context.Context, name string) (*Staged, error)

GetRelease will fetch a single release from the bucket with the given name. A release's name is the name of the directory the metadata.json file for is the release is contained within.

func (*Bucket) ListReleases

func (b *Bucket) ListReleases(ctx context.Context, version, gitRef string) ([]Staged, error)

ListReleases will list releases in a bucket. If 'version' is provided, the list will be filtered to only releases with the specified version. If 'version' AND 'gitRef' are provided, the list will be filtered to only releases with the specified version built at the specified commit ref. Specifying 'gitRef' without 'version' is not supported.

type Metadata

type Metadata struct {
	// ReleaseVersion, if set, is an explicit version used to build the release
	// artifacts.
	// By default, the release version will be computed by the Bazel release
	// process and the build type will be 'devel' instead of 'release'.
	ReleaseVersion string `json:"releaseVersion"`

	// Required git commit reference to build.
	GitCommitRef string `json:"gitCommitRef"`

	// GCS URIs of the artifacts that are a part of this build.
	Artifacts []ArtifactMetadata `json:"artifacts"`

	// BuildSource denotes what built the staged files, making it easier to identify
	// how they were produced. This is used as part of the migration from Bazel to
	// Make. An empty BuildSource is assumed to mean Bazel produced the files.
	BuildSource string `json:"buildSource,omitempty"`
}

Metadata about a staged release.

type Staged

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

Staged is a release build staged in a GCS bucket. It provides convenience methods to interact with release build and inspect metadata.

func NewStagedRelease

func NewStagedRelease(ctx context.Context, name, prefix string, objects ...*storage.ObjectHandle) (*Staged, error)

func (Staged) ArtifactsOfKind

func (s Staged) ArtifactsOfKind(kind string) []StagedArtifact

ArtifactsOfKind returns a list of staged artifacts of the type denoted by `kind`. A kind may be 'server', 'manifests', 'test' etc.

func (Staged) Metadata

func (s Staged) Metadata() Metadata

Metadata will return metadata information about the release.

func (Staged) Name

func (s Staged) Name() string

Name will return the name of the release in the GCS bucket

type StagedArtifact

type StagedArtifact struct {
	Metadata     ArtifactMetadata
	ObjectHandle *storage.ObjectHandle
}

StagedArtifact represents a single artifact within a release, with some associated metadata read from the release metadata.json file.

type Unpacked

type Unpacked struct {
	ReleaseName           string
	ReleaseVersion        string
	GitCommitRef          string
	Charts                []manifests.Chart
	YAMLs                 []manifests.YAML
	CtlBinaryBundles      []binaries.Archive // Only in v1.14.X and below.
	ComponentImageBundles map[string][]*images.Tar
}

Unpacked wraps a staged release that has been fetched and unpacked locally. It provides methods to interact with the release in order to prepare it for publishing.

func Unpack

func Unpack(ctx context.Context, s *Staged) (*Unpacked, error)

Unpack takes a staged release, inspects its metadata, fetches referenced artifacts and extracts them to disk.

Directories

Path Synopsis
publish

Jump to

Keyboard shortcuts

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