Documentation
¶
Overview ¶
Package gcpartifactregistry emulates Google Artifact Registry: the v1 API (repositories, packages, versions, tags and docker images) over gRPC and REST, and a Docker Registry v2 data plane for DOCKER repositories on the same listener, so pushed images show up in the API. See PARITY.md.
Index ¶
- Constants
- Variables
- type ConfigProvider
- type DataDirConfig
- type DockerRepoInfo
- type Handler
- func (h *Handler) API() artifactregistrypb.ArtifactRegistryServer
- func (h *Handler) Addr() string
- func (h *Handler) ExtractOperation(*echo.Context) string
- func (h *Handler) ExtractResource(*echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- type InMemoryBackend
- func (b *InMemoryBackend) BatchDeleteVersions(ctx context.Context, in *artifactregistrypb.BatchDeleteVersionsRequest) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) Close()
- func (b *InMemoryBackend) CreateRepository(in *artifactregistrypb.CreateRepositoryRequest) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) CreateRule(in *artifactregistrypb.CreateRuleRequest) (*artifactregistrypb.Rule, error)
- func (b *InMemoryBackend) CreateTag(ctx context.Context, in *artifactregistrypb.CreateTagRequest) (*artifactregistrypb.Tag, error)
- func (b *InMemoryBackend) DeleteFile(_ context.Context, name string) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) DeletePackage(ctx context.Context, name string) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) DeleteRepository(ctx context.Context, name string) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) DeleteRule(name string) (*emptypb.Empty, error)
- func (b *InMemoryBackend) DeleteTag(ctx context.Context, name string) error
- func (b *InMemoryBackend) DeleteVersion(ctx context.Context, in *artifactregistrypb.DeleteVersionRequest) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) DockerHandler() http.Handler
- func (b *InMemoryBackend) FileExtras() gcprest.Extra
- func (b *InMemoryBackend) GetDockerImage(ctx context.Context, name string) (*artifactregistrypb.DockerImage, error)
- func (b *InMemoryBackend) GetFile(ctx context.Context, name string) (*artifactregistrypb.File, error)
- func (b *InMemoryBackend) GetIamPolicy(resource string, version int32) (*iampb.Policy, error)
- func (b *InMemoryBackend) GetPackage(name string) (*artifactregistrypb.Package, error)
- func (b *InMemoryBackend) GetProjectSettings(name string) (*artifactregistrypb.ProjectSettings, error)
- func (b *InMemoryBackend) GetRepository(name string) (*artifactregistrypb.Repository, error)
- func (b *InMemoryBackend) GetRule(name string) (*artifactregistrypb.Rule, error)
- func (b *InMemoryBackend) GetTag(name string) (*artifactregistrypb.Tag, error)
- func (b *InMemoryBackend) GetVPCSCConfig(name string) (*artifactregistrypb.VPCSCConfig, error)
- func (b *InMemoryBackend) GetVersion(ctx context.Context, in *artifactregistrypb.GetVersionRequest) (*artifactregistrypb.Version, error)
- func (b *InMemoryBackend) ImageNames(project, id string) []string
- func (b *InMemoryBackend) ListDockerImages(ctx context.Context, in *artifactregistrypb.ListDockerImagesRequest) ([]*artifactregistrypb.DockerImage, string, error)
- func (b *InMemoryBackend) ListFiles(ctx context.Context, in *artifactregistrypb.ListFilesRequest) ([]*artifactregistrypb.File, string, error)
- func (b *InMemoryBackend) ListPackages(in *artifactregistrypb.ListPackagesRequest) ([]*artifactregistrypb.Package, string, error)
- func (b *InMemoryBackend) ListRepositories(in *artifactregistrypb.ListRepositoriesRequest) ([]*artifactregistrypb.Repository, string, error)
- func (b *InMemoryBackend) ListRules(in *artifactregistrypb.ListRulesRequest) ([]*artifactregistrypb.Rule, string, error)
- func (b *InMemoryBackend) ListTags(in *artifactregistrypb.ListTagsRequest) ([]*artifactregistrypb.Tag, string, error)
- func (b *InMemoryBackend) ListVersions(ctx context.Context, in *artifactregistrypb.ListVersionsRequest) ([]*artifactregistrypb.Version, string, error)
- func (b *InMemoryBackend) LookupDockerRepo(project, id string) (DockerRepoInfo, bool)
- func (b *InMemoryBackend) PackageExtras() gcprest.Extra
- func (b *InMemoryBackend) RecordManifestDelete(repo, ref string)
- func (b *InMemoryBackend) RecordManifestPut(repo, ref, digest string)
- func (b *InMemoryBackend) Registry() http.Handler
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetContext(ctx context.Context)
- func (b *InMemoryBackend) SetDataDir(dir string)
- func (b *InMemoryBackend) SetIamPolicy(resource string, policy *iampb.Policy) (*iampb.Policy, error)
- func (b *InMemoryBackend) SetRegistryAddress(host, port string)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) TagExists(repo, tag string) bool
- func (b *InMemoryBackend) TestIamPermissions(resource string, perms []string) ([]string, error)
- func (b *InMemoryBackend) UpdateFile(ctx context.Context, in *artifactregistrypb.UpdateFileRequest) (*artifactregistrypb.File, error)
- func (b *InMemoryBackend) UpdatePackage(in *artifactregistrypb.UpdatePackageRequest) (*artifactregistrypb.Package, error)
- func (b *InMemoryBackend) UpdateProjectSettings(in *artifactregistrypb.UpdateProjectSettingsRequest) (*artifactregistrypb.ProjectSettings, error)
- func (b *InMemoryBackend) UpdateRepository(in *artifactregistrypb.UpdateRepositoryRequest) (*artifactregistrypb.Repository, error)
- func (b *InMemoryBackend) UpdateRule(in *artifactregistrypb.UpdateRuleRequest) (*artifactregistrypb.Rule, error)
- func (b *InMemoryBackend) UpdateTag(ctx context.Context, in *artifactregistrypb.UpdateTagRequest) (*artifactregistrypb.Tag, error)
- func (b *InMemoryBackend) UpdateVPCSCConfig(in *artifactregistrypb.UpdateVPCSCConfigRequest) (*artifactregistrypb.VPCSCConfig, error)
- func (b *InMemoryBackend) UpdateVersion(in *artifactregistrypb.UpdateVersionRequest) (*artifactregistrypb.Version, error)
- func (b *InMemoryBackend) UploadGenericArtifact(_ context.Context, parent string, in uploadReq, data []byte) (*longrunningpb.Operation, error)
- type Provider
- type Settings
Constants ¶
const DefaultPort = 8134
DefaultPort is the dedicated gRPC, REST and Docker Registry listener's default TCP port.
const DefaultRegistryHost = "localhost"
DefaultRegistryHost is the host advertised in repositories' registry_uri.
Variables ¶
var ErrNilAppContext = errors.New("gcpartifactregistry: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
Functions ¶
This section is empty.
Types ¶
type ConfigProvider ¶
type ConfigProvider interface {
GetGCPArtifactRegistrySettings() Settings
}
ConfigProvider extracts Artifact Registry configuration from the AppContext Config.
type DataDirConfig ¶
type DataDirConfig interface {
GetRegistryDataDir() string
}
DataDirConfig locates the directory image blobs are kept in; empty keeps them in memory.
type DockerRepoInfo ¶
DockerRepoInfo describes the repository a registry path belongs to.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
Port int
// contains filtered or unexported fields
}
Handler serves Artifact Registry on a dedicated listener.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a Handler; callers override Port from Settings.
func (*Handler) API ¶
func (h *Handler) API() artifactregistrypb.ArtifactRegistryServer
API exposes the Artifact Registry service for in-process callers (dashboard proxy).
func (*Handler) ExtractOperation ¶
ExtractOperation is unused: requests never reach the shared router.
func (*Handler) ExtractResource ¶
ExtractResource is unused: requests never reach the shared router.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists the supported gRPC methods.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns a 404 handler; the real API is on the dedicated port.
func (*Handler) MatchPriority ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: Artifact Registry runs on its own listener.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend holds all Artifact Registry state under one lock. Docker images live in one embedded registry whose repositories are named <project>/<repository>/<image>.
func NewInMemoryBackend ¶
func NewInMemoryBackend() *InMemoryBackend
NewInMemoryBackend creates an empty backend that keeps images in memory.
func (*InMemoryBackend) BatchDeleteVersions ¶
func (b *InMemoryBackend) BatchDeleteVersions( ctx context.Context, in *artifactregistrypb.BatchDeleteVersionsRequest, ) (*longrunningpb.Operation, error)
BatchDeleteVersions deletes several manifests of one package, force-deleting tagged ones.
func (*InMemoryBackend) Close ¶
func (b *InMemoryBackend) Close()
Close releases the embedded registry without deleting stored images.
func (*InMemoryBackend) CreateRepository ¶
func (b *InMemoryBackend) CreateRepository( in *artifactregistrypb.CreateRepositoryRequest, ) (*longrunningpb.Operation, error)
CreateRepository stores a repository and returns the finished operation.
func (*InMemoryBackend) CreateRule ¶
func (b *InMemoryBackend) CreateRule(in *artifactregistrypb.CreateRuleRequest) (*artifactregistrypb.Rule, error)
CreateRule stores a rule; a repository holds one rule for itself and one per package.
func (*InMemoryBackend) CreateTag ¶
func (b *InMemoryBackend) CreateTag( ctx context.Context, in *artifactregistrypb.CreateTagRequest, ) (*artifactregistrypb.Tag, error)
CreateTag points a new tag at an existing version.
func (*InMemoryBackend) DeleteFile ¶
func (b *InMemoryBackend) DeleteFile(_ context.Context, name string) (*longrunningpb.Operation, error)
DeleteFile deletes a generic file; other formats refuse, as AR allows it on generic repositories only.
func (*InMemoryBackend) DeletePackage ¶
func (b *InMemoryBackend) DeletePackage(ctx context.Context, name string) (*longrunningpb.Operation, error)
DeletePackage deletes every version of an image.
func (*InMemoryBackend) DeleteRepository ¶
func (b *InMemoryBackend) DeleteRepository( ctx context.Context, name string, ) (*longrunningpb.Operation, error)
DeleteRepository removes a repository with every image in it.
func (*InMemoryBackend) DeleteRule ¶
func (b *InMemoryBackend) DeleteRule(name string) (*emptypb.Empty, error)
DeleteRule removes a rule.
func (*InMemoryBackend) DeleteTag ¶
func (b *InMemoryBackend) DeleteTag(ctx context.Context, name string) error
DeleteTag removes a tag, leaving its version in place.
func (*InMemoryBackend) DeleteVersion ¶
func (b *InMemoryBackend) DeleteVersion( ctx context.Context, in *artifactregistrypb.DeleteVersionRequest, ) (*longrunningpb.Operation, error)
DeleteVersion deletes one manifest; force is required when tags point at it.
func (*InMemoryBackend) DockerHandler ¶
func (b *InMemoryBackend) DockerHandler() http.Handler
DockerHandler serves the Docker Registry v2 API for DOCKER repositories at /v2/<project>/<repository>/<image>. Any credential is accepted, as oauth2accesstoken:<token> Basic auth or a Bearer token; a request without one is challenged to fetch a token from /v2/token.
func (*InMemoryBackend) FileExtras ¶
func (b *InMemoryBackend) FileExtras() gcprest.Extra
FileExtras routes the media endpoints that have no gRPC method: the generic artifact upload and file download.
func (*InMemoryBackend) GetDockerImage ¶
func (b *InMemoryBackend) GetDockerImage( ctx context.Context, name string, ) (*artifactregistrypb.DockerImage, error)
GetDockerImage returns one manifest of an image, addressed by digest or tag.
func (*InMemoryBackend) GetFile ¶
func (b *InMemoryBackend) GetFile(ctx context.Context, name string) (*artifactregistrypb.File, error)
GetFile returns one file.
func (*InMemoryBackend) GetIamPolicy ¶
GetIamPolicy returns a repository's policy at the requested version, or an empty one with an etag if none was set.
func (*InMemoryBackend) GetPackage ¶
func (b *InMemoryBackend) GetPackage(name string) (*artifactregistrypb.Package, error)
GetPackage returns one image as a package.
func (*InMemoryBackend) GetProjectSettings ¶
func (b *InMemoryBackend) GetProjectSettings(name string) (*artifactregistrypb.ProjectSettings, error)
GetProjectSettings returns a project's settings; a project that never changed them has the defaults.
func (*InMemoryBackend) GetRepository ¶
func (b *InMemoryBackend) GetRepository(name string) (*artifactregistrypb.Repository, error)
GetRepository returns a repository with its size and registry_uri filled in.
func (*InMemoryBackend) GetRule ¶
func (b *InMemoryBackend) GetRule(name string) (*artifactregistrypb.Rule, error)
GetRule returns one rule.
func (*InMemoryBackend) GetTag ¶
func (b *InMemoryBackend) GetTag(name string) (*artifactregistrypb.Tag, error)
GetTag returns one tag.
func (*InMemoryBackend) GetVPCSCConfig ¶
func (b *InMemoryBackend) GetVPCSCConfig(name string) (*artifactregistrypb.VPCSCConfig, error)
GetVPCSCConfig returns a location's VPC-SC policy, ALLOW until it is changed.
func (*InMemoryBackend) GetVersion ¶
func (b *InMemoryBackend) GetVersion( ctx context.Context, in *artifactregistrypb.GetVersionRequest, ) (*artifactregistrypb.Version, error)
GetVersion returns one manifest as a version.
func (*InMemoryBackend) ImageNames ¶
func (b *InMemoryBackend) ImageNames(project, id string) []string
ImageNames lists the images in the repository at registry path prefix project/repository, sorted.
func (*InMemoryBackend) ListDockerImages ¶
func (b *InMemoryBackend) ListDockerImages( ctx context.Context, in *artifactregistrypb.ListDockerImagesRequest, ) ([]*artifactregistrypb.DockerImage, string, error)
ListDockerImages lists every manifest of the repository's images.
func (*InMemoryBackend) ListFiles ¶
func (b *InMemoryBackend) ListFiles( ctx context.Context, in *artifactregistrypb.ListFilesRequest, ) ([]*artifactregistrypb.File, string, error)
ListFiles lists a repository's files, filtered by name, owner and annotations.
func (*InMemoryBackend) ListPackages ¶
func (b *InMemoryBackend) ListPackages( in *artifactregistrypb.ListPackagesRequest, ) ([]*artifactregistrypb.Package, string, error)
ListPackages lists the images of a DOCKER repository as packages.
func (*InMemoryBackend) ListRepositories ¶
func (b *InMemoryBackend) ListRepositories( in *artifactregistrypb.ListRepositoriesRequest, ) ([]*artifactregistrypb.Repository, string, error)
ListRepositories lists repositories under a location, or every location with "-".
func (*InMemoryBackend) ListRules ¶
func (b *InMemoryBackend) ListRules( in *artifactregistrypb.ListRulesRequest, ) ([]*artifactregistrypb.Rule, string, error)
ListRules lists a repository's rules by name.
func (*InMemoryBackend) ListTags ¶
func (b *InMemoryBackend) ListTags(in *artifactregistrypb.ListTagsRequest) ([]*artifactregistrypb.Tag, string, error)
ListTags lists an image's tags, optionally only those on one version.
func (*InMemoryBackend) ListVersions ¶
func (b *InMemoryBackend) ListVersions( ctx context.Context, in *artifactregistrypb.ListVersionsRequest, ) ([]*artifactregistrypb.Version, string, error)
ListVersions lists the manifests of an image as versions.
func (*InMemoryBackend) LookupDockerRepo ¶
func (b *InMemoryBackend) LookupDockerRepo(project, id string) (DockerRepoInfo, bool)
LookupDockerRepo resolves project/repository to its location and format.
func (*InMemoryBackend) PackageExtras ¶
func (b *InMemoryBackend) PackageExtras() gcprest.Extra
PackageExtras routes the npm, Python and Maven protocols on <location>-<format>.pkg.dev hosts, where the path is /<project>/<repository>/..., and at /<format>/<project>/<repository>/... on any other host.
func (*InMemoryBackend) RecordManifestDelete ¶
func (b *InMemoryBackend) RecordManifestDelete(repo, ref string)
RecordManifestDelete notes a manifest or tag deleted through the Docker API.
func (*InMemoryBackend) RecordManifestPut ¶
func (b *InMemoryBackend) RecordManifestPut(repo, ref, digest string)
RecordManifestPut notes a manifest stored through the Docker API.
func (*InMemoryBackend) Registry ¶
func (b *InMemoryBackend) Registry() http.Handler
Registry returns the embedded Docker registry handler (no authentication).
func (*InMemoryBackend) Reset ¶
func (b *InMemoryBackend) Reset()
Reset removes every repository and image.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads a snapshot, replacing every repository.
func (*InMemoryBackend) SetContext ¶
func (b *InMemoryBackend) SetContext(ctx context.Context)
SetContext bounds the lifetime of the embedded registry.
func (*InMemoryBackend) SetDataDir ¶
func (b *InMemoryBackend) SetDataDir(dir string)
SetDataDir keeps image blobs and manifests under dir; empty keeps them in memory.
func (*InMemoryBackend) SetIamPolicy ¶
func (b *InMemoryBackend) SetIamPolicy(resource string, policy *iampb.Policy) (*iampb.Policy, error)
SetIamPolicy replaces a repository's policy; a stale etag aborts the call.
func (*InMemoryBackend) SetRegistryAddress ¶
func (b *InMemoryBackend) SetRegistryAddress(host, port string)
SetRegistryAddress sets the host and port advertised in registry_uri and image URIs.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises repositories, IAM policies, the ledger, generic artifacts, rules, settings and operations. Image blobs and manifests are not part of it: they live under the data directory when one is configured.
func (*InMemoryBackend) TagExists ¶
func (b *InMemoryBackend) TagExists(repo, tag string) bool
TagExists reports whether tag already points at a manifest in repo.
func (*InMemoryBackend) TestIamPermissions ¶
func (b *InMemoryBackend) TestIamPermissions(resource string, perms []string) ([]string, error)
TestIamPermissions reports the requested Artifact Registry permissions as granted: the emulator does not enforce IAM.
func (*InMemoryBackend) UpdateFile ¶
func (b *InMemoryBackend) UpdateFile( ctx context.Context, in *artifactregistrypb.UpdateFileRequest, ) (*artifactregistrypb.File, error)
UpdateFile replaces the annotations of a file.
func (*InMemoryBackend) UpdatePackage ¶
func (b *InMemoryBackend) UpdatePackage( in *artifactregistrypb.UpdatePackageRequest, ) (*artifactregistrypb.Package, error)
UpdatePackage changes the display name and annotations of a package.
func (*InMemoryBackend) UpdateProjectSettings ¶
func (b *InMemoryBackend) UpdateProjectSettings( in *artifactregistrypb.UpdateProjectSettingsRequest, ) (*artifactregistrypb.ProjectSettings, error)
UpdateProjectSettings applies legacy_redirection_state and pull_percent.
func (*InMemoryBackend) UpdateRepository ¶
func (b *InMemoryBackend) UpdateRepository( in *artifactregistrypb.UpdateRepositoryRequest, ) (*artifactregistrypb.Repository, error)
UpdateRepository applies the masked fields (all set fields when the mask is empty).
func (*InMemoryBackend) UpdateRule ¶
func (b *InMemoryBackend) UpdateRule(in *artifactregistrypb.UpdateRuleRequest) (*artifactregistrypb.Rule, error)
UpdateRule applies the masked fields; an empty mask copies every field the request sets.
func (*InMemoryBackend) UpdateTag ¶
func (b *InMemoryBackend) UpdateTag( ctx context.Context, in *artifactregistrypb.UpdateTagRequest, ) (*artifactregistrypb.Tag, error)
UpdateTag moves an existing tag to another version.
func (*InMemoryBackend) UpdateVPCSCConfig ¶
func (b *InMemoryBackend) UpdateVPCSCConfig( in *artifactregistrypb.UpdateVPCSCConfigRequest, ) (*artifactregistrypb.VPCSCConfig, error)
UpdateVPCSCConfig sets vpcsc_policy.
func (*InMemoryBackend) UpdateVersion ¶
func (b *InMemoryBackend) UpdateVersion( in *artifactregistrypb.UpdateVersionRequest, ) (*artifactregistrypb.Version, error)
UpdateVersion changes the description and annotations of a version.
func (*InMemoryBackend) UploadGenericArtifact ¶
func (b *InMemoryBackend) UploadGenericArtifact( _ context.Context, parent string, in uploadReq, data []byte, ) (*longrunningpb.Operation, error)
UploadGenericArtifact stores a file of a generic repository, creating its package and version.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for Google Artifact Registry. It serves gRPC, REST and the Docker Registry API on its own listener (see Handler.StartWorker) and never matches on the shared AWS router.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init creates the backend and handler; the port is bound in StartWorker.
type Settings ¶
type Settings struct {
RegistryHost string `` //nolint:lll // config struct tags are intentionally verbose
/* 197-byte string literal not displayed */
Port int `` //nolint:lll // config struct tags are intentionally verbose
/* 236-byte string literal not displayed */
}
Settings holds service-level configuration, embedded in the root CLI command as CLI.GCPArtifactRegistry.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings returns the settings used when no ConfigProvider is available.