UNPKG

@adp-psych/container-tools

Version:

Tools for using containers for psychology experiments

74 lines (63 loc) 2.22 kB
#!/usr/bin/env node /* * Copyright (C) 2021, 2022 Anthony Di Pietro * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ /** * @file Installs [ExternalDNS](https://github.com/kubernetes-sigs/external-dns) * to a [Kubernetes](https://kubernetes.io/) cluster * using [Helm](https://helm.sh/). * * @requires install-external-dns * @author Anthony Di Pietro <anthony.dipietro@research.uwa.edu.au> * @copyright © 2021, 2022 Anthony Di Pietro * @license AGPL-3.0-or-later */ const dotenv = require('dotenv-defaults'); const installExternalDns = require('../lib/install-external-dns.js'); const BINARY_NAME = 'install-external-dns'; const DEFAULT_EXTERNAL_DNS_VERSION = '6.7.2'; const usage = () => { console.error(`Usage: ${BINARY_NAME} [version]`); console.error(''); console.error(`Example: ${BINARY_NAME} 6.7.2`); console.error(''); console.error('The DIGITALOCEAN_DNS_API_TOKEN environment variable'); console.error('must contain the DigitalOcean API token.'); }; const main = async () => { const version = process.argv[2] ?? DEFAULT_EXTERNAL_DNS_VERSION; if (version === '--help' || version === '-h') { usage(); } else { dotenv.config(); const apiToken = process.env.DIGITALOCEAN_DNS_API_TOKEN; if (typeof apiToken === 'undefined') { usage(); process.exitCode = 1; } else { try { await installExternalDns(version, apiToken); } catch (error) { /* eslint-disable require-atomic-updates -- * False positive. */ process.exitCode = error; /* eslint-enable require-atomic-updates -- * Reenabling. */ } } } }; main();