Skip to content

lint and validate dependency metadata to reference dependencies with …#9176

Merged
mattfarina merged 2 commits intohelm:mainfrom
dastrobu:#9169/lint-dependency-shadowing
Jan 8, 2024
Merged

lint and validate dependency metadata to reference dependencies with …#9176
mattfarina merged 2 commits intohelm:mainfrom
dastrobu:#9169/lint-dependency-shadowing

Conversation

@dastrobu
Copy link
Copy Markdown
Contributor

…a unique key (name or alias)

Report charts with the following bad dependency specifications as bad charts:

dependencies:
- name: foo
  alias: baz # ← baz used twice
  version: 1.0.0
- name: bar
  alias: baz # ← baz used twice
  version: 1.0.0

dependencies:
- name: foo
  alias: bar # ← shadows chart below
  version: 1.0.0
- name: bar
  version: 1.0.0

dependencies:
- name: foo
  version: 1.0.0
- name: foo # ← chart with same name as above (although version or repo will be different, this will not work currently)
  version: 1.2.3

Closes #9169

Signed-off-by: Daniel Strobusch 1847260+dastrobu@users.noreply.github.com

What this PR does / why we need it:

Special notes for your reviewer:

If applicable:

  • this PR contains documentation
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

@helm-bot helm-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 28, 2020
@dastrobu dastrobu force-pushed the #9169/lint-dependency-shadowing branch from ff51cdf to a9f1df0 Compare January 6, 2021 09:56
Copy link
Copy Markdown
Contributor

@sbose78 sbose78 left a comment

Choose a reason for hiding this comment

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

LGTM

@dastrobu dastrobu force-pushed the #9169/lint-dependency-shadowing branch from a9f1df0 to 1b3801a Compare June 25, 2021 05:08
@dastrobu
Copy link
Copy Markdown
Contributor Author

Rebased onto current main.

@jburnitz
Copy link
Copy Markdown

jburnitz commented Jul 2, 2022

why isn't this merged

@joejulian joejulian added this to the 3.11.0 milestone Oct 4, 2022
@dastrobu dastrobu force-pushed the #9169/lint-dependency-shadowing branch from 1b3801a to a75251f Compare December 8, 2022 19:07
@dastrobu
Copy link
Copy Markdown
Contributor Author

dastrobu commented Dec 8, 2022

Rebased onto current main.

@dastrobu dastrobu force-pushed the #9169/lint-dependency-shadowing branch from a75251f to 4c23745 Compare December 8, 2022 19:12
@dastrobu dastrobu requested a review from sbose78 December 10, 2022 09:01
@mattfarina mattfarina modified the milestones: 3.11.0, 3.12.0 Jan 18, 2023
@joejulian joejulian modified the milestones: 3.12.0, 3.13.0 May 5, 2023
Copy link
Copy Markdown

@Maxine-van-der-Smissen Maxine-van-der-Smissen left a comment

Choose a reason for hiding this comment

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

Note: I am not a maintainer.

Thanks for making the PR

…a unique key (name or alias)

Report charts with the following bad dependency specifications as bad charts:

    dependencies:
    - name: foo
      alias: baz # ← baz used twice
      version: 1.0.0
    - name: bar
      alias: baz # ← baz used twice
      version: 1.0.0

    dependencies:
    - name: foo
      alias: bar # ← shadows chart below
      version: 1.0.0
    - name: bar
      version: 1.0.0

    dependencies:
    - name: foo
      version: 1.0.0
    - name: foo # ← chart with same name as above (although version or repo will be different, this will not work currently)
      version: 1.2.3

Closes helm#9169

Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com>
@dastrobu dastrobu force-pushed the #9169/lint-dependency-shadowing branch from 4c23745 to 6a4035a Compare May 23, 2023 07:03
@joejulian joejulian self-assigned this Aug 24, 2023
Copy link
Copy Markdown
Contributor

@joejulian joejulian left a comment

Choose a reason for hiding this comment

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

I tried being creative but I can't break this. Nice work!

@joejulian joejulian added the Has One Approval This PR has one approval. It still needs a second approval to be merged. label Sep 6, 2023
@mattfarina mattfarina modified the milestones: 3.13.0, 3.14.0 Sep 25, 2023
Copy link
Copy Markdown
Contributor

@sabre1041 sabre1041 left a comment

Choose a reason for hiding this comment

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

LGTM

@mattfarina mattfarina merged commit 83a76ce into helm:main Jan 8, 2024
@dastrobu dastrobu deleted the #9169/lint-dependency-shadowing branch January 8, 2024 20:57
@dbluxo
Copy link
Copy Markdown

dbluxo commented Jan 24, 2024

Hey @dastrobu 👋 , I'm now (v3.14.0) getting error messages, is this a non valid use case?:

dependencies:
  - name: kube-rbac-proxy
    version: "0.9.1"
    repository: "<...>"
    alias: loki-query-proxy
    condition: loki-query-proxy.enabled
  - name: kube-rbac-proxy
    version: "0.9.1"
    repository: "<...>"
    alias: loki-ingestion-proxy
    condition: loki-ingestion-proxy.enabled

index.go:366: skipping loading invalid entry for chart "<...>" "1.3.0" from <...>: validation: more than one dependency with name or alias "kube-rbac-proxy"

Or am I missing something?

@bt909
Copy link
Copy Markdown

bt909 commented Jan 24, 2024

According to the documentation for the Chart.yaml using name twice with separate aliases seems to be okay.

Quote: alias: (optional) Alias to be used for the chart. Useful when you have to add the same chart multiple times

But now this seemed to be treated as error!

@dastrobu
Copy link
Copy Markdown
Contributor Author

index.go:366: skipping loading invalid entry for chart "<...>" "1.3.0" from <...>: validation: more than one dependency with name or alias "kube-rbac-proxy"

Or am I missing something?

@dbluxo I guess your case should work as long as the repo and version is identical for both dependencies. Otherwise you will hit the case described in #9169 (undefined behaviour).
As this PR is closed, I'd suggest to create a new issue for this.
I can try to create a fix for this. Note that I am not a maintainer, though.

@dbluxo
Copy link
Copy Markdown

dbluxo commented Jan 25, 2024

@dastrobu Thank you for your response. I have created an issue, would be great if our use case (same repository and version) would work again.

@ziqianggeoffreychen
Copy link
Copy Markdown

index.go:366: skipping loading invalid entry for chart "<...>" "1.3.0" from <...>: validation: more than one dependency with name or alias "kube-rbac-proxy"
Or am I missing something?

@dbluxo I guess your case should work as long as the repo and version is identical for both dependencies. Otherwise you will hit the case described in #9169 (undefined behaviour). As this PR is closed, I'd suggest to create a new issue for this. I can try to create a fix for this. Note that I am not a maintainer, though.

Hi @dastrobu , I opened an issue related to this change. In my case, the two dependencies are exactly the same with different aliases. But the alias is removed by JFrog in its index.yaml metadata. If all versions of the helm charts are with the same kind (aliases duplicate), it seems they will show up in search result. But that's not reliable. Refer to my issue for more details. Thanks.
#12744

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Has One Approval This PR has one approval. It still needs a second approval to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dependency name (and alias) clashes should be reported as errors