Documentation
¶
Index ¶
- Constants
- func GetDeleteCmd(rc RegistryContext, useServiceAccount bool, img ImageName, digest Digest) []string
- func GetRegistryListTagsCmd(rc RegistryContext, useServiceAccount bool, img string) []string
- func GetRegistryListingCmd(rc RegistryContext, useServiceAccount bool) []string
- func GetWriteCmd(dest RegistryContext, useServiceAccount bool, srcRegistry RegistryName, ...) []string
- func MaybeUseServiceAccount(serviceAccount string, useServiceAccount bool, cmd []string) []string
- func ToFQIN(registryName RegistryName, imageName ImageName, digest Digest) string
- func ToPQIN(registryName RegistryName, imageName ImageName, tag Tag) string
- type CapturedRequests
- type Digest
- type DigestTags
- type DigestTagsContext
- type Error
- type Errors
- type Image
- type ImageDigest
- type ImageDigestTag
- type ImageName
- type ImageTag
- type Manifest
- type MasterInventory
- type PopulateRequests
- type ProcessRequest
- type PromotionRequest
- type RegInvFlat
- type RegInvImage
- type RegInvImageDigest
- func (a RegInvImageDigest) Intersection(b RegInvImageDigest) RegInvImageDigest
- func (a RegInvImageDigest) Minus(b RegInvImageDigest) RegInvImageDigest
- func (riid *RegInvImageDigest) PrettyValue() string
- func (riid RegInvImageDigest) ToRegInvImageTag() RegInvImageTag
- func (a RegInvImageDigest) ToSet() container.Set
- type RegInvImageTag
- type Registry
- type RegistryContext
- type RegistryName
- type RequestResult
- type SyncContext
- func (sc *SyncContext) Error(v ...interface{})
- func (sc *SyncContext) Errorf(s string, v ...interface{})
- func (sc *SyncContext) ExecRequests(populateRequests PopulateRequests, processRequest ProcessRequest)
- func (sc *SyncContext) Fatal(v ...interface{})
- func (sc *SyncContext) Fatalf(s string, v ...interface{})
- func (sc *SyncContext) GarbageCollect(mfest Manifest, ...)
- func (sc *SyncContext) GetLostImages(mfest Manifest) RegInvImageDigest
- func (sc *SyncContext) GetPromotionCandidatesIT(mfest Manifest) RegInvImageTag
- func (sc *SyncContext) Info(v ...interface{})
- func (sc *SyncContext) Infof(s string, v ...interface{})
- func (sc *SyncContext) PrintCapturedRequests(capReqs *CapturedRequests)
- func (sc *SyncContext) Promote(mfest Manifest, ...) int
- func (sc *SyncContext) ReadDigestsAndTags(mkProducer func(RegistryContext, ImageName) stream.Producer)
- func (sc *SyncContext) ReadImageNames(mkProducer func(RegistryContext) stream.Producer)
- func (sc *SyncContext) Warn(v ...interface{})
- func (sc *SyncContext) Warnf(s string, v ...interface{})
- type Tag
- type TagOp
- type TagSet
- type TagSlice
Constants ¶
const ( // Add represents those tags that are freely promotable, without fear of an // overwrite (we are only adding tags). Add TagOp = iota // Move represents those tags that conflict with existing digests, and so // must be move to re-point to the digest that we want to promote as defined // in the manifest. It can be thought of a Delete followed by an Add. Move = iota // Delete represents those tags that are not in the manifest and should thus // be removed and deleted. This is a kind of "demotion". Delete = iota )
Variables ¶
This section is empty.
Functions ¶
func GetDeleteCmd ¶
func GetDeleteCmd( rc RegistryContext, useServiceAccount bool, img ImageName, digest Digest) []string
GetDeleteCmd generates the cloud command used to delete images (used for garbage collection).
func GetRegistryListTagsCmd ¶
func GetRegistryListTagsCmd( rc RegistryContext, useServiceAccount bool, img string) []string
GetRegistryListTagsCmd generates the invocation for retrieving all digests (and tags on them) for a given image.
func GetRegistryListingCmd ¶
func GetRegistryListingCmd( rc RegistryContext, useServiceAccount bool) []string
GetRegistryListingCmd generates the invocation for retrieving all images in a GCR.
func GetWriteCmd ¶
func GetWriteCmd( dest RegistryContext, useServiceAccount bool, srcRegistry RegistryName, image ImageName, digest Digest, tag Tag, tp TagOp) []string
GetWriteCmd generates a gcloud command that is used to make modifications to a Docker Registry.
func MaybeUseServiceAccount ¶
MaybeUseServiceAccount injects a '--account=...' argument to the command with the given service account.
Types ¶
type CapturedRequests ¶
type CapturedRequests map[PromotionRequest]int
CapturedRequests holds a map of all PromotionRequests that were generated. It is used for both -dry-run and testing.
type Digest ¶
type Digest string
Digest is a string that contains the SHA256 hash of a Docker container image.
type DigestTags ¶
DigestTags is a map where each digest is associated with a TagSlice. It is associated with a TagSlice because an image digest can have more than 1 tag pointing to it, even within the same image name's namespace (tags are namespaced by the image name).
func (DigestTags) Overwrite ¶
func (a DigestTags) Overwrite(b DigestTags)
Overwrite insert's b's values into a.
type DigestTagsContext ¶
type DigestTagsContext struct {
ImageName ImageName
RegistryName RegistryName
}
DigestTagsContext holds information about the request that was used to fetch the list of digests and associated tags for a particular image. It is used in ReadDigestsAndTags().
type Image ¶
type Image struct {
ImageName ImageName `yaml:"name"`
Dmap DigestTags
}
Image holds information about an image. It's like an "Object" in the OOP sense, and holds all the information relating to a particular image that we care about.
type ImageDigest ¶
ImageDigest is a combination of the ImageName and Digest.
type ImageDigestTag ¶
ImageDigestTag is a flattened key used by RegInvFlat.
type ImageName ¶
type ImageName string
The ImageName can be just the bare name itself (e.g., "addon-builder" in "gcr.io/k8s-image-staging/addon-builder") or the prefix + name ("foo/bar/baz/quux" in "gcr.io/hello/foo/bar/baz/quux").
type Manifest ¶
type Manifest struct {
// Registries contains the source and destination (Src/Dest) registry names.
// It is possible that in the future, we support promoting to multiple
// registries, in which case we would have more than just Src/Dest.
Registries []RegistryContext
// Src contains the RegistryName which will be set as the source registry.
// All other registries in Registries will be treated as destination
// registries.
//
// TODO: check that RegistryName is present in a RegistryContext in
// Registries.
SrcRegistry RegistryName `yaml:"src-registry"`
Images []Image `yaml:"images,omitempty"`
}
Manifest stores the information in a manifest file (describing the desired state of a Docker Registry).
func ParseManifest ¶
ParseManifest parses a Manifest from a byteslice. This function is separate from ParseManifestFromFile() so that it can be tested independently.
func ParseManifestFromFile ¶
ParseManifestFromFile parses a Manifest from a filepath.
func (Manifest) ToRegInvImageDigest ¶
func (m Manifest) ToRegInvImageDigest() RegInvImageDigest
ToRegInvImageDigest converts a Manifest to a RegInvImageDigest.
func (Manifest) ToRegInvImageTag ¶
func (m Manifest) ToRegInvImageTag() RegInvImageTag
ToRegInvImageTag converts a Manifest to a RegInvImageTag.
type MasterInventory ¶
type MasterInventory map[RegistryName]RegInvImage
MasterInventory stores multiple RegInvImage elements, keyed by RegistryName.
func (*MasterInventory) PrettyValue ¶
func (mi *MasterInventory) PrettyValue() string
PrettyValue creates a prettified string representation of MasterInventory.
type PopulateRequests ¶
type PopulateRequests func(*SyncContext, chan<- stream.ExternalRequest)
PopulateRequests is a function that can generate requests used to fetch information about a Docker Registry, or to promote images. It basically generates the set of "gcloud ..." commands used to manipulate Docker Registries.
type ProcessRequest ¶
type ProcessRequest func( *SyncContext, <-chan stream.ExternalRequest, chan<- RequestResult, *sync.WaitGroup, *sync.Mutex)
ProcessRequest is the counterpart to PopulateRequests. It is a function that can take a request (generated by PopulateRequests) and process it. In the ictual implementation (e.g. in ReadDigestsAndTags()) it closes over some other local variables to record the change of state in the Docker Registry that was touched by processing the request.
func MkRequestCapturer ¶
func MkRequestCapturer(captured *CapturedRequests) ProcessRequest
MkRequestCapturer returns a function that simply records requests as they are captured (slured out from the reqs channel).
type PromotionRequest ¶
type PromotionRequest struct {
TagOp TagOp
RegistrySrc RegistryName
RegistryDest RegistryName
ServiceAccount string
ImageName ImageName
Digest Digest
DigestOld Digest // Only for tag moves.
Tag Tag
}
PromotionRequest contains all the information required for any type of promotion (or demotion!) (involving any TagOp).
func (*PromotionRequest) PrettyValue ¶
func (pr *PromotionRequest) PrettyValue() string
PrettyValue is a prettified string representation of a PromotionRequest.
type RegInvFlat ¶
type RegInvFlat map[ImageDigestTag]interface{}
RegInvFlat is a flattened view of a Docker Registry, where the keys contain all 3 attributes --- the image name, digest, and tag.
func (RegInvFlat) ToSet ¶
func (a RegInvFlat) ToSet() container.Set
ToSet converts a RegInvFlat to a Set.
type RegInvImage ¶
type RegInvImage map[ImageName]DigestTags
A RegInvImage is a map containing all of the image names, and their associated digest-to-tags mappings. It is the simplest view of a Docker Registry, because the keys are just the ImageNames (where each ImageName does *not* include the registry name, because we already key this by the RegistryName in MasterInventory).
func (RegInvImage) Minus ¶
func (a RegInvImage) Minus(b RegInvImage) RegInvImage
Minus is a set operation.
func (RegInvImage) ToRegInvImageDigest ¶
func (ri RegInvImage) ToRegInvImageDigest() RegInvImageDigest
ToRegInvImageDigest takes a RegInvImage and converts it to a RegInvImageDigest.
func (RegInvImage) ToRegInvImageTag ¶
func (ri RegInvImage) ToRegInvImageTag() RegInvImageTag
ToRegInvImageTag converts a RegInvImage to a RegInvImageTag.
func (RegInvImage) ToSet ¶
func (a RegInvImage) ToSet() container.Set
ToSet converts a RegInvImage to a Set.
func (RegInvImage) Union ¶
func (a RegInvImage) Union(b RegInvImage) RegInvImage
Union is a set operation.
type RegInvImageDigest ¶
type RegInvImageDigest map[ImageDigest]TagSlice
RegInvImageDigest is a view of a Docker Reqistry, keyed by ImageDigest.
func (RegInvImageDigest) Intersection ¶
func (a RegInvImageDigest) Intersection(b RegInvImageDigest) RegInvImageDigest
Intersection is a set operation.
func (RegInvImageDigest) Minus ¶
func (a RegInvImageDigest) Minus(b RegInvImageDigest) RegInvImageDigest
Minus is a set operation.
func (*RegInvImageDigest) PrettyValue ¶
func (riid *RegInvImageDigest) PrettyValue() string
PrettyValue converts a RegInvImageDigest to a prettified string representation.
func (RegInvImageDigest) ToRegInvImageTag ¶
func (riid RegInvImageDigest) ToRegInvImageTag() RegInvImageTag
ToRegInvImageTag converts a RegInvImageDigest to a RegInvImageTag.
func (RegInvImageDigest) ToSet ¶
func (a RegInvImageDigest) ToSet() container.Set
ToSet converts a RegInvFlat to a Set.
type RegInvImageTag ¶
RegInvImageTag is keyed by a ImageTag.
func (RegInvImageTag) Intersection ¶
func (a RegInvImageTag) Intersection(b RegInvImageTag) RegInvImageTag
Intersection is a set operation.
func (RegInvImageTag) Minus ¶
func (a RegInvImageTag) Minus(b RegInvImageTag) RegInvImageTag
Minus is a set operation.
func (RegInvImageTag) ToSet ¶
func (a RegInvImageTag) ToSet() container.Set
ToSet converts a RegInvImageTag to a Set.
type Registry ¶
type Registry struct {
RegistryName string
RegistryNameLong RegistryName
RegInvImageDigest RegInvImageDigest
}
Registry is another way to look at a Docker Registry; it is used during Promotion.
func (*Registry) PrettyValue ¶
PrettyValue converts a Registry to a prettified string representation.
type RegistryContext ¶
type RegistryContext struct {
Name RegistryName
ServiceAccount string `yaml:"service-account,omitempty"`
}
RegistryContext holds information about a registry, to be written in a manifest file.
type RegistryName ¶
type RegistryName string
RegistryName is the leading part of an image name that includes the domain; it is everything that is not the actual image name itself. E.g., "gcr.io/google-containers".
type RequestResult ¶
type RequestResult struct {
Context stream.ExternalRequest
Errors Errors
}
RequestResult contains information about the result of running a request (e.g., a "gcloud" command, or perhaps in the future, a REST call).
type SyncContext ¶
type SyncContext struct {
ManifestPath string
Verbosity int
Threads int
DeleteExtraTags bool
DryRun bool
UseServiceAccount bool
Inv MasterInventory
RegistryContexts []RegistryContext
}
SyncContext is the main data structure for performing the promotion.
func MakeSyncContext ¶
func MakeSyncContext( manifestPath string, mi MasterInventory, verbosity, threads int, deleteExtraTags, dryRun, useSvcAcc bool, rcs []RegistryContext) SyncContext
MakeSyncContext creates a SyncContext.
func (*SyncContext) Error ¶
func (sc *SyncContext) Error(v ...interface{})
Error logs at ERROR level.
func (*SyncContext) Errorf ¶
func (sc *SyncContext) Errorf(s string, v ...interface{})
Errorf logs at ERROR level.
func (*SyncContext) ExecRequests ¶
func (sc *SyncContext) ExecRequests( populateRequests PopulateRequests, processRequest ProcessRequest)
ExecRequests uses the Worker Pool pattern, where MaxConcurrentRequests determines the number of workers to spawn.
func (*SyncContext) Fatal ¶
func (sc *SyncContext) Fatal(v ...interface{})
Fatal logs at FATAL level.
func (*SyncContext) Fatalf ¶
func (sc *SyncContext) Fatalf(s string, v ...interface{})
Fatalf logs at FATAL level.
func (*SyncContext) GarbageCollect ¶
func (sc *SyncContext) GarbageCollect( mfest Manifest, mkProducer func(RegistryContext, ImageName, Digest) stream.Producer, customProcessRequest *ProcessRequest)
GarbageCollect deletes all images that are not referenced by Docker tags. nolint[gocyclo]
func (*SyncContext) GetLostImages ¶ added in v1.0.1
func (sc *SyncContext) GetLostImages(mfest Manifest) RegInvImageDigest
GetLostImages gets all images in Manifest which are missing from src, and also logs them in the process.
func (*SyncContext) GetPromotionCandidatesIT ¶
func (sc *SyncContext) GetPromotionCandidatesIT( mfest Manifest) RegInvImageTag
GetPromotionCandidatesIT returns those images that are due for promotion.
func (*SyncContext) Infof ¶
func (sc *SyncContext) Infof(s string, v ...interface{})
Infof logs at INFO level.
func (*SyncContext) PrintCapturedRequests ¶
func (sc *SyncContext) PrintCapturedRequests(capReqs *CapturedRequests)
PrintCapturedRequests pretty-prints all given PromotionRequests.
func (*SyncContext) Promote ¶
func (sc *SyncContext) Promote( mfest Manifest, mkProducer func( RegistryName, RegistryContext, ImageName, Digest, Tag, TagOp) stream.Producer, customProcessRequest *ProcessRequest) int
Promote perferms container image promotion by realizing the intent in the Manifest.
func (*SyncContext) ReadDigestsAndTags ¶
func (sc *SyncContext) ReadDigestsAndTags( mkProducer func(RegistryContext, ImageName) stream.Producer)
ReadDigestsAndTags runs `gcloud container images list-tags gcr.io/louhi-gke-k8s/etcd --format=json` For each image name, retrieve all digests and corresponding tags (if any).
func (*SyncContext) ReadImageNames ¶
func (sc *SyncContext) ReadImageNames( mkProducer func(RegistryContext) stream.Producer)
ReadImageNames only works for streams that interpret json.
func (*SyncContext) Warnf ¶
func (sc *SyncContext) Warnf(s string, v ...interface{})
Warnf logs at WARN level.
type TagOp ¶
type TagOp int
TagOp is an enum that describes the various types of tag-modifying operations. These actions are a bit more low-level, and currently support 3 operations: adding, moving, and deleting.
func (*TagOp) PrettyValue ¶
PrettyValue is a prettified string representation of a TagOp.
type TagSet ¶
type TagSet map[Tag]interface{}
TagSet is a set of Tags.
func (TagSet) Intersection ¶
Intersection is a set operation.