hashicorp / hashicorp/consul-template

fileOrDefault method

Open
#1,825 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
4.8k
Forks
801
Avg merge
4h 5m
Merged PRs (30d)
6

Description

### Consul Template version

Run `consul-template -v` to show the version. If you are not
running the latest version, please upgrade before submitting an
issue.

`consul-template v0.32.0 (a926131)`

### Expected behavior

The fact that the `file` function always returns an error if the file doesn't exist is a problem for me. I'd really like to have a `fileOrDefault` version as an analog of the [`keyOrDefault`](https://github.com/hashicorp/consul-template/blob/main/docs/templating-language.md#keyordefault) function.

### Actual behavior
`consul-template` crashes if the file doesn't exist.

Contributor guide

Open the contributing guide

Research direction

Start by reading the existing `file` template function and the `keyOrDefault` documentation linked in the issue to understand the intended analogue. The work is done when a `fileOrDefault` function handles a missing file without crashing and returns the requested default behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.