diff --git a/README.md b/README.md index 429f7157..e9c6b487 100644 --- a/README.md +++ b/README.md @@ -36,16 +36,16 @@ jobs: ### Required input parameters -| Parameter | Description | -| --------- | ----------- | +| Parameter | Description | +|--------------|-----------------------------------------------------------------------------| | `oc version` | OpenShift [version](https://github.com/openshift/origin/releases) to deploy | ### Optional input parameters -| Parameter | Description | -| --------- | ----------- | -| `dns ip` | External DNS server IP to use in node-config.yaml | -| `enable` | A list of components to enable (comma separated) | +| Parameter | Description | +|----------------|------------------------------------------------------------------------------------------| +| `dns ip` | External DNS server IP to use in node-config.yaml | +| `enable` | A list of components to enable (comma separated) | | `github token` | GITHUB_TOKEN secret value to access GitHub REST API with an unlimited number of requests | ## License diff --git a/src/__tests__/install.test.js b/src/__tests__/install.test.js index e627ebd1..162c8d4e 100644 --- a/src/__tests__/install.test.js +++ b/src/__tests__/install.test.js @@ -27,12 +27,49 @@ describe('install module test suite', () => { }); describe('install', () => { let openshiftTar; + let inputs; beforeEach(() => { openshiftTar = 'openshift.tar'; + inputs = { + ocVersion: 'v3.11.0' + }; }); - test('no inputs, should launch standard cluster up command', async () => { - // Given - const inputs = {}; + describe('prerequisites', () => { + beforeEach(async () => { + await install({openshiftTar, inputs}); + }); + test('origin-control-plane image is pulled from Quay.io', async () => { + expect(exec.logExecSync).toHaveBeenCalledWith( + 'docker pull quay.io/openshift/origin-control-plane:v3.11.0' + ); + }); + test('origin-cli image is pulled from Quay.io', async () => { + expect(exec.logExecSync).toHaveBeenCalledWith( + 'docker pull quay.io/openshift/origin-cli:v3.11.0' + ); + }); + test('origin-node image is pulled from Quay.io', async () => { + expect(exec.logExecSync).toHaveBeenCalledWith( + 'docker pull quay.io/openshift/origin-node:v3.11.0' + ); + }); + test('origin-control-plane image is tagged without registry', async () => { + expect(exec.logExecSync).toHaveBeenCalledWith( + 'docker tag quay.io/openshift/origin-control-plane:v3.11.0 openshift/origin-control-plane:v3.11' + ); + }); + test('origin-node image is tagged without registry', async () => { + expect(exec.logExecSync).toHaveBeenCalledWith( + 'docker tag quay.io/openshift/origin-node:v3.11.0 openshift/origin-node:v3.11' + ); + }); + test('origin-cli image is tagged without registry', async () => { + expect(exec.logExecSync).toHaveBeenCalledWith( + 'docker tag quay.io/openshift/origin-cli:v3.11.0 openshift/origin-cli:v3.11' + ); + }); + }); + test('defaults, should launch standard cluster up command', async () => { // When await install({openshiftTar, inputs}); // Then @@ -54,9 +91,7 @@ describe('install module test suite', () => { }); test('withDnsIp, should launch standard cluster up command + stop + fix dns and relaunch', async () => { // Given - const inputs = { - dnsIp: '1.1.1.1' - }; + inputs.dnsIp = '1.1.1.1'; // When await install({openshiftTar, inputs}); // Then @@ -79,9 +114,7 @@ describe('install module test suite', () => { }); test('enable, should launch standard cluster up command with extra arguments to enable components', async () => { // Given - const inputs = { - enable: 'component1,-component2,component-3' - }; + inputs.enable = 'component1,-component2,component-3'; // When await install({openshiftTar, inputs}); // Then diff --git a/src/install.js b/src/install.js index 64886b55..3c717a65 100644 --- a/src/install.js +++ b/src/install.js @@ -3,6 +3,7 @@ const core = require('@actions/core'); const tc = require('@actions/tool-cache'); const fs = require('fs'); +const SemVer = require('semver'); const {execSync, logExecSync} = require('./exec'); const getClusterDir = cwd => { @@ -32,7 +33,19 @@ const replaceDnsIp = (clusterDir, dnsIp) => { fs.writeFileSync(kubeDnsResolvConf, customResolv); }; +const prePullImages = version => { + for (const image of ['origin-control-plane', 'origin-cli', 'origin-node']) { + logExecSync(`docker pull quay.io/openshift/${image}:${version}`); + const semver = new SemVer(version); + const major = semver.major; + const minor = semver.minor; + logExecSync(`docker tag quay.io/openshift/${image}:${version} openshift/${image}:v${major}.${minor}`); + } +}; + const install = async ({openshiftTar, inputs}) => { + core.info('Pulling required images from Quay'); + prePullImages(inputs.ocVersion); core.info('Installing OpenShift Cluster'); const cwd = execSync(`pwd`).toString().replace(/[\n\r]/g, ''); core.info(`Current working directory: ${cwd}`);