{"id":16800227,"url":"https://github.com/abiosoft/caddy-yaml","last_synced_at":"2026-04-02T02:59:02.067Z","repository":{"id":57545479,"uuid":"269057999","full_name":"abiosoft/caddy-yaml","owner":"abiosoft","description":"Alternative Caddy YAML config adapter with extra features","archived":false,"fork":false,"pushed_at":"2023-08-03T20:44:24.000Z","size":176,"stargazers_count":28,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T06:51:34.279Z","etag":null,"topics":["caddy","caddy-module","caddy-server","config-adapter","template","yaml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abiosoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-03T10:26:40.000Z","updated_at":"2024-11-21T20:33:06.000Z","dependencies_parsed_at":"2024-06-19T20:06:20.732Z","dependency_job_id":"f50d10d3-20ca-44c8-a012-74732d5f4b76","html_url":"https://github.com/abiosoft/caddy-yaml","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abiosoft%2Fcaddy-yaml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abiosoft%2Fcaddy-yaml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abiosoft%2Fcaddy-yaml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abiosoft%2Fcaddy-yaml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abiosoft","download_url":"https://codeload.github.com/abiosoft/caddy-yaml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244897825,"owners_count":20528296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["caddy","caddy-module","caddy-server","config-adapter","template","yaml"],"created_at":"2024-10-13T09:31:39.667Z","updated_at":"2026-04-02T02:59:02.038Z","avatar_url":"https://github.com/abiosoft.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# caddy-yaml\n\n[![Go](https://github.com/abiosoft/caddy-yaml/workflows/Go/badge.svg)](https://github.com/abiosoft/caddy-yaml/actions)\n\n\nAlternative Caddy YAML config adapter with extra features.\n\n## Install\n\nInstall with [xcaddy](https://github.com/caddyserver/xcaddy).\n\n```\nxcaddy build \\\n    --with github.com/abiosoft/caddy-yaml\n```\n## Usage\n\nSpecify with the `--adapter` flag for `caddy run`.\n```\ncaddy run --config /path/to/yaml/config.yaml --adapter yaml\n```\n\n## Comparison with existing YAML adapter\n\nThis project does a few extra things.\n\n* Conditional configurations with Templates.\n\n  ```yaml\n  #{if ne $ENVIRONMENT \"production\"}\n  logging:\n    logs:\n      default: { level: DEBUG }\n  #{end}\n  ```\n\n- Extension Fields. A convension used in [Docker Compose](https://docs.docker.com/compose/compose-file/compose-file-v3/#extension-fields).\n\n  Top level keys prefixed with `x-` are discarded. This makes it easier to leverage YAML anchors and aliases, while avoiding Caddy errors due to unknown fields.\n\n  ```yaml\n  # anchor declaration\n  x-file_server: \u0026file_server\n    handler: file_server\n    hide: [\".git\"]\n    index_names: [index.html]\n\n  # reuse alias\n  ...\n  handle:\n    - \u003c\u003c: *file_server\n      root: /var/www/blog/public\n\n  # reuse alias\n  ...\n  handle:\n    - \u003c\u003c: *file_server\n      root: /var/www/api/docs\n  ```\n\n* Config-time environment variables\n\n  Without the Caddyfile, Caddy's native configuration limits to runtime environment variables.\n  There are use cases for knowing the environment variables at configuration time. e.g. troubleshooting purposes.\n\n  ```yaml\n  listen: \"#{ $PORT }\"\n  ```\n\nIf the above features are not needed or utilised, the behaviour is identical to [iamd3vil/caddy_yaml_adapter](https://github.com/iamd3vil/caddy_yaml_adapter).\n\n\n_**Note** that both adapters cannot be built with Caddy, they are incompatible. They both register as `yaml` config adapter and at most one config adapter is allowed per config format_.\n\n\n## Templating\n\nAnything supported by [Go templates](https://pkg.go.dev/text/template) can be used, as well as any [Sprig](https://masterminds.github.io/sprig) function.\n\n### Delimeters\n\nDelimeters are `#{` and `}`. e.g. `#{ .title }`. The choice of delimeters ensures the YAML config file remains a valid YAML file that can be validated by the schema.\n\n### Values\n\nExtension fields can be reused anywhere else in\nthe YAML config.\n\n```yaml\nx-hello: Hello from YAML template\nx-nest:\n  value: nesting\n```\n\nReferencing them without `x-` prefix.\n\n```yaml\n...\nhandle:\n  - handler: static_response\n    body: \"#{ .hello } with #{ .nest.value }\"\n```\n\n_If string interpolation is not needed, YAML anchors and aliases can also be used to achieve this_.\n\n### Environment Variables\n\nEnvironment variables can be used in a template by prefixing with `$`.\n\n```yaml\nlisten:\n  - \"#{ $PORT }\"\n...\nhandler: file_server\nroot: \"#{ $APP_ROOT_DIR }/public\"\n```\n\nCaddy supports runtime environment variables via [`{env.*}` placeholders](https://caddyserver.com/docs/caddyfile/concepts#environment-variables).\n\n### Example Config\n\nCheck the [test YAML configuration file](https://github.com/abiosoft/caddy-yaml/blob/master/testdata/test.caddy.yaml).\n\n## License\n\nApache 2\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabiosoft%2Fcaddy-yaml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabiosoft%2Fcaddy-yaml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabiosoft%2Fcaddy-yaml/lists"}