Skip to content

feat: support any OCI registry - #87

Merged
uniqueg merged 9 commits into
devfrom
feat/27-oci-registries-a
Nov 7, 2026
Merged

uniqueg merged 9 commits into
devfrom
feat/27-oci-registries-a

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Makes Pubgrade work with any OCI registry, such as Harbor. This is part A of #27; part B, the sidecar's availability check, was elixir-cloud-aai/Pubgrade-Sidecar#42, which closed elixir-cloud-aai/Pubgrade-Sidecar#41.

  • Prebuilt images (default mode): Pubgrade never talks to a registry. Image names with a registry host (e.g. harbor.example.org/project/app, or registry:8443/group/sub/app) are passed on to subscribers unchanged. New integration tests cover this.
  • Build mode, intermediate registry:
    • The registry comes from the chart values builds.registry.host (default docker.io) and builds.registry.namespace, via INTERMEDIATE_REGISTRY_HOST and INTERMEDIATE_REGISTRY_NAMESPACE.
    • Credentials come from builds.registry.existingSecret/key; by default this is the key intermediate_registry_token of builds.existingSecret, as before.
    • The free-form endpoints.builds.intermediate_registery_format still works and takes precedence.
  • Fixes:
    • Image names with a registry host or without a namespace used to break builds (name.split("/")[1]). They now build under their last name part.
    • Each build gets its own intermediate image. The tag is build-<build ID>; if the configured path has its own tag (e.g. ttl.sh's lifetime), the name gets a suffix derived from the build ID instead. Builds of images with the same name, including builds of other repositories, therefore no longer overwrite each other before signing.
    • Docker Hub credentials are stored under Docker's key https://index.docker.io/v1/. Before, they were stored under docker.io, which Kaniko doesn't look up.
    • The config file is now written with json.dump.
  • Signing: the signing workflow still logs in to Docker Hub only, so images built by Pubgrade are still published there, and their names must be Docker Hub names. This is documented. Image signing (Management of DCT Keys for Image Signing #25) stays separate.
  • Docs:
    • docs/deployment.md has a new section "Registries" and an upgrade note.
    • pubgrade/config.yaml comment, helm/values.yaml.
    • The submodule bump to Pubgrade-Sidecar's PR 42 includes the sidecar's Registries docs.

Closes #27

Verification

  • pytest --cov (unit + integration, mongomock): 625 passed, 100% coverage.

  • tests/chart.sh (Helm 3.22.1): passed. New checks cover the registry defaults, custom values, and builds.registry=null.

  • ruff check, ruff format --check, mypy: clean.

  • mkdocs build --strict: clean.

  • CI on 31092a6 (after merging dev): all checks passed, including Chart, Upgrade test, Docs and the image scans. There are no open code scanning alerts. Two CI fix iterations were needed: mypy narrowing in a new test, and a gitleaks allow marker on the base64 test token, following the repo's existing convention.

  • Not run locally: build mode end to end (Kaniko, the signing workflow on GitHub). It needs a cluster with ReadWriteMany storage and the signing secrets. The unit tests check that the build and the signing use the same intermediate image.

  • Review: round 1 with the adversarial and quality reviewer subagents. Fixed:

    • Shared intermediate images (medium).
    • Chart token env lost with builds.registry: null (medium).
    • Config comment (medium).
    • Shared helper.
    • Test of build and signing paths.
    • Quoting in the chart.

    In round 2 neither reviewer found medium or high issues. Added afterwards: a note to let running builds finish before an upgrade or a registry change, because the signing works out the intermediate image again when a build completes.

  • Sourcery: 3 findings, addressed in 0699880. Intermediate images with a fixed tag are now scoped to their build; the Docker Hub-only publication in build mode is documented (the signing workflow is outside this repository); the docstring is fixed. All threads are answered and resolved.

Declined review findings

  • Fail the chart if the Docker Hub default is used without a namespace: deployments that set intermediate_registery_format in their configuration keep the chart defaults and would break on upgrade. The docs say that Docker Hub needs a namespace.

  • Store the intermediate path on the build record, so that an upgrade or registry change during a build doesn't affect it: this is rare (a helm upgrade while builds run), it was the same before with the config setting, and the upgrade note now says to let builds finish first.

  • Rename create_dockerhub_config_file and drop its unused dockerhub_token parameter, and fail early if INTERMEDIATE_REGISTRY_TOKEN is unset: both are older than this change and outside its scope.

  • grep-based checks in tests/chart.sh: they follow the existing style of the script.

  • Add a correctly spelled alias for intermediate_registery_format: a separate change.

  • Validate INTERMEDIATE_REGISTRY_HOST, and limit id_length so that build tags stay within 128 characters: these are operator settings, and the defaults are fine.

Open questions

None.

🤖 Generated with Claude Code

uniqueg and others added 4 commits November 7, 2026 23:03
The intermediate registry of builds comes from
endpoints.builds.intermediate_registery_format, if set, otherwise from
INTERMEDIATE_REGISTRY_HOST (Docker Hub by default) and
INTERMEDIATE_REGISTRY_NAMESPACE. Images whose name has a registry host
or no namespace are built under their last name part; before, a host
broke the build. Credentials for Docker Hub are stored under Docker's
key for it. Publishing prebuilt images of any registry is tested.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
builds.registry sets the host and namespace of the intermediate
registry, and optionally a Secret and key with its credentials. The
docs describe registries, and that signing still publishes to Docker
Hub.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Address review findings: unless the intermediate path has a tag, a
build pushes to and the signing pulls from the tag build-<build ID>,
so that builds of images with the same name no longer replace each
other's image. The chart keeps the registry defaults if
builds.registry is null and quotes Secret names and keys. The
configuration and docs name the environment variables.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bump Pubgrade-Sidecar to the merge of its PR 42, whose docs describe
registries, and link to them. Clarify the intermediate image example.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Define the intermediate image path and registry credential lookup, then use them consistently when creating builds, writing Docker credentials, and triggering signing.

  • pubgrade/modules/endpoints/builds.py L79-162, L751-765 (+4 small edits)

Configuration

Expose the intermediate registry host, namespace, and credentials through Helm values and pass them to Pubgrade when builds are enabled.

  • helm/templates/pubgrade/deployment.yaml L69-80
  • helm/values.yaml L11-29

Document the environment variables and precedence used to choose the intermediate registry path.

  • pubgrade/config.yaml L131-136

Documentation

Explain registry support, intermediate registry configuration, Docker Hub signing limits, and the upgrade considerations for running builds.

  • docs/deployment.md L144-178, L247-261

Tests

Verify Helm renders the default and custom intermediate registry settings, including the null-values fallback.

  • tests/chart.sh L76-102

Cover prebuilt images with registry-qualified names and the intermediate-image path, authentication, and build-to-signing consistency.

  • tests/integration/test_api.py L674-703
  • tests/pubgrade/endpoints/test_builds.py L570-594, L1199-1222, L2198-2303 (+2 small edits)

Lock files and vendored code

Update the Pubgrade-Sidecar submodule to include its registry availability-check and documentation changes.

  • external/pubgrade-sidecar L1

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@read-the-docs-community

read-the-docs-community Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 Pubgrade | 🛠️ Build #35725271 | 📁 Comparing 31092a6 against latest (3f501b7)

  🔍 Preview build  

5 files changed · ± 5 modified

± Modified

@uniqueg
uniqueg marked this pull request as ready for review November 7, 2026 22:17
@uniqueg
uniqueg requested a review from akash2237778 as a code owner November 7, 2026 22:17

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="pubgrade/modules/endpoints/builds.py" line_range="131-132" />
<code_context>
+        The image in the intermediate registry, with its tag.
+    """
+    path = intermediate_registry_format().format(image_basename(image))
+    if ":" not in path.rsplit("/", 1)[-1]:
+        path = f"{path}:build-{build_id}"
+    return path
+
</code_context>
<issue_to_address>
**Victim builds can sign attacker images**

When the configured intermediate format includes a fixed tag and callers for different repositories can choose the same image basename, an authorized caller can build an image with the same basename as another repository and overwrite that shared intermediate reference; `build_completed` recomputes the same reference and the signing workflow can sign the caller’s image as the other repository’s output.

Scope every intermediate reference to its build (or repository) even when the configured format includes a tag, and retain any required expiry semantics separately.
</issue_to_address>

### Comment 2
<location path="pubgrade/modules/endpoints/builds.py" line_range="853" />
<code_context>
-                data["images"][0]["name"].split("/")[1].split(":")[0]
-            ),
+            pull_tag=intermediate_image(data["images"][0]["name"], build_id),
             push_tag=data["images"][0]["name"],
         )
     except Exception:
</code_context>
<issue_to_address>
**Non-Docker-Hub builds fail publication**

When builds are enabled and the requested final image name uses a non-Docker-Hub registry host, `build_completed` passes the requested image name as `push_tag`, while `trigger_signing_image` supplies only Docker Hub credentials; for a name such as `harbor.example.org/project/app:1`, the signing workflow cannot authenticate to that destination, so publication fails and the build does not complete successfully.

Either make the signing workflow authenticate to the requested destination registry, or ensure build-mode requests publish to a Docker Hub image name and document that constraint.
</issue_to_address>

### Comment 3
<location path="pubgrade/modules/endpoints/builds.py" line_range="745" />
<code_context>
-    )
     with open(config_file_location, "w") as config_file:
-        config_file.write(template_config_file)
+        json.dump({"auths": {registry: {"auth": token}}}, config_file)


</code_context>
<issue_to_address>
**Registry writer docs name Docker Hub**

`create_dockerhub_config_file` now writes credentials for whichever intermediate registry is configured, but its docstring still describes a Docker Hub config file and Docker Hub token; callers reading the API documentation are misled about the file’s purpose.

Update the docstring to describe the intermediate registry credentials and clarify that the `dockerhub_token` parameter is unused here.
</issue_to_address>

Linked issues

#27 Make Pubgrade Harbor Compatible · 1 of 1 met

# Requirement Status Notes
1 Make Pubgrade Harbor compatible ✅ Met Prebuilt image names are forwarded unchanged, and builds can use a configurable intermediate registry; sidecar rollout support is included through the submodule update.

#41 feat: roll out images from any OCI registry · 0 of 5 met · 5 to check by hand

# Requirement Status Notes
1 Check image availability through the OCI distribution API, including Docker Hub and anonymous bearer-token challenges 👀 Check by hand (manual process) Inspect the updated sidecar submodule revision to confirm it implements the OCI API and bearer-token handling.
2 Allow optional private-registry credentials from a Kubernetes Secret configured through chart values 👀 Check by hand (manual process) Inspect the updated sidecar submodule revision to confirm its Secret and chart-values support.
3 Keep Docker Hub as the default for images without a registry host 👀 Check by hand (manual process) Inspect the updated sidecar submodule revision to confirm its fallback for unqualified image names.
4 Add API unit tests and a CI test against a generic OCI registry 👀 Check by hand (manual process) Check the updated sidecar submodule revision and its CI configuration for the requested tests.
5 Document the API, deployment values, and upgrade considerations 👀 Check by hand (manual process) Inspect the updated sidecar submodule documentation to confirm it covers the API, values, and upgrade note.

Sourcery assessment

Needs a human reviewer. 2 findings to address first, and if the registry path or credentials resolve incorrectly, a build can push to an unintended location or the signing workflow can pull the wrong intermediate image and publish it under the requested Docker Hub name. Reverting stops future builds, but cannot retract images already pushed to either registry.

Blocking findings: pubgrade/modules/endpoints/builds.py:132, pubgrade/modules/endpoints/builds.py:853


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread pubgrade/modules/endpoints/builds.py Resolved
Comment thread pubgrade/modules/endpoints/builds.py Resolved
Comment thread pubgrade/modules/endpoints/builds.py Resolved
Address review findings: with a tag in the intermediate path (e.g., a
lifetime on ttl.sh), the image name gets a suffix derived from the
build ID, so that builds of other repositories can't replace an image
before it is signed. Docs: build mode needs Docker Hub image names, as
the signing workflow publishes to Docker Hub only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linked issues

#27 Make Pubgrade Harbor Compatible · 0 of 1 met

# Requirement Status Notes
1 Make Pubgrade compatible with Harbor and other OCI registries. 🟡 Partly met Prebuilt images retain their registry host, and builds can push to a configurable intermediate OCI registry, but the signing workflow still publishes built images to Docker Hub only.

#41 feat: roll out images from any OCI registry · 5 of 5 met

# Requirement Status Notes
1 Check image availability through the OCI distribution API, including anonymous bearer-token challenges. ✅ Met The sidecar submodule is updated to the merge of PR 42, which closed this issue.
2 Support optional private-registry credentials from a Kubernetes Secret. ✅ Met Implemented in the sidecar update to PR 42.
3 Keep Docker Hub as the default for images without a registry host. ✅ Met Implemented in the sidecar update to PR 42.
4 Add API tests and a CI test against a generic OCI registry. ✅ Met The sidecar submodule is updated to PR 42, which closed this issue.
5 Document the API, deployment values, and upgrade considerations. ✅ Met The deployment guide links to the sidecar's Registries documentation; the sidecar submodule is updated to PR 42.

Comment thread docs/deployment.md Resolved
@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (3f501b7) to head (31092a6).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev       #87   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           17        17           
  Lines         1497      1518   +21     
=========================================
+ Hits          1497      1518   +21     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg merged commit 55b235f into dev Nov 7, 2026
46 checks passed
@uniqueg
uniqueg deleted the feat/27-oci-registries-a branch November 7, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: roll out images from any OCI registry Make Pubgrade Harbor Compatible

1 participant