codeartifact

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 25 Imported by: 0

README

CodeArtifact

Parity grade: A · SDK aws-sdk-go-v2/service/codeartifact@v1.38.19 · last audited 2026-07-13 (f779cb61)

Coverage

Metric Value
Operations audited 48 (38 ok, 4 partial, 6 gap)
Feature families 2 (2 ok)
Known gaps 5
Deferred items 2
Resource leaks clean
Known gaps
  • GetAssociatedPackageGroup/ListAssociatedPackages/ListAllowedRepositoriesForGroup/UpdatePackageGroupOriginConfiguration's allowed-repository-list semantics are stubs: package-group pattern matching (glob-style segment matching against format/namespace/package) is never implemented, so groups never match. ListSubPackageGroups uses a prefix heuristic instead of real pattern semantics. Implementing this is a real feature (AWS's pattern-matching algorithm), not a quick wire fix — needs its own pass.
  • DescribePackage / DescribePackageVersion auto-create a stub record when the resource doesn't exist, instead of returning ResourceNotFoundException like real AWS. This is pre-existing, intentionally-documented behavior (not touched this pass to avoid destabilizing a large swath of tests that depend on it) but is a real behavioral divergence from AWS.
  • GetPackageVersionReadme and ListPackageVersionDependencies always return empty — real values require parsing package-format-specific metadata from the uploaded asset (npm package.json readme/dependencies, Maven POM, etc.), which PublishPackageVersion's single-asset-per-call model doesn't capture today.
  • GetAuthorizationToken returns a fabricated token string rather than any real credential material; acceptable since nothing validates it downstream, but flagged in case a future op starts checking it.
  • domain-owner / cross-account query param is accepted by real AWS on nearly every op (for cross-account domain access) but is not read anywhere in this backend; single-account-only is assumed throughout.
Deferred
  • Full package-group pattern-matching algorithm (see gaps above)
  • isolation_test.go / sdk_completeness_test.go / store_setup.go were read but not modified — no bugs found in a quick pass, not exhaustively re-audited

More

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a requested resource does not exist.
	ErrNotFound = awserr.New("ResourceNotFoundException", awserr.ErrNotFound)
	// ErrAlreadyExists is returned when a resource already exists.
	ErrAlreadyExists = awserr.New("ConflictException", awserr.ErrConflict)
	// ErrValidation is returned when input validation fails.
	ErrValidation = awserr.New("ValidationException", awserr.ErrInvalidParameter)
)
View Source
var ErrNilAppContext = errors.New("nil app context")

ErrNilAppContext is returned when Init is called with a nil AppContext.

Functions

This section is empty.

Types

type AssetInfo

type AssetInfo struct {
	Name    string `json:"name"`
	SHA256  string `json:"sha256"`
	Content []byte `json:"content,omitempty"`
	Size    int64  `json:"size"`
}

AssetInfo represents an asset (file) uploaded to a package version via PublishPackageVersion. Content holds the raw bytes so GetPackageVersionAsset can serve back exactly what was published, instead of always returning an empty stub.

type Domain

type Domain struct {
	CreatedTime    time.Time  `json:"createdTime"`
	Tags           *tags.Tags `json:"tags,omitempty"`
	Name           string     `json:"name"`
	ARN            string     `json:"arn"`
	EncryptionKey  string     `json:"encryptionKey,omitempty"`
	Owner          string     `json:"owner"`
	Region         string     `json:"region"`
	Status         string     `json:"status"`
	S3BucketARN    string     `json:"s3BucketArn,omitempty"`
	AssetSizeBytes int64      `json:"assetSizeBytes"`
}

Domain represents an AWS CodeArtifact domain.

The Tags field is backend-owned. Callers must treat the returned pointer as read-only; mutate tags only via TagResource / CreateDomain.

type DomainPermissionsPolicy

type DomainPermissionsPolicy struct {
	Document    string `json:"document"`
	Revision    string `json:"revision"`
	ResourceARN string `json:"resourceArn"`
	// contains filtered or unexported fields
}

DomainPermissionsPolicy represents a permissions policy attached to a domain.

type ExternalConnection

type ExternalConnection struct {
	ExternalConnectionName string `json:"externalConnectionName"`
	PackageFormat          string `json:"packageFormat"`
	Status                 string `json:"status"`
}

ExternalConnection represents a connection of a repository to an external package source.

type Handler

type Handler struct {
	Backend *InMemoryBackend
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

func (*Handler) Name

func (h *Handler) Name() string

func (*Handler) Reset

func (h *Handler) Reset()

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

type InMemoryBackend

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

InMemoryBackend is the in-memory store for CodeArtifact resources.

domains and repositories already carry a real, wire-visible Region field, so each registers directly on b.registry as a flat *store.Table keyed by the composite "region|id" string (see regionKey), with a companion *store.Index grouping entries by region for the per-region scans the old region-nested maps used to answer directly -- the region-qualified-table pattern services/emr uses.

packageGroups, packages, and packageVersions have no wire-visible region field, so each gained an unexported region field purely for this composite key; they are "dirty" tables (store.New only, NOT store.Register-ed onto b.registry -- see store_setup.go) round-tripped through a DTO wrapper in persistence.go. repositoryPolicies and domainPolicies are also "dirty" for the same reason (region, plus domainName/repoName -- neither type carries any parent-identity field at all).

externalConnections is deliberately NOT converted: its value, []ExternalConnection, is a slice of plain structs with no identity of its own, so there is nothing for store.Table to key on. It remains a plain region-nested map, unchanged by this refactor.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates a new in-memory CodeArtifact backend.

func (*InMemoryBackend) AssociateExternalConnection

func (b *InMemoryBackend) AssociateExternalConnection(
	ctx context.Context,
	domainName, repoName, connectionName string,
) (*Repository, error)

AssociateExternalConnection associates an external connection with a repository.

func (*InMemoryBackend) CopyPackageVersions

func (b *InMemoryBackend) CopyPackageVersions(
	ctx context.Context,
	domainName, srcRepo, dstRepo, format, namespace, name string,
	versions []string,
) (map[string]string, error)

CopyPackageVersions copies specified package versions from a source repository to a destination repository in the same domain.

func (*InMemoryBackend) CountRepositoriesInDomain

func (b *InMemoryBackend) CountRepositoriesInDomain(ctx context.Context, domainName string) int

CountRepositoriesInDomain returns the number of repositories in a domain.

func (*InMemoryBackend) CreateDomain

func (b *InMemoryBackend) CreateDomain(
	ctx context.Context, name, encryptionKey string, kv map[string]string,
) (*Domain, error)

CreateDomain creates a new CodeArtifact domain.

func (*InMemoryBackend) CreatePackageGroup

func (b *InMemoryBackend) CreatePackageGroup(
	ctx context.Context,
	domainName, pattern, description, contactInfo string,
	kv map[string]string,
) (*PackageGroup, error)

CreatePackageGroup creates a new CodeArtifact package group.

func (*InMemoryBackend) CreateRepository

func (b *InMemoryBackend) CreateRepository(
	ctx context.Context,
	domainName, repoName, description string,
	kv map[string]string,
	upstreams []string,
) (*Repository, error)

CreateRepository creates a new CodeArtifact repository.

func (*InMemoryBackend) DeleteDomain

func (b *InMemoryBackend) DeleteDomain(ctx context.Context, name string) (*Domain, error)

DeleteDomain deletes a domain by name, cascade-deleting all its repositories, packages, package versions, external connections, policies, and Tags.

func (*InMemoryBackend) DeleteDomainPermissionsPolicy

func (b *InMemoryBackend) DeleteDomainPermissionsPolicy(
	ctx context.Context, domainName string,
) (*DomainPermissionsPolicy, error)

DeleteDomainPermissionsPolicy removes the permissions policy from a domain. Returns ErrNotFound if the domain does not exist or if no policy has been set.

func (*InMemoryBackend) DeletePackage

func (b *InMemoryBackend) DeletePackage(
	ctx context.Context, domainName, repoName, format, namespace, name string,
) (*Package, error)

DeletePackage deletes a package and all its versions from a repository.

func (*InMemoryBackend) DeletePackageGroup

func (b *InMemoryBackend) DeletePackageGroup(ctx context.Context, domainName, pattern string) (*PackageGroup, error)

DeletePackageGroup deletes a package group by domain and pattern.

func (*InMemoryBackend) DeletePackageVersions

func (b *InMemoryBackend) DeletePackageVersions(
	ctx context.Context,
	domainName, repoName, format, namespace, name string,
	versions []string,
) (map[string]string, error)

DeletePackageVersions deletes specified versions of a package and returns a map of version→errorCode for any versions that could not be deleted.

func (*InMemoryBackend) DeleteRepository

func (b *InMemoryBackend) DeleteRepository(ctx context.Context, domainName, repoName string) (*Repository, error)

DeleteRepository deletes a repository by domain and name, cascade-deleting all its packages, package versions, external connections, permissions policy, and Tags.

func (*InMemoryBackend) DeleteRepositoryPermissionsPolicy

func (b *InMemoryBackend) DeleteRepositoryPermissionsPolicy(
	ctx context.Context,
	domainName, repoName string,
) (*RepositoryPermissionsPolicy, error)

DeleteRepositoryPermissionsPolicy removes the permissions policy from a repository.

func (*InMemoryBackend) DescribeDomain

func (b *InMemoryBackend) DescribeDomain(ctx context.Context, name string) (*Domain, error)

DescribeDomain returns a domain by name.

func (*InMemoryBackend) DescribePackage

func (b *InMemoryBackend) DescribePackage(
	ctx context.Context, domainName, repoName, format, namespace, name string,
) (*Package, error)

DescribePackage returns a package by domain, repository, format, namespace, and name. If the package does not already exist in the store, a stub entry is created on the fly so that callers (e.g. Terraform providers) can always retrieve metadata about packages that were published directly to the repository.

func (*InMemoryBackend) DescribePackageGroup

func (b *InMemoryBackend) DescribePackageGroup(ctx context.Context, domainName, pattern string) (*PackageGroup, error)

DescribePackageGroup returns a package group by domain and pattern.

func (*InMemoryBackend) DescribePackageVersion

func (b *InMemoryBackend) DescribePackageVersion(
	ctx context.Context,
	domainName, repoName, format, namespace, name, version string,
) (*PackageVersion, error)

DescribePackageVersion returns a specific version of a package. As with DescribePackage, stub entries are created on demand.

func (*InMemoryBackend) DescribeRepository

func (b *InMemoryBackend) DescribeRepository(ctx context.Context, domainName, repoName string) (*Repository, error)

DescribeRepository returns a repository by domain and name.

func (*InMemoryBackend) DisassociateExternalConnection

func (b *InMemoryBackend) DisassociateExternalConnection(
	ctx context.Context,
	domainName, repoName, connectionName string,
) (*Repository, error)

DisassociateExternalConnection removes an external connection from a repository.

func (*InMemoryBackend) DisposePackageVersions

func (b *InMemoryBackend) DisposePackageVersions(
	ctx context.Context,
	domainName, repoName, format, namespace, name string,
	versions []string,
) (map[string]string, error)

DisposePackageVersions moves specified versions of a package to the Disposed status.

func (*InMemoryBackend) GetAssociatedPackageGroup

func (b *InMemoryBackend) GetAssociatedPackageGroup(
	ctx context.Context,
	domainName, format, namespace, name string,
) (*PackageGroup, error)

GetAssociatedPackageGroup returns the most specific package group associated with a package.

func (*InMemoryBackend) GetDomainPermissionsPolicy

func (b *InMemoryBackend) GetDomainPermissionsPolicy(
	ctx context.Context, domainName string,
) (*DomainPermissionsPolicy, error)

GetDomainPermissionsPolicy retrieves the permissions policy for a domain. Returns ErrNotFound if the domain does not exist or if no policy has been set.

func (*InMemoryBackend) GetExternalConnections

func (b *InMemoryBackend) GetExternalConnections(
	ctx context.Context, domainName, repoName string,
) []ExternalConnection

GetExternalConnections returns a copy of the external connections for a repository.

func (*InMemoryBackend) GetPackageVersionAsset

func (b *InMemoryBackend) GetPackageVersionAsset(
	ctx context.Context,
	domainName, repoName, format, namespace, name, version, asset string,
) ([]byte, error)

GetPackageVersionAsset returns the content of an asset previously uploaded via PublishPackageVersion.

func (*InMemoryBackend) GetPackageVersionReadme

func (b *InMemoryBackend) GetPackageVersionReadme(
	ctx context.Context,
	domainName, repoName, format, namespace, name, version string,
) (string, error)

GetPackageVersionReadme is a stub that returns empty README content.

func (*InMemoryBackend) GetRepositoryPermissionsPolicy

func (b *InMemoryBackend) GetRepositoryPermissionsPolicy(
	ctx context.Context,
	domainName, repoName string,
) (*RepositoryPermissionsPolicy, error)

GetRepositoryPermissionsPolicy retrieves the permissions policy for a repository.

func (*InMemoryBackend) ListAllowedRepositoriesForGroup

func (b *InMemoryBackend) ListAllowedRepositoriesForGroup(
	ctx context.Context,
	domainName, pattern string,
) ([]string, error)

ListAllowedRepositoriesForGroup is a stub returning allowed repositories for a package group.

func (*InMemoryBackend) ListAssociatedPackages

func (b *InMemoryBackend) ListAssociatedPackages(ctx context.Context, domainName, pattern string) ([]*Package, error)

ListAssociatedPackages lists packages associated with a package group.

func (*InMemoryBackend) ListDomains

func (b *InMemoryBackend) ListDomains(ctx context.Context) []*Domain

ListDomains returns all domains sorted by name.

func (*InMemoryBackend) ListPackageGroups

func (b *InMemoryBackend) ListPackageGroups(ctx context.Context, domainName, prefix string) ([]*PackageGroup, error)

ListPackageGroups returns all package groups in a domain, optionally filtered by prefix.

func (*InMemoryBackend) ListPackageVersionAssets

func (b *InMemoryBackend) ListPackageVersionAssets(
	ctx context.Context,
	domainName, repoName, format, namespace, name, version string,
) ([]AssetInfo, error)

ListPackageVersionAssets lists the assets actually uploaded to a package version via PublishPackageVersion.

func (*InMemoryBackend) ListPackageVersionDependencies

func (b *InMemoryBackend) ListPackageVersionDependencies(
	ctx context.Context,
	domainName, repoName, format, namespace, name, version string,
) ([]map[string]any, error)

ListPackageVersionDependencies is a stub returning empty dependencies.

func (*InMemoryBackend) ListPackageVersions

func (b *InMemoryBackend) ListPackageVersions(
	ctx context.Context,
	domainName, repoName, format, namespace, name string,
) ([]*PackageVersion, error)

ListPackageVersions lists all versions of a package in a repository.

func (*InMemoryBackend) ListPackages

func (b *InMemoryBackend) ListPackages(
	ctx context.Context, domainName, repoName, format, namespace string,
) ([]*Package, error)

ListPackages lists packages in a repository.

func (*InMemoryBackend) ListRepositories

func (b *InMemoryBackend) ListRepositories(ctx context.Context) []*Repository

ListRepositories returns all repositories across all domains, sorted by name.

func (*InMemoryBackend) ListRepositoriesInDomain

func (b *InMemoryBackend) ListRepositoriesInDomain(ctx context.Context, domainName string) ([]*Repository, error)

ListRepositoriesInDomain returns all repositories in a domain, sorted by name. Returns ErrNotFound if the domain does not exist.

func (*InMemoryBackend) ListSubPackageGroups

func (b *InMemoryBackend) ListSubPackageGroups(
	ctx context.Context,
	domainName, pattern string,
) ([]*PackageGroup, error)

ListSubPackageGroups returns sub-package groups of a given package group pattern.

func (*InMemoryBackend) ListTagsForResource

func (b *InMemoryBackend) ListTagsForResource(ctx context.Context, resourceARN string) (map[string]string, error)

ListTagsForResource returns tags for a resource by ARN.

func (*InMemoryBackend) PublishPackageVersion

func (b *InMemoryBackend) PublishPackageVersion(
	ctx context.Context,
	domainName, repoName, format, namespace, name, version string,
	asset AssetInfo,
) (*PackageVersion, error)

PublishPackageVersion creates or updates a package version in the backend and upserts the uploaded asset (by name) into its Assets list. Unlike DescribePackageVersion's auto-create fallback, this is the real entry point AWS clients use to create a version, so it validates the repository exists first.

func (*InMemoryBackend) PutDomainPermissionsPolicy

func (b *InMemoryBackend) PutDomainPermissionsPolicy(
	ctx context.Context, domainName, document string,
) (*DomainPermissionsPolicy, error)

PutDomainPermissionsPolicy stores a permissions policy for a domain.

func (*InMemoryBackend) PutPackageOriginConfiguration

func (b *InMemoryBackend) PutPackageOriginConfiguration(
	ctx context.Context,
	domainName, repoName, format, namespace, name, publish, upstream string,
) (*Package, error)

PutPackageOriginConfiguration sets a package's publish/upstream origin restrictions and persists the (possibly newly created) package record. publish/upstream default to "ALLOW" when the caller passes an empty string, matching an unconfigured package.

func (*InMemoryBackend) PutRepositoryPermissionsPolicy

func (b *InMemoryBackend) PutRepositoryPermissionsPolicy(
	ctx context.Context,
	domainName, repoName, document string,
) (*RepositoryPermissionsPolicy, error)

PutRepositoryPermissionsPolicy stores a permissions policy for a repository.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns the AWS region this backend is configured for.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all stored resources, closing Tags on each domain, repository, and package group.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads backend state from a JSON snapshot. It implements persistence.Persistable.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state to JSON. It implements persistence.Persistable.

func (*InMemoryBackend) TagResource

func (b *InMemoryBackend) TagResource(ctx context.Context, resourceARN string, kv map[string]string) error

TagResource adds or replaces tags on a resource by ARN.

func (*InMemoryBackend) UntagResource

func (b *InMemoryBackend) UntagResource(ctx context.Context, resourceARN string, tagKeys []string) error

UntagResource removes tags from a resource by ARN.

func (*InMemoryBackend) UpdatePackageGroup

func (b *InMemoryBackend) UpdatePackageGroup(
	ctx context.Context,
	domainName, pattern, description, contactInfo string,
) (*PackageGroup, error)

UpdatePackageGroup updates description or contact info of a package group.

func (*InMemoryBackend) UpdatePackageGroupOriginConfiguration

func (b *InMemoryBackend) UpdatePackageGroupOriginConfiguration(
	ctx context.Context,
	domainName, pattern string,
) (*PackageGroup, error)

UpdatePackageGroupOriginConfiguration is a stub that accepts origin config changes.

func (*InMemoryBackend) UpdatePackageVersionsStatus

func (b *InMemoryBackend) UpdatePackageVersionsStatus(
	ctx context.Context,
	domainName, repoName, format, namespace, name, targetStatus string,
	versions []string,
) (map[string]string, error)

UpdatePackageVersionsStatus updates the status of specified package versions.

func (*InMemoryBackend) UpdateRepository

func (b *InMemoryBackend) UpdateRepository(
	ctx context.Context, domainName, repoName, description string, upstreams []string,
) (*Repository, error)

UpdateRepository updates repository description or upstreams.

type Package

type Package struct {
	DomainName  string `json:"domainName"`
	DomainOwner string `json:"domainOwner"`
	Repository  string `json:"repository"`
	Format      string `json:"format"`
	Namespace   string `json:"namespace,omitempty"`
	Name        string `json:"name"`
	// OriginConfigPublish and OriginConfigUpstream mirror
	// PackageOriginRestrictions.Publish/Upstream ("ALLOW" or "BLOCK"), set via
	// PutPackageOriginConfiguration. Both default to "ALLOW", matching a package
	// that has never had its origin configuration explicitly set.
	OriginConfigPublish  string `json:"originConfigPublish,omitempty"`
	OriginConfigUpstream string `json:"originConfigUpstream,omitempty"`
	// contains filtered or unexported fields
}

Package represents an AWS CodeArtifact package (without versions).

type PackageGroup

type PackageGroup struct {
	CreatedTime time.Time  `json:"createdTime"`
	Tags        *tags.Tags `json:"tags,omitempty"`
	ARN         string     `json:"arn"`
	DomainName  string     `json:"domainName"`
	DomainOwner string     `json:"domainOwner"`
	Pattern     string     `json:"pattern"`
	Description string     `json:"description,omitempty"`
	ContactInfo string     `json:"contactInfo,omitempty"`
	// contains filtered or unexported fields
}

PackageGroup represents an AWS CodeArtifact package group.

type PackageVersion

type PackageVersion struct {
	PublishedAt time.Time `json:"publishedAt"`
	DomainName  string    `json:"domainName"`
	Repository  string    `json:"repository"`
	Format      string    `json:"format"`
	Namespace   string    `json:"namespace,omitempty"`
	PackageName string    `json:"packageName"`
	Version     string    `json:"version"`
	Status      string    `json:"status"`
	Revision    string    `json:"revision"`

	Assets []AssetInfo `json:"assets,omitempty"`
	// contains filtered or unexported fields
}

PackageVersion represents a single version of an AWS CodeArtifact package.

type Provider

type Provider struct{}

Provider implements service.Provider for AWS CodeArtifact.

func (*Provider) Init

Init initializes the CodeArtifact service backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type Repository

type Repository struct {
	CreatedTime          time.Time  `json:"createdTime"`
	Tags                 *tags.Tags `json:"tags,omitempty"`
	Name                 string     `json:"name"`
	ARN                  string     `json:"arn"`
	DomainName           string     `json:"domainName"`
	DomainOwner          string     `json:"domainOwner"`
	Description          string     `json:"description,omitempty"`
	AdministratorAccount string     `json:"administratorAccount"`
	Region               string     `json:"region"`
	UpstreamRepositories []string   `json:"upstreamRepositories,omitempty"`
}

Repository represents an AWS CodeArtifact repository.

The Tags field is backend-owned. Callers must treat the returned pointer as read-only; mutate tags only via TagResource / CreateRepository.

type RepositoryPermissionsPolicy

type RepositoryPermissionsPolicy struct {
	Document    string `json:"document"`
	Revision    string `json:"revision"`
	ResourceARN string `json:"resourceArn"`
	// contains filtered or unexported fields
}

RepositoryPermissionsPolicy represents a permissions policy attached to a repository.

Jump to

Keyboard shortcuts

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