-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
consul validate only accepts .json or .hcl files => impossible to roll out + validate configs e.g. with puppet #3620
Comments
I guess this behaviour came in with #3480 |
@jenshadlich this is not a mistake and was always working like that inside a config directory. Only for the main config file the |
and yes, this was added as part of #3480 also to make it unambiguous to the parser whether it should parse a JSON or a HCL file. |
@magiconair thanks for the feedback. Can you please tell me what I need to do make puppet do that? (has to work with puppt 3.7 btw) |
No, unfortunately not. However, my guess is that you can customize the format of the random string that is being added and if all fails you could just add another |
A better option is to validate the entire config directory instead of the file since validating incomplete config fragments is also no longer supported. You would probably get a |
@magiconair I'm afraid that it's not possible to simply tell puppet to add a It would be great if you could provide a way to disable the file extension check or allow forcing it via In theory the puppet code is very straight forward like this (if not validate would be so strict):
All workarounds will create a mess and are harder to read and maintain. |
@jenshadlich This will break as soon as someone wants to use |
We could loosen the requirement on where the extension has to be. Instead of at the and we could just accept it anywhere. This makes it more ambiguous but for all practical purposes we should be fine unless someone creates a JSON file and calls it |
The question about |
@magiconair I understand your concerns. In my case the validation shall take place for exactly one file. So Validating the extension anywhere feels a bit strange even though it would also do the job. About the scope of the flags: I personally think the most logical thing is that it applies to all files. I would assume that the client knows what is is doing when setting those flags. Another option / a little tweak could to fallback to consul's preferred config file format (I don't really care if it's |
Yeah, i also think that relying on a filename's extension is so DOS-era. The "validate" command should instead try to determine the type from the content (like it's done for most pictures for example). But you can see it in the puppet module which my colleague referenced already |
Starting with Consul 1.0 all config files must have a '.json' or '.hcl' extension to make it unambigous how the data should be parsed. Some automation tools generate temporary files by appending a random string to the generated file which obfuscates the extension and prevents the file type detection. This patch adds a -config-format option which can be used to override the auto-detection behavior by forcing all config files or all files within a config directory independent of their extension to be interpreted as of this format. Fixes #3620
@martinseener I need to think about that. IMHO, config files should have only one format but if they can be in multiple formats you need to have a way of telling them apart unambiguously. Usually, I prefer things to be explicit so that operators know what they are dealing with and don't have to guess. I've written a PR which adds a I'll discuss this with the team internally to see what they think. |
@magiconair sure! i think the PR your wrote is a good approach and should ease some things. Thanks alot for that! |
@magiconair great! many thanks! |
* config: refactor ReadPath(s) methods without side-effects Return the sources instead of modifying the state. * config: clean data dir before every test * config: add tests for config-file and config-dir * config: add -config-format option Starting with Consul 1.0 all config files must have a '.json' or '.hcl' extension to make it unambigous how the data should be parsed. Some automation tools generate temporary files by appending a random string to the generated file which obfuscates the extension and prevents the file type detection. This patch adds a -config-format option which can be used to override the auto-detection behavior by forcing all config files or all files within a config directory independent of their extension to be interpreted as of this format. Fixes #3620
consul version
for both Client and ServerClient:
v1.0.0
Server:
v1.0.0
consul info
for both Client and ServerClient:
Operating system and Environment details
Linux / Ubuntu 14.04
Description of the Issue (and unexpected/desired result)
My use puppet to roll out consul configurations. Puppet appends a random string to the filename e.g.
my-service.json20171026-6787-5on04g
which breaks the validation. This makes the validation pointless because we now have to disable this step. It would be good to control the filename check e.g. by command line argument.Reproduction steps
Create a config file with a file extension other than .json or .hcl and validate.
The text was updated successfully, but these errors were encountered: