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

Independent element for YAML anchors #1738

Closed
ndac-todoroki opened this issue Apr 25, 2018 · 5 comments
Closed

Independent element for YAML anchors #1738

ndac-todoroki opened this issue Apr 25, 2018 · 5 comments

Comments

@ndac-todoroki
Copy link

ndac-todoroki commented Apr 25, 2018

related: #741

Reading the docs, I get that I can define an anchor inside some pre-defined element(s), as shown in the issue above:

hosts:
  "example.com":
    listen:
      port: 443
      ssl:
        certificate-file: /path/to/example.com.crt
        key-file:         /path/to/example.com.crt
    paths:  &default_paths
      "/":
        file.dir: /path/to/doc-root
  "example.org":
    listen:
      port: 443
      ssl:
        certificate-file: /path/to/example.org.crt
        key-file:         /path/to/example.org.crt
    paths:  *default_paths

But it gets harder to read when your config file gets bigger. I tried cutting all anchors out:

anchors:
  https_settings: &https
    port: 443
  default_paths:  &default_paths
    "/":
      file.dir: /path/to/doc-root

hosts:
  "example.com":
    listen:
      <<: *https
      ssl:
        certificate-file: /path/to/example.com.crt
        key-file:         /path/to/example.com.crt
    paths:  *default_paths
  "example.org":
    listen:
      <<: *https
      ssl:
        certificate-file: /path/to/example.org.crt
        key-file:         /path/to/example.org.crt
    paths:  *default_paths

without any luck. I get Apr 25 21:47:27 ip-10-0-0-65 h2o[4530]: [/etc/h2o/h2o.conf:1] unknown command: anchors error logs.

Do we already have some predefined namespace (element) to do things like this? If not, I really want to have something like this, where things included in that particular element (anchors) will just be interpolated.

@i110
Copy link
Contributor

i110 commented Apr 26, 2018

@ndac-todoroki
Copy link
Author

yeah, I'm currently doing that, but dividing everything into pieces of files looks very bad to me (partially because relative paths are not recognized in !file). I don't want to jump around little files just for one row :(

@i110
Copy link
Contributor

i110 commented Apr 26, 2018

I filed #1739, which adds stash directive.

@ksaltik

This comment has been minimized.

@ndac-todoroki
Copy link
Author

I tried the master branch, and seems it works very good! Thanks i110! I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants