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 support for arbitrary terraform functions #11542

Merged
merged 1 commit into from
May 21, 2021

Conversation

rifelpet
Copy link
Member

This allows terraformWriter.LiteralFunctionExpression to be used with any terraform function.

The arguments must be strings, which means that any string arguments must include quotes. I was debating between this and using a slice of interfaces for Literal.FnArgs and passing each to json.Marshal to get their string representations (which would quote the strings for us). This would require either returning the json.Marshal error up through all of the HCL2 rendering (which doesn't currently return errors) or adding a panic which I'm not excited about.

Feedback welcome.

/hold

This allows terraformWriter.LiteralFunctionExpression to be used with any terraform function.

The arguments must be strings, which means that any string arguments must include quotes.
@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 20, 2021
@johngmyers
Copy link
Member

The thing that concerns me is lack of quoting \, ${, or %{ in the arguments. Probably unlikely to exist in pathnames, but would we want to provide a better quoting function than fmt.Sprintf("%q"?

@johngmyers
Copy link
Member

Other than that, looks good. I don't consider that blocking.
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 21, 2021
@hakman
Copy link
Member

hakman commented May 21, 2021

Same here.
/lgtm

@rifelpet
Copy link
Member Author

We can improve escaping in a followup. The HCL library may be able to help us there

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 21, 2021
@rifelpet
Copy link
Member Author

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rifelpet

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 21, 2021
@k8s-ci-robot k8s-ci-robot merged commit 06835e2 into kubernetes:master May 21, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.22 milestone May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants