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

Feature: kots template #4533

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

nvanthao
Copy link
Member

@nvanthao nvanthao commented Apr 2, 2024

What this PR does / why we need it:

It is currently difficult to debug templating error thrown by KOTS during install.

Which issue(s) this PR fixes:

Special notes for your reviewer:

This PR introduce new command kots template with 4 options to parse template.

  1. Parse raw template directly from --data flag.

E.g.

kots template --license-file license.yaml --config-values config.yaml --data '{{repl ConfigOption "hostname" | ToUpper }}'

MYHOST
  1. Parse template interactively. New REPL session will be created to parse template
kots template --license-file license.yaml --config-values config.yaml --interactive
  1. Parse template by file
kots template --license-file license.yaml --config-values config.yaml <path_to_template>
  1. Parse all templates in kotsKind directory, this behave similar to helm template where all files in kotsKind directory will be printed to stdout.
kots template --license-file license.yaml --config-values config.yaml 

Does this PR introduce a user-facing change?

New command line command `kots template`

Does this PR require documentation?

Yes

@CLAassistant
Copy link

CLAassistant commented Apr 2, 2024

CLA assistant check
All committers have signed the CLA.

@nvanthao nvanthao added the type::feature New feature or request label Apr 2, 2024
@nvanthao nvanthao force-pushed the gerard/sc-93245/f-template-render branch from f1567d3 to de3b613 Compare April 4, 2024 23:30
fmt.Println(m)
}

// also render helm charts with helm template if any
Copy link
Member

@cbodonnell cbodonnell Apr 5, 2024

Choose a reason for hiding this comment

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

the rendered directory should already have the rendered helm templates, plain k8s manifests, and additional resources created by kustomize (pull secrets and any customer patches). i think we may be able to instead just iterate and print the files in that directory?

the kotskinds will not be in rendered, so i think what you have above this is good

Copy link
Member Author

Choose a reason for hiding this comment

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

Many thanks Craig! I've included rendered directory excluding kotsadm- files. However I think we should also run helm template on helm/ directory for HelmChart v2. What do you think?

Copy link
Member

@cbodonnell cbodonnell Apr 9, 2024

Choose a reason for hiding this comment

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

the rendered directory will already contain the helm template output in an all.yaml file for each HelmChart, so i think we can just iterate over all of the files there, including the kotsadm- files since those will ultimately be deployed along with everything else

Screenshot 2024-04-09 at 2 08 40 PM

Copy link
Member Author

Choose a reason for hiding this comment

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

gotcha! I've removed the helm template part. Please let me know how it goes!

pkg/pull/pull.go Outdated Show resolved Hide resolved
@nvanthao nvanthao force-pushed the gerard/sc-93245/f-template-render branch from bd1eccf to 9517886 Compare April 8, 2024 03:53
@nvanthao nvanthao force-pushed the gerard/sc-93245/f-template-render branch from a1f686f to d018228 Compare April 18, 2024 21:22
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.

None yet

3 participants