remove --registry- flags#34
Conversation
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
📝 WalkthroughWalkthroughRegistry authentication moved from CLI flags to environment variables ( Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI (caib)
participant Fn as extractRegistryCredentials()
participant Env as Environment (REGISTRY_USERNAME / REGISTRY_PASSWORD)
participant Docker as Docker/Podman auth
participant Reg as Registry
CLI->>Fn: request registry creds for push/export
Fn->>Env: check REGISTRY_USERNAME / REGISTRY_PASSWORD
alt env creds present
Env-->>Fn: return (URL, username, password)
else
Fn->>Docker: read ~/.docker/config.json or podman auth
Docker-->>Fn: return (URL, token/creds) or none
end
Fn-->>CLI: return (URL, username, password)
CLI->>Reg: push/export using returned credentials (if provided)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cmd/caib/main.go (1)
389-418: Avoid sending empty registry credentials in build requests.When
REGISTRY_USERNAME/REGISTRY_PASSWORDaren’t set,extractRegistryCredentialsreturns empty values but these blocks still setRegistryCredentials, which can override fallback and cause auth failures. Gate on both fields (asrunDiskalready does), or error when only one is set.🛠️ Suggested fix
- if effectiveRegistryURL != "" { + if effectiveRegistryURL != "" && registryUsername != "" && registryPassword != "" { req.RegistryCredentials = &buildapitypes.RegistryCredentials{ Enabled: true, AuthType: "username-password", RegistryURL: effectiveRegistryURL, Username: registryUsername, Password: registryPassword, } }- if effectiveRegistryURL != "" { + if effectiveRegistryURL != "" && registryUsername != "" && registryPassword != "" { req.RegistryCredentials = &buildapitypes.RegistryCredentials{ Enabled: true, AuthType: "username-password", RegistryURL: effectiveRegistryURL, Username: registryUsername, Password: registryPassword, } }Also applies to: 754-781
🤖 Fix all issues with AI agents
In `@cmd/caib/main.go`:
- Around line 121-126: The registry-detection logic incorrectly only checks for
a dot; update the condition in the function that derives registry from the image
reference (the block using parts := strings.SplitN(ref, "/", 2) and returning
parts[0]) to treat the first path component as a registry when it contains a '.'
OR ':' OR equals "localhost" (case-sensitive per spec). Replace the current
strings.Contains(parts[0], ".") check with a predicate that checks
strings.Contains(parts[0], ".") || strings.Contains(parts[0], ":") || parts[0]
== "localhost", and apply the same change to the other two call sites that use
this same extraction logic so localhost and host:port registries are correctly
recognized. Ensure return values remain username, password as before.
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cmd/caib/main.go (1)
389-418: Avoid sending empty registry credentials in build/build-dev requestsWith env vars now being the sole source,
RegistryCredentialscan be sent with empty username/password (Enabled=true), which risks failed auth or overriding defaults. Gate on non-empty creds (align withrunDisk).🔧 Proposed fix
- if effectiveRegistryURL != "" { + if effectiveRegistryURL != "" && registryUsername != "" && registryPassword != "" { req.RegistryCredentials = &buildapitypes.RegistryCredentials{ Enabled: true, AuthType: "username-password", RegistryURL: effectiveRegistryURL, Username: registryUsername, Password: registryPassword, } }- if effectiveRegistryURL != "" { + if effectiveRegistryURL != "" && registryUsername != "" && registryPassword != "" { req.RegistryCredentials = &buildapitypes.RegistryCredentials{ Enabled: true, AuthType: "username-password", RegistryURL: effectiveRegistryURL, Username: registryUsername, Password: registryPassword, } }Also applies to: 754-781
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
Summary by CodeRabbit
Documentation
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.