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

Adding a simple function to test env vars #103

Closed

Conversation

aodinokov
Copy link
Contributor

@aodinokov aodinokov commented Sep 20, 2020

This function was created based the request from kustomize team:
this is for kubernetes-sigs/kustomize#2999

Please pay attention that go functions don't get built, so to make my e2e work I've done this:
84f2c57#diff-60fe268f71ae7f8409aff40d0a3e51d8

The idea is to create go-template based function with
sprig lib. Sprig supports env and expandenv[1].
Using this it will be possilbe to return generated documents
with values based on envs and data fields.

[1]
http://masterminds.github.io/sprig/os.html
@aodinokov
Copy link
Contributor Author

this is for kubernetes-sigs/kustomize#2999
cc: @monopole , @Shell32-Natsu

@aodinokov aodinokov marked this pull request as draft September 20, 2020 22:31
@aodinokov aodinokov force-pushed the function-with-env branch 2 times, most recently from 0c83936 to 73d6e2f Compare September 21, 2020 04:43
added e2e testing for templater
@aodinokov aodinokov marked this pull request as ready for review September 21, 2020 05:47
Copy link
Contributor

@prachirp prachirp left a comment

Choose a reason for hiding this comment

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

Thanks, this makes sense in the context of testing env variables.

@aodinokov aodinokov force-pushed the function-with-env branch 5 times, most recently from 4d29606 to 19a9756 Compare September 25, 2020 06:35
Copy link
Contributor

@prachirp prachirp left a comment

Choose a reason for hiding this comment

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

LGTM

@aodinokov aodinokov force-pushed the function-with-env branch 2 times, most recently from 3098246 to 255b893 Compare September 27, 2020 06:04
@aodinokov aodinokov marked this pull request as draft October 8, 2020 03:13
the templater uses go-template engine,
sprit library and introduced KYAML go-template library
to be able to flexibly transform documents.
Please refer to README for more information.
@aodinokov aodinokov marked this pull request as ready for review October 12, 2020 06:37
@aodinokov aodinokov marked this pull request as draft October 21, 2020 04:15
@frankfarzan frankfarzan requested review from prachirp and removed request for frankfarzan and prachirp October 28, 2020 20:39
The previous iteration was too complicated.
Created the easy function to test env variables
@aodinokov aodinokov force-pushed the function-with-env branch 5 times, most recently from c519c4e to 553ae02 Compare November 3, 2020 06:35
@aodinokov aodinokov marked this pull request as ready for review November 3, 2020 07:00
@aodinokov
Copy link
Contributor Author

aodinokov commented Nov 3, 2020

@frankfarzan sorry for the delay with the new version.
I've completely removed the template mechanism and have made a really simple function, but since it works with env variables it can be used when the value isn't known. That is a pretty powerful feature. E.g. see timestamping example.

PS:
while I was working on this I found several little issues in the repo:

  1. Remove kustomize-build. #116 - forgot about functions/ts/build/kustomize_build.Dockerfile - see Remove remaining kustomize_build dockerfile #117
  2. helm/charts@2f54b7c#diff-4ea099515951a32bd22484cbcc15d627597b97b43f6df64437b8ca64a2ff6676 - chart is deprecated and that causes error - partially fixed, partially commented
  3. https://github.com/GoogleContainerTools/kpt-functions-catalog/blob/master/tests/annotate_config.sh#L53 - this branch has been removed and that causes error - fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants