-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
lang: Add fileexists function #19086
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks good to me!
Historically though we've always named functions with words all strung together with no delimiters, like fileexists
. While that precedent is certainly not ideal for readability, I think it's better that we stick with it so we don't force users to remember which functions use underscores and which ones don't.
I left some inline feedback about the docs.
|
||
## Related Functions | ||
|
||
* [`file`](./file.html) reads the contents of a file at a given path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the example above of using this to conditionally call file()
, perhaps it'd be nice to include the opposite link here too, so readers of the docs for the file
function can find this function and see that conditional reading pattern.
|
||
# `file_exists` Function | ||
|
||
`file_exists` determines whether a file exists at a given path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use a period at the end of this sentence for consistency with how the others are written.
```hcl | ||
file_exists(path) | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's important to also mention here two restrictions:
Functions are evaluated during configuration parsing rather than at apply time, so this function can only be used with files that are already present on disk before Terraform takes any actions.
This function works only with regular files. If used with a directory, FIFO, or other special mode, it will return an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My previous response still stands, but v0.12-dev
is no longer active since it's been merged into master, so unfortunately these changes will need to be cherry-picked onto a new branch from the latest master
😞
8f31fd0
to
edaa4bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
(And sorry for the collision with the merge down to master.)
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
I treat this is as "ready for review" functionally.
Addresses #10878, but will not close it until the
v0.12-dev
branch is merged tomaster
.