Skip to content

Fix the duplicate reference to the secretRef field of the PackageInstall object within the App object - #1860

Closed
klzsysy wants to merge 1 commit into
carvel-dev:developfrom
klzsysy:fix/duplicate-values-from-secret
Closed

klzsysy wants to merge 1 commit into
carvel-dev:developfrom
klzsysy:fix/duplicate-values-from-secret

Conversation

@klzsysy

@klzsysy klzsysy commented Sep 16, 2026

Copy link
Copy Markdown

What this PR does / why we need it:

If the secretRef field exists in the packageinstall object, the child app object will redundantly reference these secrets.

image image

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?

The `app` object will no longer duplicate the `secretRef` field found in the `packageInstall` object.

Additional Notes for your reviewer:

It also fixed an issue where duplicate references occurred in the app object when package and packageinstall objects referenced the same secret.

Added relevant unit test cases.

Review Checklist:
  • Follows the developer guidelines
  • Relevant tests are added or updated
  • Relevant docs in this repo added or updated
  • Relevant carvel.dev docs added or updated in a separate PR and there's
    a link to that PR
  • Code is at least as readable and maintainable as it was before this
    change

Additional documentation e.g., Proposal, usage docs, etc.:


    NewApp assigned the Package's spec to the App through a shallow copy, so the App
    spec kept pointers into the Package: AppTemplate.Ytt is a pointer, and
    AppSpec.Template shares its backing array. Appending the PackageInstall's values
    into templateStep.Ytt/HelmTemplate.ValuesFrom therefore wrote back into the
    Package that was passed in.

    reconcileAppWithPackage calls NewApp twice with the same Package - once to detect
    whether the App needs updating (packageinstall.go:225), and once inside the
    update closure (:234). Because the first call had already mutated the Package,
    the second call appended pkgInstall.spec.values a second time, so the stored App
    listed every PackageInstall values secret twice.

Signed-off-by: Sonny Yang <klzsysy@gmail.com>
@klzsysy
klzsysy force-pushed the fix/duplicate-values-from-secret branch from 4afd23d to 5b05de5 Compare September 16, 2026 12:07

@joaopapereira joaopapereira left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some of this already has been addressed and merge in #1862, do you mind rebasing your PR?

Some other changes:

  • Dedup is incomplete: annotation-driven paths (ExtHelmPathsFromSecretNameAnnKey, ytt PathsFrom / ExtYttDataValuesOverlaysAnnKey) still append without checking existing names. Either extend or document as out of scope.
  • We should add a line on the Release Note section of the PR saying that we are not allowing duplicated secrets and that we are only taking into account the first occurrence of each secret
  • Prefer aligning with #1862’s test style rather than duplicating fixtures.

@github-project-automation github-project-automation Bot moved this to In Progress in Carvel Sep 23, 2026
@klzsysy

klzsysy commented Oct 12, 2026

Copy link
Copy Markdown
Author

#1862 has already addressed the core issue I was concerned about,this PR can be closed for now.

@klzsysy klzsysy closed this Oct 12, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Closed in Carvel Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

3 participants