@adp-psych/container-tools
Version:
Tools for using containers for psychology experiments
84 lines (76 loc) • 2.25 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 [Wave](https://https://github.com/wave-k8s/wave)
* to a [Kubernetes](https://kubernetes.io/) cluster
* using [Helm](https://helm.sh/).
*
* @module module:install-wave
* @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 {
addRepository,
updateRepositories,
upgradeInstall,
} = require('./helm.js');
/**
* The name of the repository containing the Helm chart.
*
* @constant {String}
* @static
* @access protected
*/
const REPOSITORY_NAME = 'wave';
/**
* The URL of the repository containing the Helm chart.
*
* @constant {String}
* @static
* @access protected
*/
const REPOSITORY_URL = 'https://wave-k8s.github.io/wave/';
/**
* Installs/upgrades Wave using Helm.
*
* @static
* @access protected
* @param {String} version - The version of Wave to install.
* @example
* // Installs/upgrades Wave to version 2.0.0.
* helmUpgradeWave('2.0.0');
*/
const helmUpgradeWave = async (version) => {
await upgradeInstall('wave', 'wave/wave', [`--version=${version}`]);
};
/**
* Installs/upgrades Wave using Helm.
*
* @static
* @param {String} version - The version of Wave to install.
* @example
* // Installs/upgrades Wave to version 2.0.0.
* installWave('2.0.0');
*/
const installWave = async (version) => {
await addRepository(REPOSITORY_NAME, REPOSITORY_URL);
await updateRepositories();
await helmUpgradeWave(version);
};
module.exports = installWave;