azukiapp / azk

azk is a lightweight open source development environment orchestration tool. Instantly & safely run any environment on your local machine.
http://azk.io
Apache License 2.0
897 stars 63 forks source link

[Manifest] Improving support to env vars on http domains #522

Closed fearenales closed 8 years ago

fearenales commented 8 years ago

This PR intends to improve support to env vars on http domains in the Manifest file.

The current behavior is to use the first domain in the http.domains array as the system hostname. However, when using env vars as domains (useful for deployment, as instance), it may break.

The new behavior, removes empty values (in case those env vars are not set) and the use the first one. This way, it's possible to do the following:

Azkfile.js

systems({
  example: {
  // ...
    http: {
      domains: [
        "#{env.HOST_DOMAIN}",
        "#{env.HOST_IP}",
        "#{system.name}.#{azk.default_domain}",
      ]
    }
  }
});
$ HOST_DOMAIN= HOST_IP= azk status
┌───┬─────────┬───────────┬────────────────────┬─────────────────┬─────────────┐
│   │ System  │ Instances │ Hostname/url       │ Instances-Ports │ Provisioned │
├───┼─────────┼───────────┼────────────────────┼─────────────────┼─────────────┤
│ ↓ │ example │ 0         │ example.dev.azk.io │ -               │ -           │
└───┴─────────┴───────────┴────────────────────┴─────────────────┴─────────────┘
$ HOST_DOMAIN= HOST_IP=192.168.0.1 azk status
┌───┬─────────┬───────────┬────────────────────┬─────────────────┬─────────────┐
│   │ System  │ Instances │ Hostname/url       │ Instances-Ports │ Provisioned │
├───┼─────────┼───────────┼────────────────────┼─────────────────┼─────────────┤
│ ↓ │ example │ 0         │ 192.168.0.1        │ -               │ -           │
└───┴─────────┴───────────┴────────────────────┴─────────────────┴─────────────┘
$ HOST_DOMAIN=my.domain.com HOST_IP=192.168.0.1 azk status
┌───┬─────────┬───────────┬────────────────────┬─────────────────┬─────────────┐
│   │ System  │ Instances │ Hostname/url       │ Instances-Ports │ Provisioned │
├───┼─────────┼───────────┼────────────────────┼─────────────────┼─────────────┤
│ ↓ │ example │ 0         │ my.domain.com      │ -               │ -           │
└───┴─────────┴───────────┴────────────────────┴─────────────────┴─────────────┘