stages

package
v0.0.0-...-e0ff526 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StageFilePath is the path to the json file.
	StageFilePath = "pipeline/stages.json"

	// GitTagPrefix is a prefix applied to all Docker image tags which
	// correspond to Git commit hashes.
	GitTagPrefix = "git-"

	// PodAnnotationKey is the key of the annotation which is attached to
	// PodTemplateSpec to map container names to stages.
	PodAnnotationKey = "skia.org/stage"
)

Variables

This section is empty.

Functions

func GetStagesFromAnnotations

func GetStagesFromAnnotations(annotations map[string]string) (map[string]string, error)

Types

type CommitResolver

type CommitResolver func(ctx context.Context, repoURL, reference string) (string, error)

CommitResolver is a function used to resolve a short Git commit hash or ref to a full commit hash.

func GitilesCommitResolver

func GitilesCommitResolver(httpClient *http.Client) CommitResolver

GitilesCommitResolver returns a CommitResolver which uses gitiles and the given http.Client to resolve commits.

type Image

type Image struct {
	// GitRepo is the URL of the Git repository from which the image is built.
	GitRepo string `json:"git_repo,omitempty"`
	// Stages are the release stages tracked by users of this image.
	Stages map[string]*Stage `json:"stages,omitempty"`
}

Image represents an image within a StageFile.

type Stage

type Stage struct {
	// GitHash is the Git commit hash at which this version of the image was
	// built.
	GitHash string `json:"git_hash"`
	// Digest is the sha256 digest of the image.
	Digest string `json:"digest"`
}

Stage represents a stage of a given Image.

type StageFile

type StageFile struct {
	// DefaultGitRepo is the URL of the git repository from which most images
	// are built. It is used to provide git commit information when an image
	// does not specify its own git repository.
	DefaultGitRepo string `json:"default_git_repo,omitempty"`
	// Images are the images which have release stages defined in this file.
	Images map[string]*Image `json:"images,omitempty"`
}

StageFile represents a file which defines release pipeline stages.

func Decode

func Decode(content []byte) (*StageFile, error)

Decode the given content as a StageFile.

func DecodeFile

func DecodeFile(filepath string) (*StageFile, error)

DecodeFile parses the given file as a StageFile.

func (*StageFile) Encode

func (f *StageFile) Encode() ([]byte, error)

Encode the StageFile.

func (*StageFile) EncodeFile

func (f *StageFile) EncodeFile(filepath string) error

EncodeFile writes the StageFile to a file.

func (*StageFile) GitRepoForImage

func (f *StageFile) GitRepoForImage(image string) (string, error)

GitRepoForImage returns the Git repo URL for the given image.

type StageManager

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

StageManager provides utilities for working with release stage files.

func NewStageManager

func NewStageManager(ctx context.Context, fs vfs.FS, dockerClient docker.Client, commitResolver CommitResolver) *StageManager

NewStageManager returns a StageManager instance. The http.Client is used for interacting with git repositories and should have the necessary authentication settings (eg. OAuth2.0 token source and scopes) attached.

func (*StageManager) AddImage

func (sm *StageManager) AddImage(ctx context.Context, image, gitRepo string) error

AddImage adds the given image to the stage file. The gitRepo is optional and overrides the default git repo.

func (*StageManager) Apply

func (sm *StageManager) Apply(ctx context.Context) error

Apply updates all config files to conform to the stage file.

func (*StageManager) PromoteStage

func (sm *StageManager) PromoteStage(ctx context.Context, image, stageToMatch, stageToUpdate string) error

PromoteStage sets a given stage to the same image version as another.

func (*StageManager) ReadStageFile

func (sm *StageManager) ReadStageFile(ctx context.Context) (*StageFile, error)

ReadStageFile reads and returns the stage file.

func (*StageManager) RemoveImage

func (sm *StageManager) RemoveImage(ctx context.Context, image string) error

RemoveImage removes the given image from the stage file.

func (*StageManager) RemoveStage

func (sm *StageManager) RemoveStage(ctx context.Context, image, stage string) error

RemoveStage removes the given stage from the stage file.

func (*StageManager) SetStage

func (sm *StageManager) SetStage(ctx context.Context, image, stage, reference string) error

SetStage sets the given stage of the given image to match the given reference, which may be a Docker image digest, tag, or Git commit hash.

Jump to

Keyboard shortcuts

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