fix dos/unix line ending

This commit is contained in:
Tom Limoncelli 2020-03-10 11:46:09 -04:00
parent 4edf360854
commit e6390c67d7

View file

@ -1,78 +1,78 @@
--- ---
name: require name: require
parameters: parameters:
- path - path
--- ---
`require(...)` behaves similarly to its equivalent in node.js. You can use it `require(...)` behaves similarly to its equivalent in node.js. You can use it
to split your configuration across multiple files. If the path starts with a to split your configuration across multiple files. If the path starts with a
`.`, it is calculated relative to the current file. For example: `.`, it is calculated relative to the current file. For example:
{% include startExample.html %} {% include startExample.html %}
{% highlight js %} {% highlight js %}
// dnsconfig.js // dnsconfig.js
require('kubernetes/clusters.js'); require('kubernetes/clusters.js');
D("mydomain.net", REG, PROVIDER, D("mydomain.net", REG, PROVIDER,
IncludeKubernetes() IncludeKubernetes()
); );
{%endhighlight%} {%endhighlight%}
{% highlight js %} {% highlight js %}
// kubernetes/clusters.js // kubernetes/clusters.js
require('./clusters/prod.js'); require('./clusters/prod.js');
require('./clusters/dev.js'); require('./clusters/dev.js');
function IncludeKubernetes() { function IncludeKubernetes() {
return [includeK8Sprod(), includeK8Sdev()]; return [includeK8Sprod(), includeK8Sdev()];
} }
{%endhighlight%} {%endhighlight%}
{% highlight js %} {% highlight js %}
// kubernetes/clusters/prod.js // kubernetes/clusters/prod.js
function includeK8Sprod() { function includeK8Sprod() {
return [ /* ... */ ]; return [ /* ... */ ];
} }
{%endhighlight%} {%endhighlight%}
{% highlight js %} {% highlight js %}
// kubernetes/clusters/dev.js // kubernetes/clusters/dev.js
function includeK8Sdev() { function includeK8Sdev() {
return [ /* ... */ ]; return [ /* ... */ ];
} }
{%endhighlight%} {%endhighlight%}
{% include endExample.html %} {% include endExample.html %}
You can also use it to require json files and initialize variables with it: You can also use it to require json files and initialize variables with it:
For Example: For Example:
{% include startExample.html %} {% include startExample.html %}
{% highlight js %} {% highlight js %}
// dnsconfig.js // dnsconfig.js
var domains = require('./domain-ip-map.json') var domains = require('./domain-ip-map.json')
for (var domain in domains) { for (var domain in domains) {
D(domain, REG, PROVIDER, D(domain, REG, PROVIDER,
A("@", domains[domain]) A("@", domains[domain])
); );
} }
{%endhighlight%} {%endhighlight%}
{%highlight js %} {%highlight js %}
// domain-ip-map.json // domain-ip-map.json
{ {
"mydomain.net": "1.1.1.1", "mydomain.net": "1.1.1.1",
"myotherdomain.org": "5.5.5.5" "myotherdomain.org": "5.5.5.5"
} }
{%endhighlight} {%endhighlight}
{% include endExample.html %} {% include endExample.html %}