Skip to content

Conversation

markcampv
Copy link

This PR adds a new fileContents template function to Consul Template.

The fileContents function reads the contents of a specified file and returns it as a string. If the file does not exist or cannot be read, it returns an empty string. This makes it safe to use in conditional template logic, such as comparisons or fallbacks using functions like default, ne, or regexMatch.

This function is particularly useful in templates that need to make decisions based on the contents of existing files, such as determining whether to overwrite a file or trigger related logic when file contents differ.

@markcampv markcampv requested a review from a team as a code owner August 6, 2025 21:58
@tgross
Copy link
Member

tgross commented Aug 7, 2025

I have no opinion on this PR itself but should @hashicorp/consul-selfmanage-maintainers accept it, I'd ask if you all wouldn't mind letting us on Nomad know so we can add this to the denylist.

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.

2 participants