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

Use rendered kots kinds #4239

Merged
merged 15 commits into from
Dec 22, 2023
Merged

Use rendered kots kinds #4239

merged 15 commits into from
Dec 22, 2023

Conversation

sgalsaleh
Copy link
Member

@sgalsaleh sgalsaleh commented Dec 19, 2023

What this PR does / why we need it:

Uses rendered KOTS kinds whenever they're available. This is a step forward to support templating for all KOTS kinds fields.

Which issue(s) this PR fixes:

Fixes:

Special notes for your reviewer:

Steps to reproduce

Does this PR introduce a user-facing change?

* Adds the ability to template the entire [values](/reference/custom-resource-helmchart-v2#values) field in the HelmChart custom resource.
* Fixes an issue where the [namespace](/reference/custom-resource-helmchart-v2#namespace) field in HelmChart custom resources was not rendered when uninstalling the corresponding chart.
* Fixes an issue where KOTS failed to parse the Preflight custom resource if template functions were used for non-string fields.

Does this PR require documentation?

TBD

@sgalsaleh sgalsaleh added the type::feature New feature or request label Dec 19, 2023
@sgalsaleh sgalsaleh requested a review from cbodonnell December 19, 2023 22:04
@@ -600,16 +591,14 @@ func Pull(upstreamURI string, pullOptions PullOptions) (string, error) {
}
}

installationBytes, err := ioutil.ReadFile(filepath.Join(u.GetUpstreamDir(writeUpstreamOptions), "userdata", "installation.yaml"))
// installation spec gets updated during the process, ensure the map has the latest version
Copy link
Contributor

Choose a reason for hiding this comment

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

at this point, would the renderedKotsKinds.Installation be the same as what's in upstream/userdata/installation.yaml? just curious why we need to reload it from the archive vs marshaling what we have in renderedKotsKinds

Copy link
Member Author

Choose a reason for hiding this comment

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

they would be the same, yes. it didn't really matter which one to use. i decided to load it from the upstream directory just to make sure it's definitely the same, and just in case someone forgets to update the renderedKotsKinds object in a later change.

return "", errors.Wrap(err, "failed to load rendered kotskinds from map")
}

needsConfig, err := kotsadmconfig.NeedsConfiguration(pullOptions.AppSlug, pullOptions.AppSequence, pullOptions.AirgapRoot != "", renderedKotsKinds, registrySettings)
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -444,7 +439,7 @@ func tryGetConfigFromFileContent(content []byte, log *logger.CLILogger) *kotsv1b
return nil
}

func getKotsKinds(u *upstreamtypes.Upstream) (*kotsutil.KotsKinds, error) {
func getTemplatingKotsKinds(u *upstreamtypes.Upstream) (*kotsutil.KotsKinds, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

might be good to add a comment for this indicating what "templating kots kinds" is. assuming it's the kots kinds that are needed to render template functions?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, and correct.

cbodonnell
cbodonnell previously approved these changes Dec 22, 2023
cbodonnell
cbodonnell previously approved these changes Dec 22, 2023
@sgalsaleh sgalsaleh merged commit b35c513 into main Dec 22, 2023
185 checks passed
@sgalsaleh sgalsaleh deleted the use-rendered-kots-kinds branch December 22, 2023 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type::feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants