Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹 Refactor auth opts for registries. Pass through opts when pulling registry images #3738

Merged
merged 2 commits into from
Apr 9, 2024

Conversation

preslavgerchev
Copy link
Contributor

@preslavgerchev preslavgerchev commented Apr 9, 2024

  • Move all remote.Options code to auth/options
  • Ensure that if we pass external opts, those are also passed all the way down to the image fetching
  • Remove redundant code

@preslavgerchev preslavgerchev force-pushed the preslav/refactor-container-auth branch from abef6d0 to 300c9cb Compare April 9, 2024 19:51
@preslavgerchev preslavgerchev changed the title 🧹 Refactor auth opts for registries. 🧹 Refactor auth opts for registries. Pass through opts when pulling registry images Apr 9, 2024
Copy link
Contributor

github-actions bot commented Apr 9, 2024

Test Results

2 971 tests  ±0   2 970 ✅ ±0   1m 28s ⏱️ -1s
  328 suites ±0       1 💤 ±0 
   23 files   ±0       0 ❌ ±0 

Results for commit 37fb5db. ± Comparison against base commit 46664a5.

This pull request removes 3 and adds 3 tests. Note that renamed tests count towards both.
go.mondoo.com/cnquery/v10/llx ‑ TestSuccess/2024-04-08_08:35:38.226223731_+0000_UTC_m=+0.007722426
go.mondoo.com/cnquery/v10/llx ‑ TestTruthy/2024-04-08_08:35:38.226223731_+0000_UTC_m=+0.007722426
go.mondoo.com/cnquery/v10/llx ‑ TestTruthy/2024-04-08_08:35:38.226223731_+0000_UTC_m=+0.007722426#01
go.mondoo.com/cnquery/v10/llx ‑ TestSuccess/2024-04-09_10:10:40.236068383_+0000_UTC_m=+0.008132019
go.mondoo.com/cnquery/v10/llx ‑ TestTruthy/2024-04-09_10:10:40.236068383_+0000_UTC_m=+0.008132019
go.mondoo.com/cnquery/v10/llx ‑ TestTruthy/2024-04-09_10:10:40.236068383_+0000_UTC_m=+0.008132019#01

♻️ This comment has been updated with latest results.

@preslavgerchev preslavgerchev force-pushed the preslav/refactor-container-auth branch from 300c9cb to 1e84b68 Compare April 9, 2024 19:54
@preslavgerchev preslavgerchev force-pushed the preslav/refactor-container-auth branch from 1e84b68 to 315c363 Compare April 9, 2024 19:56
@preslavgerchev preslavgerchev marked this pull request as ready for review April 9, 2024 20:03
@@ -50,12 +47,11 @@ func (r *Resolver) Resolve(ctx context.Context, root *inventory.Asset, conf *inv
if err == nil {
log.Debug().Str("image", conf.Host).Msg("detected container image in container registry")

remoteOpts := AuthOption(conf.Credentials, credsResolver)
// we need to disable default keychain auth if an auth method was found
if len(remoteOpts) > 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was redundant, if we ensure that the auth opt always returns then we dont need the DisableKeychainAuth since we can have the AuthOption decide whats the best auth method by looking at the creds

@@ -164,7 +121,7 @@ func (a *DockerRegistryImages) ListRepository(repoName string) ([]*inventory.Ass
return nil, fmt.Errorf("parsing reference %q: %v", repoWithTag, err)
}

a, err := a.toAsset(ref, nil)
a, err := a.toAsset(ref, nil, opts...)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

pass opts thru to ensure these are respected

Copy link
Member

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

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

Very nice cleanup

@preslavgerchev preslavgerchev merged commit 1e1dc6f into main Apr 9, 2024
15 checks passed
@preslavgerchev preslavgerchev deleted the preslav/refactor-container-auth branch April 9, 2024 20:22
@github-actions github-actions bot locked and limited conversation to collaborators Apr 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants