Sets a package's publish/upstream origin-control restrictions, matching
AWS's documented behavior that this operation can create the package
(with no versions) when it doesn't exist yet, so a caller can lock a
package down before anything is ever published to it.
DescribePackage now reflects a stored configuration instead of the
fixed ALLOW/BLOCK defaults it previously always returned, and
PublishPackageVersion rejects a publish with ConflictException once a
package's origin configuration sets publish to BLOCK, the one publish
path this operation can actually gate since PublishPackageVersion only
ever accepts the generic format. Maven/npm/pypi publish through their
own native wire protocols and are not yet gated by this setting,
documented as a known limitation.
The format/namespace coordinate validation shared with DescribePackage
is extracted into one helper instead of being duplicated a second time.
clear() (the Resettable reset path) now also clears the new store; it
previously left an origin-config-only package (no versions) visible to
DescribePackage after a reset that wiped everything else.
DescribePackage's existence check for an origin-config-only package now
short-circuits before the sidecar/generic check runs at all: for a
container-backed format that check would otherwise start the real
Maven/npm/pypi sidecar container just to answer a describe for a
package nothing was ever actually published to.
DeletePackage now agrees with DescribePackage on all of this instead of
drifting from it. Its deletedPackage.originConfiguration reports the
restrictions that were actually stored, not a hard-coded ALLOW/BLOCK;
it clears the stored configuration as part of the delete, so a deleted
package cannot resurrect as a zero-version one on the next
DescribePackage; and it now recognizes an origin-config-only package
(no version ever published) as something it can delete, rather than
404ing on a package DescribePackage itself reports as existing.
DeletePackage's own namespace/format validation, previously a second
inline copy of the same rules, now goes through the shared helper too.
A rejected PutPackageOriginConfiguration now also has a test asserting
an invalid/missing upstream value alone is rejected (the prior tests
only exercised publish) and that a rejection, on either a package that
didn't exist yet or one with a prior configuration, changes nothing.
deleteRepository now also removes any packageOriginConfigs entries
under that repository: unlike sidecarContainerIds, which already gets
a fresh id on every creation specifically so a repository recreated
under the same name never inherits the previous one's sidecar content,
packageOriginConfigs was keyed purely by name, so a recreated
repository would otherwise inherit a prior package's restrictions,
including a publish:BLOCK the new repository's owner never set.
DeletePackage deletes a package and every one of its versions, matching
PackageSummary's own field name (package, not name, confirmed against the API
reference) in the deletedPackage response. A nonexistent package answers
ResourceNotFoundException instead of silently succeeding.
Existence and deletion go where the package actually lives: stored
generic-format versions and their asset bytes for generic, and each format's
sidecar for maven, npm, and pypi. Validates package and namespace shape, and
requires or rejects a namespace per format, the same boundary describePackage
already enforces, before touching repository or sidecar state.
Synchronized like every other mutating method on this service, so a publish
and a delete racing the same generic package cannot interleave. Within one
generic version's own delete, its metadata record is removed before its asset
bytes are cleaned up, so a cleanup failure on one asset can never leave a
surviving record pointing at bytes that are now gone; the failure is logged
and the rest of the package's assets still get cleaned up.
Verdaccio and Reposilite can each remove a whole package in one call,
confirmed against live containers: Verdaccio needs the packument's own _rev
appended as npm's real unpublish protocol does (a bare DELETE with no revision
is not a route at all), Reposilite removes everything under the group/artifact
directory in a single DELETE. pypiserver has no single whole-package route,
but its own management endpoint (POST / with :action=remove_pkg) does delete
a named version for real, confirmed live against the pinned v2.4.2 image:
every version is listed first through the same image's PyPI JSON API
endpoint, then each file removed under its own, unnormalized name (an sdist
and a wheel of the same release can legitimately differ there, so deleting by
one shared name alone could silently leave the other file behind).
RepositorySidecarManager.deletePackage's default still throws
UnsupportedOperationException for a sidecar that genuinely cannot do this,
and the service turns that into a documented InternalServerException rather
than claiming a success it cannot back up or leaving an unhandled 500.
DescribePackage returns a package's format, namespace, name, and origin
controls, and answers ResourceNotFoundException for a package that does not
exist. Existence is checked where the package actually lives: stored
generic-format package versions for generic, and each format's sidecar for
maven, npm, and pypi. A package whose name merely starts with another's name
does not match it.
Origin controls are reported as publish ALLOW and upstream BLOCK, the default
CodeArtifact assigns to a package whose first version was published directly.
Floci never ingests packages from upstream and does not store origin controls,
so these values are fixed.
For maven, npm, and pypi the existence check starts that repository's sidecar
if it is not already running, the same side effect the asset bridge has.
RepositorySidecarManager gains packageExists, implemented by each sidecar client.
Reposilite's own redeployment:false setting rejects a redeploy to an
existing GAV path unconditionally, even when the new content is
byte-identical to what is already there (confirmed against a real
instance). AWS's own CodeArtifact docs ("Overwriting package assets"
in the packages overview) say a republish of an asset whose content
matches what is already published succeeds because the operation is
idempotent; only a genuine content mismatch is a real conflict.
Reposilite has no content-aware mode of its own, so this fetches the
existing artifact first and short-circuits to a 200 on an exact match
rather than ever sending Reposilite a PUT it would reject regardless
of whether the retry was actually harmless.
Two follow-ups hectorvent flagged on #4619, approved but marked as
separate-PR material:
Compares an existing asset's persisted SHA-256 instead of reading its
bytes. The hash is normal metadata (not @JsonIgnore like the content
field), so this needs no disk read, no in-memory-store lookup, and no
special case for a backing file that happens to be missing - a stored
hash never "goes missing" the way a file can, and a genuinely different
republish still conflicts even when the file is gone, closing a gap the
previous byte-comparison approach had.
Extends the idempotent-retry allowance to an already-Published version.
AWS's "Overwriting package assets" rule isn't scoped to Unfinished, and
the terminal publish call (the one that actually finishes a version) is
the likeliest one a client retries after a dropped response. A brand-new
asset name against a Published version still always conflicts; only a
byte-identical replay of an asset that's already there is idempotent.
PublishPackageVersion silently overwrote a generic-format asset's stored
bytes whenever the same asset name was republished to an Unfinished
package version, with no comparison against what was already there. AWS's
own docs ("Overwriting package assets" in the CodeArtifact packages
overview) say a republish is only rejected when the content actually
differs from what's already stored; byte-identical content succeeds
idempotently. Compares the new upload against the existing asset's real
bytes (read the same way GetPackageVersionAsset does, not the in-memory
PackageAsset.content field, which is @JsonIgnore and unreliable after a
reload) and now returns ConflictException on a genuine mismatch instead of
silently replacing the content.
GetRepositoryEndpoint for format=npm now returns a working registry
endpoint: real npm/yarn/pnpm clients can publish to and install from it,
proxied straight through to a real Verdaccio instance rather than
reimplemented. Every request needs Authorization: Bearer <token> from
GetAuthorizationToken, matching npm's own _authToken config and, unlike
Maven's HTTP Basic support, Bearer only.
Unlike Reposilite, Verdaccio has no native concept of multiple named
repositories inside one instance, so each CodeArtifact repository gets
its own container instead of sharing one, started lazily on first use
and identified by a fresh id assigned at CreateRepository time so a
repository deleted and recreated under the same name never inherits the
previous one's packages. Each container is started with
VERDACCIO_PUBLIC_URL set to that repository's own proxy URL so package
metadata it returns (dist.tarball) points back through Floci instead of
the container's own internal, client-unreachable address.
VerdaccioSidecarManager implements the RepositorySidecarManager
interface CodeArtifactService already generalized DeleteRepository's
cleanup over, so a deleted repository's Verdaccio container is stopped
and removed the same generic way Maven's Reposilite storage is released.
The per-key container lifecycle (map of running containers, per-key
start lock, health poll, restart-on-unhealthy, stop-all) has nothing
Verdaccio-specific in it, so it is pulled out into PerKeyContainerPool
for a future per-repository sidecar to reuse directly.
CodeArtifactNpmDataPlane is a raw streaming proxy rather than a JAX-RS
controller, since npm's wire protocol has no fixed path shape the way
Maven's GAV layout does; Verdaccio already speaks that protocol
correctly, so this only needs to authenticate the request and forward
it. The publish/fetch integration test replays a real request the npm
CLI sent during manual verification, captured with a tiny Node.js
capture server, so it exercises the exact envelope shape (including a
real gzip tarball attachment) npm publish actually produces; the full
round trip was additionally verified by hand with the real npm CLI
against a live Floci instance.
DeleteRepository never cleaned up the Reposilite-side storage of a deleted
repository; it was left behind, wasting space over a long-running process.
Reposilite has no bulk-delete endpoint, but DELETE on a path recursively
removes everything under it in one call, so this deletes each of the
repository's top-level entries before removing it from the shared settings
list, verified against a live instance. Order matters: the repository must
stay registered while its files are deleted, since Reposilite 404s every
path, including DELETE, for an id absent from its settings.
Release is best-effort: the CodeArtifact-side metadata delete already
committed by the time it runs, matching real CodeArtifact's own
DeleteRepository (synchronous, always succeeds once the repository exists).
A sidecar that is unreachable must not turn an already-successful delete
into a 500, and must not leave the repository stuck, since a retry would
just 404 against the already-deleted record.
Introduces RepositorySidecarManager, a small interface every per-format
sidecar can implement, and CodeArtifactSidecarRegistry, which discovers
implementations via CDI. CodeArtifactService.deleteRepository releases
storage generically over whatever formats a repository has sidecar ids
for, so a future format's sidecar needs no change here. Reposilite is the
first and only implementation for now; CodeArtifactRepository's
mavenRepositoryId field becomes a sidecarContainerIds map for the same
reason.
GetRepositoryEndpoint for format=maven now returns a URL real Maven clients
(mvn deploy, mvn dependency:get, Gradle) can publish to and resolve from
directly, backed by a shared Reposilite sidecar container started lazily on
first use. A CodeArtifact repository maps to its own Reposilite repository,
provisioned automatically and never reused even across delete/recreate of a
same-named repository, so a fresh repository can never inherit a previous
one's artifacts.
Adds GetAuthorizationToken (a token scoped to a domain, with the 900-43200s
custom range; 0 falls back to 12 hours) and requires it on every Maven proxy
request, either as the password of HTTP Basic credentials, the form AWS's
Maven guide configures with username aws, or as a Bearer token. Maven
requests are not SigV4-signed, so the region and account come from the token.
Also enforces AWS's 5 GB asset size quota on the Maven endpoint, matching the
existing PublishPackageVersion check. Artifacts do not survive a Floci
restart; the service page documents this as a known limitation.
AWS returns ResourceNotFoundException (404) when DeleteDomain targets a
domain that does not exist, even though the API reference leaves it out
of the operation's error list. Keep that behaviour, pin it with unit and
integration tests, and note it in the docs and next to requireDomain.
Closes#4000
Every ConflictException, ResourceNotFoundException, and ServiceQuotaExceededException
the service threw carried a message only, but the wire model declares
resourceId/resourceType on all three, and the AWS SDK exposes them as typed
accessors. Populate them consistently using the resource's locally-unique name
(domain name, repository name, package version, or asset name) as resourceId.
Populating resourceId this way exposed a real crash: Map.of() rejects null
values, so any request missing a required identifier (domain, repository,
package, packageVersion, asset) turned what used to be a wrong-status
ResourceNotFoundException into a raw NullPointerException / HTTP 500. Fixed
by validating required identifiers up front (returning ValidationException,
matching AWS) and by making the extendedData-building helper itself
null-safe against a missing resourceId, so no single overlooked call site
can reintroduce a 500.
CreateDomain and CreateRepository accepted an unlimited number of domains and
repositories, but AWS caps an account at 10 domains per Region and a domain at
1,000 repositories, returning ServiceQuotaExceededException once reached.
Adds PublishPackageVersion, DescribePackageVersion, and GetPackageVersionAsset
for CodeArtifact's generic package format, matching AWS's own wire restriction
that PublishPackageVersion accepts only the generic format. Includes real
asset hashing (MD5, SHA-1, SHA-256, SHA-512), SHA-256 integrity verification
against the caller's x-amz-content-sha256 header, correct Unfinished/Published
status transitions, and the documented AWS quotas for this action (350 assets
per version, 5 GB max asset size), all returning ServiceQuotaExceededException
when exceeded.
Asset bytes are kept out of the JSON/WAL-backed package-version store
(@JsonIgnore on PackageAsset.content) and instead go through a dedicated
asset store, a disk file in persistent/hybrid/wal mode or a side map in
memory mode, the same split S3Object/S3Service already uses for object
bytes. Without this, a publish rewrote every asset of every package version
on disk each time, growing quadratically under this action's own
350-asset/5GB quotas. The asset name is also validated against the wire
model's AssetName pattern (no control characters), not just its length,
since it is echoed back verbatim in the X-AssetName response header on
GetPackageVersionAsset.
Verified against the real botocore service-2.json wire model and the AWS
CodeArtifact User Guide (including its PDF for the quotas table, since the
HTML quotas page is JS-rendered). Live-verified with the real AWS CLI and
the AWS SDK for Java v2 against a running Floci instance, including an exact
byte-for-byte asset round-trip and the real ConflictException when
republishing an already-Published version.
Floci had zero CodeArtifact support: no service package, no docs, nothing.
Any terraform apply touching aws_codeartifact_domain, aws_codeartifact_repository,
or either permissions-policy resource failed outright. This adds the full
CodeArtifact control plane: domain and repository CRUD, resource policies with
optimistic-locking revisions, tags, and the fixed set of real AWS-hosted
external (upstream) connections (public:npmjs, public:pypi, public:maven-central,
etc.).
Package publish/fetch endpoints per format (npm, PyPI, Maven, NuGet, generic)
are intentionally out of scope here: this closes the terraform apply gap, not
real package serving.
ListTagsForResource (POST /v1/tags?resourceArn=) is CodeArtifact's one tag
operation that addresses the resource with a query parameter on the bare path
rather than a path segment, unlike every other V1TagsController/SharedTagsController
handler. That method lives on V1TagsController itself rather than the shared
AbstractTagsController base: SharedTagsController (mounted at /tags) already
declares its own bare POST (tagResourceByBody, for TagResource), so a bare POST
on the shared base collides with it and Quarkus refuses to start. CodeArtifact's
handler is @V1Tags-qualified and only ever registered against V1TagsController,
so the method belongs there. core/common stays service-free: CodeArtifactTagHandler
registers itself as a bean the same way MskTagHandler does, and TagHandler gained
a default for the lowercase key/value entry names CodeArtifact uses instead of
AWS's usual capitalized Key/Value.
Known, documented limitations (see docs/services/codeartifact.md): no cycle
detection across upstream chains, no referential-integrity check when deleting
a repository other repositories reference as an upstream, and no authorization
check on cross-account domainOwner addressing (consistent with Floci's opt-in
IAM enforcement elsewhere).
Verified against the real botocore codeartifact service-2.json (protocol, exact
querystring vs. body placement per operation, exact ARN format, epoch-seconds
timestamps, real error shapes) and the live AWS API docs for behavioral rules
not in the wire model (DeleteDomain blocked while repositories exist, the real
fixed external-connection name/format list, PutDomainPermissionsPolicy's
all-body field placement vs. the sibling repository operation's querystring
placement).
Live-verified three ways:
- Unit tests including a concurrent-create race test proving the synchronized
guard actually holds under contention, plus full-stack QuarkusTest/RestAssured
integration tests.
- A real terraform init/apply/plan/destroy cycle against a running Floci
instance, independently confirming destroy actually tore the domain down via
a follow-up describe-domain call.
- A live AWS SDK v2 Java test exercising the real CodeartifactClient against a
live instance.