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

Add Helm manifest gen #447

Merged
merged 10 commits into from
Aug 26, 2021
Merged

Conversation

Trojan295
Copy link
Contributor

@Trojan295 Trojan295 commented Aug 18, 2021

Description

Changes proposed in this pull request:

  • Add capact alpha manifest-gen implementation helm command
  • Rename --override flag to --overwrite
  • Add unit tests for the manifest generation code

Testing

You can use the following command to generate manifests for the bitnami/postgresql Helm chart:

go run cmd/cli/main.go alpha manifest-gen implementation helm cap.implementation.bitnami.postgresql.install postgresql --repo "https://charts.bitnami.com/bitnami" -i cap.interface.database.postgresql.install

Problems

  1. If user provides an empty parameter value for a string, it will be interpreted as null, when evaluating values in workflow.
    The values of the parameters are transformed to strings in format:

    key: <@ additionalInput.key | default("some_default") @>
    # becomes, if user provides an empty string as value
    key:        # interpreted as null in YAML

    I couldn't find a way to make yaml.Marshal add double quotes to every string value so it would be ok.

  2. If a key in Helm values.yaml contains a dot, then Jinja will have problem with interpreting it correctly. I'm not sure if this is a problem in Jinja as changing it to object[key] instead of object.key does not work also.

    # does not work
    annotations:
       prometheus.scrape: <@ additionalInput.annotations.prometheus.scrape @>
    
    # also does not work
    annotations:
       prometheus.scrape: <@ additionalInput.annotations["prometheus.scrape"] @>

Related issue(s)

Closes #417

@Trojan295 Trojan295 force-pushed the add-helm-manifest-gen branch from 1a50ea3 to 97bc62a Compare August 18, 2021 15:32
@Trojan295 Trojan295 marked this pull request as ready for review August 18, 2021 15:39
@mszostok mszostok self-assigned this Aug 23, 2021
@Trojan295 Trojan295 closed this Aug 23, 2021
@Trojan295 Trojan295 deleted the add-helm-manifest-gen branch August 23, 2021 14:45
Copy link
Member

@mszostok mszostok left a comment

Choose a reason for hiding this comment

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

Overall, really nice work
good-job-clapping

It's awesome that you added test coverage and refactored code, it's more readable right now.

Regarding problem with escaping in jinja templating we can wait for our jinja sensei @lukaszo

cmd/cli/cmd/alpha/manifest-gen/implementation/helm.go Outdated Show resolved Hide resolved
cmd/cli/cmd/alpha/manifest-gen/implementation/helm.go Outdated Show resolved Hide resolved
cmd/cli/cmd/alpha/manifest-gen/manifest-gen.go Outdated Show resolved Hide resolved
internal/cli/alpha/manifestgen/helm.go Outdated Show resolved Hide resolved
internal/cli/alpha/manifestgen/helm.go Outdated Show resolved Hide resolved
internal/cli/alpha/manifestgen/helm.go Show resolved Hide resolved
@Trojan295 Trojan295 restored the add-helm-manifest-gen branch August 24, 2021 11:17
@Trojan295
Copy link
Contributor Author

Trojan295 commented Aug 24, 2021

I reopened the PR in #459, as I accidentally removed the branch from my fork...

edit: nvm

@pkosiec
Copy link
Member

pkosiec commented Aug 24, 2021

@Trojan295 FYI you could reopen the same pull request if you didn't create the new one 🙂 You can try closing the new one (#459) and reopening this, probably it would be easier to track post-review changes, but it's up to you.

@Trojan295 Trojan295 reopened this Aug 24, 2021
@Trojan295 Trojan295 added area/cli Relates to CLI enhancement New feature or request labels Aug 24, 2021
@pkosiec pkosiec mentioned this pull request Aug 24, 2021
@Trojan295 Trojan295 force-pushed the add-helm-manifest-gen branch from 2c0b807 to 68bd7c5 Compare August 25, 2021 12:08
@Trojan295 Trojan295 force-pushed the add-helm-manifest-gen branch from 68bd7c5 to bc3deeb Compare August 25, 2021 14:48
Copy link
Member

@mszostok mszostok left a comment

Choose a reason for hiding this comment

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

lgtm, just minor comments

}

if len(parentKeyPath) > 0 {
schema.Title = parentKeyPath[len(parentKeyPath)-1]
Copy link
Member

Choose a reason for hiding this comment

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

nit

Suggested change
schema.Title = parentKeyPath[len(parentKeyPath)-1]
schema.Title = strcase.ToCamel(parentKeyPath[len(parentKeyPath)-1])

arguments:
artifacts:
- name: input-parameters
from: "{{"{{"}}steps.prepare-parameters.outputs.artifacts.merged{{"}}"}}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
from: "{{"{{"}}steps.prepare-parameters.outputs.artifacts.merged{{"}}"}}"
from: "{{`{{steps.prepare-parameters.outputs.artifacts.merged}}`}}"

IMO it can be done in more readable way, simply replace

"{{"{{"}}

with

"{{`{{

(in the same way right brackets)

so from this

"{{"{{"}}steps.prepare-parameters.outputs.artifacts.merged{{"}}"}}"

you will get

"{{`{{steps.prepare-parameters.outputs.artifacts.merged}}`}}"

@Trojan295 Trojan295 merged commit 0fbf562 into capactio:main Aug 26, 2021
Trojan295 added a commit to Trojan295/capact that referenced this pull request Aug 27, 2021
Trojan295 added a commit to Trojan295/capact that referenced this pull request Aug 27, 2021
lukaszo added a commit that referenced this pull request Sep 1, 2021
* solves problem nr 2 from Add Helm manifest gen #447
* add unittests
* complete features list
* enable running python tests on CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli Relates to CLI enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create content development tools for Helm charts
3 participants