Skip to content
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

The name example.Caddyfile is not considered a valid Caddyfile #5909

Closed
coolaj86 opened this issue Oct 22, 2023 · 6 comments
Closed

The name example.Caddyfile is not considered a valid Caddyfile #5909

coolaj86 opened this issue Oct 22, 2023 · 6 comments
Labels
feature ⚙️ New feature or request

Comments

@coolaj86
Copy link
Contributor

coolaj86 commented Oct 22, 2023

caddy run --config ./example.Caddyfile
2023/10/22 06:21:11.620	INFO	using provided configuration	{"config_file": "./example.Caddyfile", "config_adapter": ""}
Error: loading initial config: decoding request body: invalid character '#' looking for beginning of value

But if I simply rename the:

caddy run --config ./Caddyfile.example

Then it works as expected.

It seems like .Caddyfile (or really anything that isn't .json) should be considered a Caddyfile unless some sort of matching logic for some particular adapter says otherwise.

@mholt
Copy link
Member

mholt commented Oct 22, 2023

Any file that starts with Caddyfile will automatically be assumed to be a Caddyfile. From our docs:

If it is called something else that doesn't start with "Caddyfile", you will need to specify --adapter caddyfile.

So you can always specify the adapter name if the file name doesn't conform.

That said, I wonder if we should treat any file name that has Caddyfile in it as a Caddyfile... but maybe that's too liberal.

@coolaj86
Copy link
Contributor Author

coolaj86 commented Oct 22, 2023

  • equals Caddyfile
  • Has prefix Caddyfile.
  • Has suffix .Caddyfile

OSes and editors expect to know a file by its specific name, suffix, or magic bytes.

the only other file type I know of that started out with using a prefix as its type identifier is .env.xyz, and its definitely more difficult to get editors to recognize it correctly.

Being consistent with decades long tried and true conventions is generally good for machines and users alike.

@mholt
Copy link
Member

mholt commented Oct 22, 2023

Docker does this with the Dockerfile though too. And Vagrant has the Vagrantfile. It's not something we invented nor is it uncommon. Docker is practically everywhere.

But yeah, maybe containing the word Caddyfile is good enough, since it would have to be explicitly given as the config file anyway, so I don't foresee many false positives here. We only automatically use files named exactly Caddyfile.

@francislavoie
Copy link
Member

I think .Caddyfile suffix is okay to support. Maybe even .caddyfile.

@francislavoie francislavoie added the feature ⚙️ New feature or request label Oct 22, 2023
@cwbriscoe
Copy link

Case insensitive options would also be good for those that are allergic to the shift key.

@omalk98
Copy link
Contributor

omalk98 commented Oct 28, 2023

Hi @mholt and @francislavoie, I've submitted a pull request to handle this case.
Let me know if there are any other conditions you would like to handle for the Caddyfile naming convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ⚙️ New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants