@adp-psych/container-tools
Version:
Tools for using containers for psychology experiments
82 lines (75 loc) • 2.27 kB
JavaScript
/*
* Copyright (C) 2021 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/upgrades a [Helm](https://helm.sh/) chart.
*
* @module module:helm
* @requires console-exec
* @author Anthony Di Pietro <anthony.dipietro@research.uwa.edu.au>
* @copyright © 2021 Anthony Di Pietro
* @license AGPL-3.0-or-later
*/
const {consoleSpawn} = require('./console-exec.js');
/**
* Adds a Helm repository.
*
* @static
* @param {String} chartName - The name of the repository.
* @param {String} chartUrl - The URL of the repository.
* @example
* // Adds the Bitnami Helm repository.
* addRepository('bitnami', 'https://charts.bitnami.com/bitnami');
*/
const addRepository = async (chartName, chartUrl) => {
await consoleSpawn('helm', ['repo', 'add', chartName, chartUrl]);
};
/**
* Updates the local Helm chart information from the repositories.
*
* @static
* @example
* updateRepositories(); // Updates the local Helm chart information.
*/
const updateRepositories = async () => {
await consoleSpawn('helm', ['repo', 'update']);
};
/**
* Installs/upgrades a Helm chart.
*
* @static
* @param {String} release - The release.
* @param {String} chart - The chart.
* @param {Array.<String>} args - Additional arguments to Helm.
* @example
* // Installs/upgrades cert-manager.
* upgradeInstall('cert-manager', 'jetstack/cert-manager', []);
*/
const upgradeInstall = async (release, chart, args) => {
await consoleSpawn('helm', [
'upgrade',
release,
chart,
'--install',
'--atomic',
...args,
]);
};
module.exports = {
addRepository,
updateRepositories,
upgradeInstall,
};