Repository navigation
Description
Note
Draft: this is part of the multi-repository backup/restore work in #2358 and #730. The details may change before #2358 is agreed.
What
Remove the flags from oras backup and oras restore that hold a single, global setting for the registry. Once these commands work across several registries (#730, #2358, #2364), one global setting is either ambiguous or unsafe:
- A backup can read from several source registries.
- A restore with a rules file (Mode 3 in docs: record full references and support multiple registries in backup proposal #2358) can push to several target registries.
With a global flag it is unclear which registry --plain-http or --ca-file is meant for. Credentials, client certificates and headers would also be sent to every registry the command talks to.
Today registryCredentialTransport (cmd/oras/internal/option/remote.go) already keeps client certificates and custom headers from following redirects to other hosts. But every registry client in one command is built from the same option.Remote, so each one gets the same credentials, headers and certificate.
Both commands are [Experimental], and #2364 already brings a breaking change, so all of these flags go in that same release instead of being deprecated one at a time.
Today both commands embed option.Remote and call opts.EnableDistributionSpecFlag() (cmd/oras/root/backup.go, cmd/oras/root/restore.go), so they get every flag below.
Flags to remove
| Flag | Why it does not fit multiple registries |
|---|---|
-u, --username |
One set of credentials for every registry |
-p, --password |
Same |
--identity-token |
Same |
--password-stdin |
Same |
--identity-token-stdin |
Same |
-H, --header |
Custom headers, possibly Authorization, go to every registry |
--cert-file |
One mTLS client identity for every registry |
--key-file |
Same |
--ca-file |
Unclear which registry it is meant for; per-host trust belongs in certs.d |
--insecure |
Turns off TLS verification for every registry |
--plain-http |
Unclear which registry it is meant for; downgrades every registry to HTTP |
--distribution-spec |
Registries differ in referrers API support (v1.1-referrers-api / v1.1-referrers-tag) |
Flags to keep
| Flag | Why it is fine |
|---|---|
--registry-config |
The auth file is keyed by host |
--resolve |
Each entry names its host:port |
Where per-registry settings come from instead
| Removed flag(s) | Replacement | Available today? |
|---|---|---|
-u, -p, --identity-token, --*-stdin |
oras login / credential store, --registry-config |
Yes |
--ca-file, --cert-file, --key-file |
certs.d |
Only with ORAS_EXPERIMENTAL_CONTAINERS_CONFIG=1 |
--insecure |
registries.conf insecure = true |
Only with ORAS_EXPERIMENTAL_CONTAINERS_CONFIG=1 |
--distribution-spec |
Auto-detection per registry, or registries.conf referrers-api |
Auto-detection yes; referrers-api only with the env var |
--plain-http |
None for hosts other than localhost | No |
-H, --header |
None. Out of scope for now | No |
Prerequisites
- Per-host plain HTTP.
Remote.isPlainHTTP(remote.go) only looks at the--plain-httpflag and the localhost auto-detect.registries.confinsecuremaps toTransport.Insecure(skip TLS verification), not to plain HTTP. Without a per-host way to choose plain HTTP, users of an HTTP registry on a host other than localhost (e.g.registry.lan:5000) can no longer usebackup/restore. Options: mapregistries.confinsecureto plain HTTP the way podman does, or add a separate per-host setting. - The containers config gate. The per-host TLS settings (
certs.d,registries.conf) are only read whenORAS_EXPERIMENTAL_CONTAINERS_CONFIGis set (containers_config.go). Decide whetherbackup/restorealways read them, or whether the removal waits until containers config is no longer experimental. Otherwise users of private CAs and mTLS have no way forward. Update docs: record full references and support multiple registries in backup proposal #2358.Done: docs: record full references and support multiple registries in backup proposal #2358 now drops these flags, with a Removed Flags table, the replacements and these prerequisites under Authentication Handling.
Scope
- Stop registering the flags above on
backupandrestore.Remote.ApplyFlagsWithPrefixregisters all of them at once, so this needs a mode onoption.Remoteor a separate option type that registers only--registry-configand--resolveand skipsapplyStdinFlags. - Make
Remote.Parsework when the credential, cert and header flags are not registered, so it doesn't read stdin or prompt for a password. - Remove
opts.EnableDistributionSpecFlag()from both commands. - Give a clear error for the removed flags, pointing to
oras login,--registry-configandregistries.conf/certs.d, instead of cobra's generic "unknown flag". - Update the help text and examples for both commands: drop the
--insecureand--plain-httpexamples, and add anoras loginexample. - Update the docs to list the removed flags and what to use instead. (The proposal in docs: record full references and support multiple registries in backup proposal #2358 is already updated.)
- Mark it as a breaking change in the release notes.
- Update the e2e tests:
- Most need no changes. The suite logs in during setup (
test/e2e/internal/utils/init.go) and uses localhost registries, which are auto-detected as plain HTTP. - The two
--distribution-spectests intest/e2e/suite/command/backup.go(v1.1-referrers-api/v1.1-referrers-tag) need another way to force each mode (e.g.registries.confreferrers-api) or should be removed. - Add a test that the removed flags are rejected.
- Most need no changes. The suite logs in during setup (
- Unit tests set
PlainHTTPon the repository directly (cmd/oras/root/backup_test.go), so they should not need changes.
Not in scope
- Per-host flag syntax (e.g.
--header host=Name:Value). This can be added later if there is demand. - Changing these flags on any other command.
Open questions
- Per-host plain HTTP: should
registries.confinsecurealso allow plain HTTP, or should there be a separate setting? - Should
backup/restoreread containers config withoutORAS_EXPERIMENTAL_CONTAINERS_CONFIG, or should this change wait until that support is no longer experimental?
Activity