internal

package
v0.0.0-...-f4b31ea Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Overview

Package internal contains the internals of the uprev service.

Index

Constants

View Source
const (
	Oauth2Username = "oauth2accesstoken"
	Oauth2Password = "$(gcloud auth print-access-token)"
	// "host/project/containerName:tag"
	ContainerFormat = "%s/%s/%s:%s"
)

Variables

View Source
var (
	//go:embed dockerfiles/*
	Dockerfiles embed.FS
	//go:embed resources/*
	Resources embed.FS

	DefaultRepository = &Repository{
		Hostname:      common.DefaultDockerHost,
		Project:       common.DefaultDockerProject,
		FirestoreHost: common.TestPlatformFireStore,
	}
	PartnerRepository = &Repository{
		Hostname:      common.DefaultDockerHost,
		Project:       common.PartnerDockerProject,
		FirestoreHost: common.PartnerTestPlatformFireStore,
	}
)

Functions

func GcloudAuth

func GcloudAuth(ctx context.Context, registry, dockerKeyFile string) (err error)

GcloudAuth signs into gcloud and attempts to activate the service account given by the dockerKeyFile.

func RevertShas

func RevertShas(ctx context.Context, containerNames []string, firestoreDatabaseName, creds, tag string) (err error)

RevertShas swaps the previous sha with the current sha and updates the firestore.

func UpdateShaStorage

func UpdateShaStorage(ctx context.Context, firestoreDatabaseName string, containerInfo ContainerInfosMap, creds, tag string) (err error)

UpdateShaStorage connects the the firestore and uploads the SHAs produced during the uprev service.

func UprevContainer

func UprevContainer(ctx context.Context, imageCache map[string]any, config *UprevConfig, cipdLabel, imageTag string) (containerInfoItem *common.ContainerInfoItem, err error)

UprevContainer performs the logic for upreving a container. This involves creating a temporary directory for the container to modify by writing its Dockerfile and ensuring its CIPD packages.

func WriteDockerfile

func WriteDockerfile(dir string, name string) error

WriteDockerfile writes the embedded dockerfile to the temporary directory.

func WriteResource

func WriteResource(dir string, name string) error

WriteResource writes the embedded resource to the temporary directory.

Types

type CIPDPackage

type CIPDPackage struct {
	// Name of CIPD package.
	Name string
	// Reference label of CIPD package.
	// Mainly for local development.
	Ref string
}

CIPDPackage contains relevant information about a CIPDPackage.

func NewCIPDPackage

func NewCIPDPackage(name string) *CIPDPackage

NewCIPDPackage creates a CIPDPackage without a reference label.

func NewCIPDPackageWithRef

func NewCIPDPackageWithRef(name, ref string) *CIPDPackage

NewCIPDPackageWithRef creates a CIPDPackage with a reference label.

type ContainerInfosMap

type ContainerInfosMap = map[string]*common.ContainerInfoItem

type Repository

type Repository struct {
	Hostname      string
	Project       string
	FirestoreHost string
}

type UprevConfig

type UprevConfig struct {
	// Dockerfile found by: Dockerfile_<Name>
	Name string
	// Repository information.
	// If empty, defaults to
	// 	host: us-docker.pkg.dev
	// 	project: cros-registry/test-services
	//  firestoreHost: test-platform-store
	Repositories []*Repository
	// Defaults to Name, but can be separately set if
	// container name is different than the uprev name.
	ContainerName string
	// Binaries used during docker image setup.
	CIPDPackages []*CIPDPackage
	// Prepper is a function signature representing
	// any custom work needed by the Dockerfile.
	Prepper   func(ctx context.Context, dir string) error
	Resources []string
}

UprevConfig describes a container's uprev information.

func CleanConfigs

func CleanConfigs(configs []*UprevConfig) []*UprevConfig

func GetConfigs

func GetConfigs() []*UprevConfig

GetConfigs returns the uprev configs.

Directories

Path Synopsis
Package preppers contains preppers for configured containers.
Package preppers contains preppers for configured containers.

Jump to

Keyboard shortcuts

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