envoyproxy/envoy

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

Open

#13 726 ouverte le 23 oct. 2020

Voir sur GitHub
 (8 commentaires) (1 réaction) (1 assigné)C++ (5 373 forks)batch import
area/configurationhelp wanted

Métriques du dépôt

Stars
 (27 997 stars)
Métriques de merge PR
 (Merge moyen 8j) (378 PRs mergées en 30 j)

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:

Guide contributeur