Add the package_metadata.oci setting

What does this MR do and why?

Adds a package_metadata.oci section to gitlab.yml and Gitlab::PackageMetadata::OciSource, which reads it. Keys:

  • url: the registry, required to turn the source on.
  • username and password_file: optional credentials. A username needs a password_file that exists, is readable and is not empty.
  • token_hosts: optional hosts besides the registry's own that may receive them. An entry is host or host:port, always over HTTPS, and the port defaults to 443.

OciSource returns nil while the section is empty. An unknown key, a URL without a host, a username whose password_file is unset, not a string, missing, a directory, unreadable, not valid UTF-8 or empty, or a malformed token_hosts entry (a bad port included) raises an error naming the key, so a typo cannot turn the source off silently. The error never holds the file's contents; when the read itself fails, it names the operating system error class and never the path. A misconfiguration is logged with its error class.

Safe alone: nothing reads the source yet.

Part 2 of 7. Previous: feature/pmdb-oci-1-auth-challenge. Next: feature/pmdb-oci-3-client.

Related to #642401

How to set up and validate locally

bundle exec rspec ee/spec/lib/gitlab/package_metadata/oci_source_spec.rb

MR acceptance checklist

  • The specs that cover this slice pass at 6e7769ff4b: 546 examples in 12 spec files, 0 failures.
  • RuboCop reports no offenses on the changed files.

An AI coding assistant wrote this change. The assistant also ran RuboCop on the changed files and the specs above on a self-managed GitLab development instance on a test VM.

Edited by Andrew Dunn

Merge request reports

Loading
Loading