envoyproxy / envoyproxy/envoy

Support .yaml.j2 and .json.j2 file suffixes for --config-path

Open
#13,726 8 comments 1 reaction 1 assignee Claimed by @perlun View on GitHub
area/configuration help wanted
Dominant language
C++
Stars
28.9k
Forks
5.6k
Avg merge
1d 22h
Merged PRs (30d)
430

Description

*Title*: Support `.yaml.j2` and `.json.j2` file suffixes for `--config-path`

*Description*:
Envoy currently uses the file suffix to determine the file format being used, as described in the docs: https://www.envoyproxy.io/docs/envoy/latest/operations/cli#cmdoption-c

However, this is a bit inflexible. We call our config files `envoy.yaml.j2`, since they are Jinja templates that we deploy using Ansible. It makes sense to use the `.yaml.j2` extension in this case, since it makes it more clear both to text editors and humans that this file supports Jinja template mechanisms.

However, this interacts poorly with Envoy:

`$ envoy --mode validate --config-path overrides/foo/envoy/some_host_name/envoy.yaml.j2`

> [2020-10-23 10:55:07.743][4000][critical][main] [external/envoy/source/server/config_validation/server.cc:59] error initializing configuration 'overrides/foo/envoy/some_host_name/envoy.yaml.j2': Unable to parse JSON as proto (INVALID_ARGUMENT:Unexpected token.

If I rename the file to `envoy.yaml`, the validation succeeds without errors. As a workaround, I could add a symlink from `envoy.yaml` to `envoy.yaml.j2` and make it "work" for now.

### Suggestion

I think it would make some sense to add `.yaml.j2` and `.json.j2` as supported file extensions by Envoy. Of course, this does not mean that Envoy would magically understand Jinja syntax (this is completely out of scope for this issue), but it would make the process slightly smoother in cases where Jinja expressions are not being used (my use case currently).

I don't know if this is considered an edge case, but it's a bit annoying. If you agree that it would make sense to fix this, please point me to the appropriate part of the Envoy source and I'll happily submit a PR to support this. Thanks for a great project. :+1:

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.