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

kctrl package release creates an invalid OpenAPI spec from Helm Chart #1630

Open
nebhale opened this issue Oct 2, 2024 · 2 comments
Open
Labels
bug This issue describes a defect or unexpected behavior carvel-accepted This issue should be considered for future work and that the triage process has been completed

Comments

@nebhale
Copy link

nebhale commented Oct 2, 2024

What steps did you take:

Given the following:

# helm/Chart.yaml
apiVersion: v2
name: test
version: 0.1.0
# helm/values.yaml
credentials:
  username: null
  password: null
# package-build.yml
apiVersion: kctrl.carvel.dev/v1alpha1
kind: PackageBuild
metadata:
  creationTimestamp: null
  name: test.nebhale.com
spec:
  template:
    spec:
      app:
        spec:
          deploy:
          - kapp: {}
          template:
          - helmTemplate:
              path: helm
          - ytt:
              paths:
              - '-'
          - kbld: {}
      export:
      - includePaths:
        - helm
# package-resources.yml
apiVersion: data.packaging.carvel.dev/v1alpha1
kind: Package
metadata:
  creationTimestamp: null
  name: test.nebhale.com.0.0.0
spec:
  refName: test.nebhale.com
  releasedAt: null
  template:
    spec:
      deploy:
      - kapp: {}
      fetch:
      - git: {}
      template:
      - helmTemplate:
          path: helm
      - ytt:
          paths:
          - '-'
      - kbld: {}
  valuesSchema:
    openAPIv3: null
  version: 0.0.0

---
apiVersion: data.packaging.carvel.dev/v1alpha1
kind: PackageMetadata
metadata:
  creationTimestamp: null
  name: test.nebhale.com
spec:
  displayName: test
  longDescription: test.nebhale.com
  shortDescription: test.nebhale.com

---
apiVersion: packaging.carvel.dev/v1alpha1
kind: PackageInstall
metadata:
  annotations:
    kctrl.carvel.dev/local-fetch-0: .
  creationTimestamp: null
  name: test
spec:
  packageRef:
    refName: test.nebhale.com
    versionSelection:
      constraints: 0.0.0
  serviceAccountName: test-sa
status:
  conditions: null
  friendlyDescription: ""
  observedGeneration: 0

run kctrl package release

What happened:
The following, invalid OpenAPIV3 was created. Specifically .spec.valuesSchema.openAPIv3.properties.credentials.properties.[password|username].type="null" is invalid as null is not a valid type by spec.

# carvel-artifacts/package.yml
apiVersion: data.packaging.carvel.dev/v1alpha1
kind: Package
metadata:
  creationTimestamp: null
  name: test.nebhale.com.0.0.0+build.1727907345
spec:
  refName: test.nebhale.com
  releasedAt: "2024-10-02T22:15:55Z"
  template:
    spec:
      deploy:
      - kapp: {}
      fetch:
      - imgpkgBundle:
          image: index.docker.io/bhale382/test@sha256:be8d6e5d70f56cf37a5beff589c52d235e852474f0b9dc805d5199166627fd2c
      template:
      - helmTemplate:
          path: helm
      - ytt:
          paths:
          - '-'
      - kbld:
          paths:
          - '-'
          - .imgpkg/images.yml
  valuesSchema:
    openAPIv3:
      properties:
        credentials:
          properties:
            password:
              default: "null"
              type: "null"
            username:
              default: "null"
              type: "null"
          type: object
      type: object
  version: 0.0.0+build.1727907345

What did you expect:
I'd have expected a valid type to be put into the schema.

Anything else you would like to add:
It appears if the following had been used, the type would have been string.

# helm/values.yaml
credentials:
  username:
  password:

Unfortunately after a run through ytt, the nulls are put into place and that behavior is not preserved. I'd be open to this being the behavior in the place of null as well.

Environment:

  • kapp Controller version (execute kubectl get deployment -n kapp-controller kapp-controller -o yaml and the annotation is kbld.k14s.io/images): N/A
  • Kubernetes version (use kubectl version): N/A

Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

@nebhale nebhale added bug This issue describes a defect or unexpected behavior carvel-triage This issue has not yet been reviewed for validity labels Oct 2, 2024
@100mik
Copy link
Contributor

100mik commented Oct 3, 2024

I am wondering if this is resolved if PackageBuild does not have a ytt section. Maybe init should not be adding it for helm only scenarios.

@100mik 100mik added carvel-accepted This issue should be considered for future work and that the triage process has been completed and removed carvel-triage This issue has not yet been reviewed for validity labels Oct 3, 2024
@nebhale
Copy link
Author

nebhale commented Oct 3, 2024

I'm doing a pre-pass with ytt directly for other reasons, so I don't think it's the one in PackageBuild that's the real problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue describes a defect or unexpected behavior carvel-accepted This issue should be considered for future work and that the triage process has been completed
Projects
Status: Prioritized Backlog
Development

No branches or pull requests

2 participants