Skip to content

Conversation

@Rupikz
Copy link
Contributor

@Rupikz Rupikz commented Oct 15, 2025

Description

Remove duplicate image source providers if the DefaultImagePullSource parameter is set.

Details:

  1. Move getProviders() logic from source config builder
  2. Fixes combining providers base.Join(def...).Join(pull...) previously "pull" continued to contain "def"

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have added unit tests that cover changed behavior
  • I have tested my code in common scenarios and confirmed there are no regressions
  • I have added comments to my code, particularly in hard-to-understand sections

if len(def) == 0 {
return nil, fmt.Errorf("invalid DefaultImagePullSource: %s; available values are: %v", c.DefaultImagePullSource, pull.Tags())
}
providers = base.Join(def...).Join(pull...)
Copy link
Contributor

Choose a reason for hiding this comment

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

This set is supposed to remove duplicates, but I see through some debugging that some of the sources are not comparable, so they are not being removed. An easier change would just be to add this line:
pull = pull.Remove(c.DefaultImagePullSource)

@kzantow
Copy link
Contributor

kzantow commented Oct 16, 2025

Hey @Rupikz, thanks for the contribution. However, base.Join(def...).Join(pull...) should prevent duplicates. I made a PR to fix that issue: anchore/go-collections#4

@Rupikz
Copy link
Contributor Author

Rupikz commented Oct 16, 2025

Hey @kzantow,

Awesome, your solution is better.
Should we close this PR now, or would it be okay to push a small refactor? (move getProviders from source config builder)?

@kzantow
Copy link
Contributor

kzantow commented Oct 16, 2025

Hey @Rupikz adding tests here is great, I'd love to get those contributed. Does the function need to be refactored? It seems to me there isn't much benefit to moving it. Maybe just revert that part of the change, bump the dependency, and update the tests to use the method instead of refactored function?

Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @Rupikz!

@kzantow kzantow merged commit fc74b07 into anchore:main Oct 16, 2025
12 checks passed
@willmurphyscode willmurphyscode added the bug Something isn't working label Oct 22, 2025
spiffcs added a commit that referenced this pull request Oct 22, 2025
* main:
  chore(deps): update tools to latest versions (#4302)
  chore(deps): bump github.com/github/go-spdx/v2 from 2.3.3 to 2.3.4 (#4301)
  chore(deps): bump github/codeql-action from 4.30.8 to 4.30.9 (#4299)
  support universal (fat) mach-o binary files (#4278)
  chore(deps): bump sigstore/cosign-installer from 3.10.0 to 4.0.0 (#4296)
  chore(deps): bump anchore/sbom-action from 0.20.7 to 0.20.8 (#4297)
  convert posix path back to windows (#4285)
  Remove duplicate image source providers (#4289)
  chore(deps): bump anchore/sbom-action from 0.20.6 to 0.20.7 (#4293)
  feat: add option to fetch remote licenses for pnpm-lock.yaml files (#4286)
  Add PDM parser (#4234)
  chore(deps): update tools to latest versions (#4291)
  fix: panic during java archive maven resolution (#4290)
  Extract zip archive with multiple entries (#4283)
  chore: update to use old configuration on new cosign (#4287)
  chore(deps): update anchore dependencies (#4282)
  chore(deps): bump github.com/mholt/archives from 0.1.3 to 0.1.5 (#4280)
  add docs to configs (#4281)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants