Skip to content

Fix Helm chart appVersion not being quoted in index.yaml

  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA

What does this MR do and why?

These changes attempt to force "appVersion" in the index presentation for Helm Charts to be quoted so it is not accidentally interpreted as a number by YAML parsers. The idea is that helm tools will be referencing the helm repository via:

https://gitlab.com/api/v4/projects/61796499/packages/helm/stable/index.yaml

Which currently presents the YAML as:

---
apiVersion: v1
entries:
  mychart:
  - name: mychart
    type: application
    version: 0.2.0
    apiVersion: v2
    appVersion: 1234e004
    description: Proof of bug?
    created: '2024-09-18T17:23:44.630243000Z'
    digest:
    urls:
    - charts/mychart-0.2.0.tgz
  - name: mychart
    type: application
    version: 0.1.0
    apiVersion: v2
    appVersion: abcd1234
    description: Proof of bug?
    created: '2024-09-18T17:19:44.773301000Z'
    digest:
    urls:
    - charts/mychart-0.1.0.tgz
generated: '2024-09-18T17:23:54.438919051Z'
serverInfo:
  contextPath: "/api/v4/projects/61796499/packages/helm"

But it should be (note the change in "appVersion"):

---
apiVersion: v1
entries:
  mychart:
  - name: mychart
    type: application
    version: 0.2.0
    apiVersion: v2
    appVersion: "1234e004"
    description: Proof of bug?
    created: '2024-09-18T17:23:44.630243000Z'
    digest:
    urls:
    - charts/mychart-0.2.0.tgz
  - name: mychart
    type: application
    version: 0.1.0
    apiVersion: v2
    appVersion: "abcd1234"
    description: Proof of bug?
    created: '2024-09-18T17:19:44.773301000Z'
    digest:
    urls:
    - charts/mychart-0.1.0.tgz
generated: '2024-09-18T17:23:54.438919051Z'
serverInfo:
  contextPath: "/api/v4/projects/61796499/packages/helm"

Now the disclaimer: I have no ruby experience before this nor with GitLab's source code. I think the code I've changed will produce the desired output, but I'm not sure how to verify it right now since as far as I could tell the example projects in the test site (I'm using GitPod) don't have any helm charts. I'm also not sure how else the IndexPresenters are used outside of "index.yaml" requests. It's possible all of these changes should have been put into a view rather than in the presenter class.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

TODO

Related to #490699

Edited by 🤖 GitLab Bot 🤖

Merge request reports

Loading