release

package
v0.17.11 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 41 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultToolRepo = "release"
	DefaultToolRef  = git.DefaultBranch
	DefaultToolOrg  = git.DefaultGithubOrg

	DefaultK8sOrg  = git.DefaultGithubOrg
	DefaultK8sRepo = git.DefaultGithubRepo
	DefaultK8sRef  = git.DefaultRef

	// TODO(vdf): Need to reference K8s Infra project here.
	DefaultKubernetesStagingProject = "kubernetes-release-test"
	DefaultRelengStagingTestProject = "k8s-staging-releng-test"
	DefaultRelengStagingProject     = "k8s-staging-releng"
	DefaultDiskSize                 = "500"

	KubernetesTar = "kubernetes.tar.gz"

	// Staged source code tarball of Kubernetes.
	SourcesTar = "src.tar.gz"

	// Root path on the bucket for staged artifacts.
	StagePath = "stage"

	// Path where the release container images are stored.
	ImagesPath = "release-images"

	// GCSStagePath is the directory where release artifacts are staged before
	// push to GCS.
	GCSStagePath = "gcs-stage"

	// ReleaseStagePath is the directory where releases are staged.
	ReleaseStagePath = "release-stage"

	// GCEPath is the directory where GCE scripts are created.
	GCEPath = ReleaseStagePath + "/full/kubernetes/cluster/gce"

	// GCIPath is the path for the container optimized OS for gcli.
	GCIPath = ReleaseStagePath + "/full/kubernetes/cluster/gce/gci"

	// ReleaseTarsPath is the directory where release artifacts are created.
	ReleaseTarsPath = "release-tars"

	// WindowsLocalPath is the directory where Windows GCE scripts are created.
	WindowsLocalPath = ReleaseStagePath + "/full/kubernetes/cluster/gce/windows"

	// CIBucketLegacy is the default bucket for Kubernetes CI releases.
	CIBucketLegacy = "kubernetes-release-dev"

	// CIBucketK8sInfra is the community infra bucket for Kubernetes CI releases.
	CIBucketK8sInfra = "k8s-release-dev"

	// TestBucket is the default bucket for mocked Kubernetes releases.
	TestBucket = "kubernetes-release-gcb"

	// ProductionBucket is the default bucket for Kubernetes releases.
	// Owned by SIG k8s Infra: https://git.k8s.io/community/sig-k8s-infra
	ProductionBucket = "767373bbdcb8270361b96548387bf2a9ad0d48758c35"

	// ProductionBucketURL is the url for the ProductionBucket.
	ProductionBucketURL = "https://dl.k8s.io"

	// Production registry root URL.
	GCRIOPathProd = image.ProdRegistry

	// Staging registry root URL prefix.
	GCRIOPathStagingPrefix = image.StagingRepoPrefix

	// Staging registry root URL.
	GCRIOPathStaging = GCRIOPathStagingPrefix + image.StagingRepoSuffix

	// Mock staging registry root URL.
	GCRIOPathMock = GCRIOPathStaging + "/mock"

	// BuildDir is the default build output directory.
	BuildDir = "_output"

	// Publishing bot issue repository.
	PubBotRepoOrg  = "kubernetes"
	PubBotRepoName = "sig-release"

	DockerHubEnvKey   = "DOCKERHUB_TOKEN" // Env var containing the docker key
	DockerHubUserName = "k8sreleng"       // Docker Hub username

	ProvenanceFilename = "provenance.json" // Name of the SLSA provenance file (used in stage and release)
)
View Source
const (
	ReleaseTypeOfficial string = "official"
	ReleaseTypeRC       string = "rc"
	ReleaseTypeBeta     string = "beta"
	ReleaseTypeAlpha    string = "alpha"
)

Variables

View Source
var DefaultPrerequisitesCheckerOptions = &PrerequisitesCheckerOptions{
	CheckGitHubToken: true,
}
View Source
var ManifestImages = []string{
	"conformance",
	"kube-apiserver",
	"kube-controller-manager",
	"kube-proxy",
	"kube-scheduler",
	"kubectl",
}

Functions

func CopyBinaries added in v0.4.1

func CopyBinaries(rootPath, targetPath string) error

CopyBinaries takes the provided `rootPath` and copies the binaries sorted by their platform into the `targetPath`.

func CreatePubBotBranchIssue added in v0.8.0

func CreatePubBotBranchIssue(branchName string) error

CreatePubBotBranchIssue creates an issue on GitHub to notify.

func DockerHubLogin added in v0.8.0

func DockerHubLogin() error

Calls docker login to log into docker hub using a token from the environment.

func FixPublicReleaseNotesURL added in v0.17.11

func FixPublicReleaseNotesURL(gcsPath string) string

TODO: remove this function once https://cdn.dl.k8s.io/release/release-notes-index.json is fixed.

func GetForceBuildKrel added in v0.17.8

func GetForceBuildKrel() string

GetForceBuildKrel checks if the 'FORCE_BUILD_KREL' environment variable is set. If 'FORCE_BUILD_KREL' is non-empty, it returns the value. Otherwise, it returns "false".

func GetK8sOrg added in v0.12.0

func GetK8sOrg() string

GetK8sOrg checks if the 'K8S_ORG' environment variable is set. If 'K8S_ORG' is non-empty, it returns the value. Otherwise, it returns DefaultK8sOrg.

func GetK8sRef added in v0.12.0

func GetK8sRef() string

GetK8sRef checks if the 'K8S_REF' environment variable is set. If 'K8S_REF' is non-empty, it returns the value. Otherwise, it returns DefaultK8sRef.

func GetK8sRepo added in v0.12.0

func GetK8sRepo() string

GetK8sRepo checks if the 'K8S_REPO' environment variable is set. If 'K8S_REPO' is non-empty, it returns the value. Otherwise, it returns DefaultK8sRepo.

func GetToolOrg added in v0.2.5

func GetToolOrg() string

GetToolOrg checks if the 'TOOL_ORG' environment variable is set. If 'TOOL_ORG' is non-empty, it returns the value. Otherwise, it returns DefaultToolOrg.

func GetToolRef added in v0.8.0

func GetToolRef() string

GetToolRef checks if the 'TOOL_REF' environment variable is set. If 'TOOL_REF' is non-empty, it returns the value. Otherwise, it returns DefaultToolRef.

func GetToolRepo added in v0.2.5

func GetToolRepo() string

GetToolRepo checks if the 'TOOL_REPO' environment variable is set. If 'TOOL_REPO' is non-empty, it returns the value. Otherwise, it returns DefaultToolRepo.

func GetWorkspaceVersion added in v0.6.0

func GetWorkspaceVersion() (string, error)

func IsDefaultK8sUpstream added in v0.12.0

func IsDefaultK8sUpstream() bool

IsDefaultK8sUpstream returns true if GetK8sOrg(), GetK8sRepo() and GetK8sRef() point to their default values.

func IsDirtyBuild

func IsDirtyBuild(build string) bool

IsDirtyBuild checks if build version is dirty.

func IsUpToDate added in v0.17.0

func IsUpToDate(oldVersion, newVersion semver.Version) bool

func IsValidReleaseBuild

func IsValidReleaseBuild(build string) (bool, error)

IsValidReleaseBuild checks if build version is valid for release.

func ListBuildBinaries added in v0.10.0

func ListBuildBinaries(gitroot, version string) (list []struct{ Path, Platform, Arch string }, err error)

ListBuildBinaries returns a list of binaries.

func ListBuildImages added in v0.10.0

func ListBuildImages(gitroot, version string) (imageList []string, err error)

ListBuildImages returns a slice with paths to all images produced by the build.

func ListBuildTarballs added in v0.10.0

func ListBuildTarballs(gitroot, version string) (tarList []string, err error)

ListBuildTarballs returns a list of the client, node server and other tarballs.

func PrepareWorkspaceRelease added in v0.6.0

func PrepareWorkspaceRelease(directory, buildVersion, bucket string) error

PrepareWorkspaceRelease sets up the workspace by downloading and extracting the staged sources on the provided bucket.

func PrepareWorkspaceStage added in v0.6.0

func PrepareWorkspaceStage(directory string, noMock bool) error

PrepareWorkspaceStage sets up the workspace by cloning a new copy of k/k.

func ReadDockerizedVersion

func ReadDockerizedVersion(workDir string) (string, error)

ReadDockerizedVersion reads the version from a Dockerized Kubernetes build.

func URLPrefixForBucket added in v0.2.6

func URLPrefixForBucket(bucket string) string

URLPrefixForBucket returns the URL prefix for the provided bucket string.

func WriteChecksums added in v0.4.1

func WriteChecksums(rootPath string) error

WriteChecksums writes the SHA256SUMS/SHA512SUMS files (contains all checksums) as well as a sepearete *.sha[256|512] file containing only the SHA for the corresponding file name.

Types

type ArtifactChecker added in v0.10.0

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

func NewArtifactChecker added in v0.10.0

func NewArtifactChecker() *ArtifactChecker

func NewArtifactCheckerWithOptions added in v0.10.0

func NewArtifactCheckerWithOptions(opts *ArtifactCheckerOptions) *ArtifactChecker

func (*ArtifactChecker) CheckBinaryArchitectures added in v0.10.0

func (ac *ArtifactChecker) CheckBinaryArchitectures() error

CheckBinaryArchitectures ensures all the artifacts produced in each release are of the right architecture.

func (*ArtifactChecker) CheckBinaryTags added in v0.10.0

func (ac *ArtifactChecker) CheckBinaryTags() error

CheckBinaryTags checks that the binaries produced in the release are correctly tagged with the semver string.

func (*ArtifactChecker) Options added in v0.10.0

func (ac *ArtifactChecker) Options() *ArtifactCheckerOptions

type ArtifactCheckerOptions added in v0.10.0

type ArtifactCheckerOptions struct {
	GitRoot  string   // Directory where the repo was cloned
	Versions []string // Version tags we are checking
}

type BranchChecker added in v0.6.0

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

func NewBranchChecker added in v0.6.0

func NewBranchChecker() *BranchChecker

NewBranchChecker creates a new release branch checker instance.

func (*BranchChecker) NeedsCreation added in v0.6.0

func (r *BranchChecker) NeedsCreation(
	branch, releaseType string, buildVersion semver.Version,
) (createReleaseBranch bool, err error)

NeedsCreation returns if the provided release branch has to be created and checks if it's correct.

func (*BranchChecker) SetImpl added in v0.6.0

func (r *BranchChecker) SetImpl(impl branchCheckerImpl)

SetImpl can be used to set the internal BranchChecker implementation.

type GitObjectPusher added in v0.5.0

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

GitObjectPusher is an object that pushes things to a gitrepo.

func NewGitPusher added in v0.5.0

func NewGitPusher(opts *GitObjectPusherOptions) (*GitObjectPusher, error)

NewGitPusher returns a new git object pusher.

func (*GitObjectPusher) PushBranch added in v0.5.0

func (gp *GitObjectPusher) PushBranch(branchName string) error

PushBranch pushes a branch to the repository

this function is idempotent.

func (*GitObjectPusher) PushBranches added in v0.6.0

func (gp *GitObjectPusher) PushBranches(branchList []string) error

PushBranches Convenience method to push a list of branches.

func (*GitObjectPusher) PushMain added in v0.6.0

func (gp *GitObjectPusher) PushMain() error

PushMain pushes the main branch to the origin.

func (*GitObjectPusher) PushTag added in v0.5.0

func (gp *GitObjectPusher) PushTag(newTag string) (err error)

PushTag pushes a tag to the master repo.

func (*GitObjectPusher) PushTags added in v0.6.0

func (gp *GitObjectPusher) PushTags(tagList []string) (err error)

PushTags convenience method to push a list of tags to the remote repo.

type GitObjectPusherOptions added in v0.5.0

type GitObjectPusherOptions struct {
	// Flago simulate pushes, passes --dry-run to git
	DryRun bool

	// Number of times to retry pushes
	MaxRetries int

	// Path to the repository
	RepoPath string
}

GitObjectPusherOptions struct to hold the pusher options.

type Images added in v0.4.1

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

Images is a wrapper around container image related functionality.

func NewImages added in v0.4.1

func NewImages() *Images

NewImages creates a new Images instance.

func (*Images) Exists added in v0.6.0

func (i *Images) Exists(registry, version string, fast bool) (bool, error)

Exists verifies that a set of image manifests exists on a specified remote registry. This is a simpler check than Validate, which doesn't presuppose the existence of a local build directory. Used in CI builds to quickly validate if a build is actually required.

func (*Images) GetManifestImages added in v0.13.0

func (i *Images) GetManifestImages(
	registry, version, buildPath string,
	forTarballFn func(path, origTag, newTagWithArch string) error,
) (map[string][]string, error)

GetManifestImages can be used to retrieve the map of built images and architectures.

func (*Images) Publish added in v0.4.1

func (i *Images) Publish(registry, version, buildPath string) error

PublishImages releases container images to the provided target registry.

func (*Images) SetImpl added in v0.13.0

func (i *Images) SetImpl(impl imageImpl)

SetImpl can be used to set the internal image implementation.

func (*Images) Validate added in v0.4.2

func (i *Images) Validate(registry, version, buildPath string) error

Validates that image manifests have been pushed to a specified remote registry.

type PrerequisitesChecker added in v0.6.0

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

PrerequisitesChecker is the main type for checking the prerequisites for a release.

func NewPrerequisitesChecker added in v0.6.0

func NewPrerequisitesChecker() *PrerequisitesChecker

NewPrerequisitesChecker creates a new PrerequisitesChecker instance.

func (*PrerequisitesChecker) Options added in v0.10.0

Options return the options from the prereq checker.

func (*PrerequisitesChecker) Run added in v0.6.0

func (p *PrerequisitesChecker) Run(workdir string) error

func (*PrerequisitesChecker) SetImpl added in v0.6.0

func (p *PrerequisitesChecker) SetImpl(impl prerequisitesCheckerImpl)

SetImpl can be used to set the internal PrerequisitesChecker implementation.

type PrerequisitesCheckerOptions added in v0.10.0

type PrerequisitesCheckerOptions struct {
	CheckGitHubToken bool
}

Type prerequisites checker.

type ProvenanceChecker added in v0.12.0

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

ProvenanceChecker is the main structure to check the provenance.

func NewProvenanceChecker added in v0.12.0

func NewProvenanceChecker(opts *ProvenanceCheckerOptions) *ProvenanceChecker

func (*ProvenanceChecker) CheckStageProvenance added in v0.12.0

func (pc *ProvenanceChecker) CheckStageProvenance(buildVersion string) error

CheckStageProvenance validates the provenance for the provided build version.

func (*ProvenanceChecker) GenerateFinalAttestation added in v0.12.0

func (pc *ProvenanceChecker) GenerateFinalAttestation(buildVersion string, versions *Versions) error

GenerateFinalAttestation combines the stage provenance attestation with a release sbom to create the end-user provenance atteatation.

type ProvenanceCheckerOptions added in v0.12.0

type ProvenanceCheckerOptions struct {
	StageBucket      string // Bucket where the artifacts are stored
	StageDirectory   string // Directory where artifacts will be downloaded
	ScratchDirectory string // Directory where StageDirectory will be created
}

type ProvenanceReader added in v0.12.0

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

func NewProvenanceReader added in v0.12.0

func NewProvenanceReader(opts *ProvenanceReaderOptions) *ProvenanceReader

func (*ProvenanceReader) GetBuildSubjects added in v0.12.0

func (pr *ProvenanceReader) GetBuildSubjects(path, version string) ([]intoto.Subject, error)

GetBuildSubjects returns all artifacts in the output directory as intoto subjects, ready to add to the attestation.

func (*ProvenanceReader) GetStagingSubjects added in v0.12.0

func (pr *ProvenanceReader) GetStagingSubjects(path string) ([]intoto.Subject, error)

GetStagingSubjects reads artifacts from the GCB workspace and returns them as in-toto subjects, with their paths normalized to their final locations in the staging bucket.

type ProvenanceReaderOptions added in v0.12.0

type ProvenanceReaderOptions struct {
	Bucket       string
	BuildVersion string
	WorkspaceDir string
}

type Publisher added in v0.4.1

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

Publisher is the structure for publishing anything release related.

func NewPublisher added in v0.4.1

func NewPublisher() *Publisher

NewPublisher creates a new Publisher instance.

func (*Publisher) PublishReleaseNotesIndex added in v0.7.0

func (p *Publisher) PublishReleaseNotesIndex(
	gcsIndexRootPath, gcsReleaseNotesPath, version string,
) error

PublishReleaseNotesIndex updates or creates the release notes index JSON at the target `gcsIndexRootPath`.

func (*Publisher) PublishToGcs added in v0.4.1

func (p *Publisher) PublishToGcs(
	publishFile, buildDir, markerPath, version string,
	privateBucket bool,
) error

PublishToGcs publishes a release to GCS publishFile - the GCS location to look in buildDir - build output directory markerPath - the GCS path to publish a version marker to version - release version.

func (*Publisher) PublishVersion added in v0.4.1

func (p *Publisher) PublishVersion(
	buildType, version, buildDir, bucket, gcsRoot string,
	extraVersionMarkers []string,
	privateBucket, fast bool,
) error

Publish a new version, (latest or stable) but only if the files actually exist on GCS and the artifacts we're dealing with are newer than the contents in GCS. buildType - One of 'release' or 'ci' version - The version buildDir - build output directory bucket - GCS bucket gcsRoot - The top-level GCS directory builds will be released to

Expected destination format:

gs://<bucket>/<gcsRoot>[/fast]/<version>

func (*Publisher) SetClient added in v0.4.1

func (p *Publisher) SetClient(client publisherClient)

SetClient can be used to set the internal publisher client.

func (*Publisher) VerifyLatestUpdate added in v0.4.1

func (p *Publisher) VerifyLatestUpdate(
	publishFile, markerPath, version string,
) (needsUpdate bool, err error)

VerifyLatestUpdate checks if the new version is greater than the version currently published on GCS. It returns `true` for `needsUpdate` if the remote version does not exist or needs to be updated. publishFile - the version marker to look for markerPath - the GCS path to search for the version marker in version - release version.

type Repo added in v0.3.0

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

Repo is a wrapper around a kubernetes/release repository.

func NewRepo added in v0.3.0

func NewRepo() *Repo

NewRepo creates a new release repository.

func (*Repo) CheckState added in v0.3.0

func (r *Repo) CheckState(expOrg, expRepo, expRev string, nomock bool) error

CheckState verifies that the repository is in the requested state.

func (*Repo) GetTag added in v0.3.0

func (r *Repo) GetTag() (string, error)

GetTag returns the tag from the current repository.

func (*Repo) Open added in v0.3.0

func (r *Repo) Open() error

Open assumes the current working directory as repository root and tries to open it.

func (*Repo) SetRepo added in v0.3.0

func (r *Repo) SetRepo(repo Repository)

SetRepo can be used to set the internal repository implementation.

type Repository added in v0.3.0

type Repository interface {
	Describe(opts *git.DescribeOptions) (string, error)
	CurrentBranch() (branch string, err error)
	RevParse(rev string) (string, error)
	Head() (string, error)
	Remotes() (res []*git.Remote, err error)
	LsRemote(...string) (string, error)
	IsDirty() (bool, error)
}

Repository is an interface for interacting with a git repository

type Version added in v0.3.0

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

Version is a wrapper around version related functionality.

func NewVersion added in v0.3.0

func NewVersion() *Version

NewVersion creates a new Version.

func (*Version) GetKubeVersion added in v0.3.0

func (v *Version) GetKubeVersion(versionType VersionType) (string, error)

GetKubeVersion retrieves the version of the provided Kubernetes version type.

func (*Version) GetKubeVersionForBranch added in v0.3.0

func (v *Version) GetKubeVersionForBranch(versionType VersionType, branch string) (string, error)

GetKubeVersionForBranch returns the remote Kubernetes release version for the provided branch.

func (*Version) SetClient added in v0.3.0

func (v *Version) SetClient(client VersionClient)

SetClient can be used to manually set the internal Version client.

type VersionClient added in v0.3.0

type VersionClient interface {
	GetURLResponse(string) (string, error)
}

VersionClient is a client for getting Kubernetes versions

type VersionType added in v0.2.6

type VersionType string

VersionType is a simple wrapper around a Kubernetes release version.

const (
	// VersionTypeStable references the latest stable Kubernetes
	// version, for example `v1.17.3`.
	VersionTypeStable VersionType = "release/stable"

	// VersionTypeStablePreRelease references the latest stable pre
	// release Kubernetes version, for example `v1.19.0-alpha.0`.
	VersionTypeStablePreRelease VersionType = "release/latest"

	// VersionTypeCILatest references the latest CI Kubernetes version,
	// for example `v1.19.0-alpha.0.721+f8ff8f44206ff4`.
	VersionTypeCILatest VersionType = "ci/latest"

	// VersionTypeCILatestCross references the latest CI cross build Kubernetes
	// version, for example `v1.19.0-alpha.0.721+f8ff8f44206ff4`.
	VersionTypeCILatestCross VersionType = "ci/k8s-" + git.DefaultBranch
)

func (VersionType) URL added in v0.3.0

func (t VersionType) URL(version string) string

URL retrieves the full URL of the Kubernetes release version.

type Versions added in v0.4.0

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

Versions specifies the collection of found release versions.

func GenerateReleaseVersion added in v0.4.1

func GenerateReleaseVersion(
	releaseType, version, branch string, branchFromMaster bool,
) (*Versions, error)

GenerateReleaseVersion returns the next build versions for the provided parameters.

func NewReleaseVersions added in v0.6.0

func NewReleaseVersions(prime, official, rc, beta, alpha string) *Versions

NewReleaseVersions can be used to create a new `*Versions` instance.

func (*Versions) Alpha added in v0.4.0

func (r *Versions) Alpha() string

Alpha can be used to get the ReleaseTypeAlpha from the versions.

func (*Versions) Beta added in v0.4.0

func (r *Versions) Beta() string

Beta can be used to get the ReleaseTypeBeta from the versions.

func (*Versions) Official added in v0.4.0

func (r *Versions) Official() string

Official can be used to get the ReleaseTypeOfficial from the versions.

func (*Versions) Ordered added in v0.6.0

func (r *Versions) Ordered() (versions []string)

Ordered returns a list of ordered release versions.

func (*Versions) Prime added in v0.4.0

func (r *Versions) Prime() string

Prime can be used to get the most prominent release version.

func (*Versions) RC added in v0.4.0

func (r *Versions) RC() string

Rc can be used to get the ReleaseTypeRC from the versions.

func (*Versions) String added in v0.4.0

func (r *Versions) String() string

String returns a string representation for the release versions.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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