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

lang: Add fileexists function #19086

Merged
merged 1 commit into from
Oct 18, 2018
Merged

lang: Add fileexists function #19086

merged 1 commit into from
Oct 18, 2018

Conversation

radeksimko
Copy link
Member

@radeksimko radeksimko commented Oct 16, 2018

I treat this is as "ready for review" functionally.

Addresses #10878, but will not close it until the v0.12-dev branch is merged to master.

Copy link
Contributor

@apparentlymart apparentlymart left a 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
Copy link
Contributor

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
Copy link
Contributor

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)
```

Copy link
Contributor

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.

Copy link
Contributor

@apparentlymart apparentlymart left a 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 😞

@radeksimko radeksimko changed the base branch from v0.12-dev to master October 17, 2018 09:18
Copy link
Contributor

@apparentlymart apparentlymart left a 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.)

@radeksimko radeksimko merged commit d6f7577 into master Oct 18, 2018
@radeksimko radeksimko deleted the f-file-exists-func branch October 18, 2018 05:26
@radeksimko radeksimko changed the title lang: Add file_exists function lang: Add fileexists function Oct 18, 2018
@ghost
Copy link

ghost commented Apr 1, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants