UNPKG

1.93 kBJavaScriptView Raw
1/**
2 * Copyright 2018 F5 Networks, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17'use strict';
18
19const gtmDnsProvider = require('./gtmDnsProvider');
20
21module.exports = {
22 // It is envisioned that in the future, when there are non-F5 DNS providers,
23 // those providers will live in their own repositories, or perhaps in the
24 // repository of a cloud provider (f5-cloud-libs-aws, for example).
25 // At that time, this function should take a name and path. The path will be
26 // expected to live under f5-cloud-libs/node_modules
27
28 /**
29 * Creates a DNS provider for the given name
30 *
31 * @param {String} name - Name of the provider
32 * @param {Ojbect} [options] - Options for the instance.
33 * @param {Object} [options.clOptions] - Command line options if called from a script.
34 * @param {Object} [options.logger] - Logger to use. Or, pass loggerOptions to get your own logger.
35 * @param {Object} [options.loggerOptions] - Options for the logger.
36 * See {@link module:logger.getLogger} for details.
37 */
38 getDnsProvider(name, options) {
39 let DnsProvider;
40
41 if (name === 'gtm') {
42 DnsProvider = gtmDnsProvider;
43 }
44
45 if (DnsProvider) {
46 return new DnsProvider(options);
47 }
48
49 throw new Error('Unsupported DNS provider');
50 }
51};