Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pull missing Docker Hub images from Quay #41

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
51 changes: 42 additions & 9 deletions src/__tests__/install.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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}`);
Expand Down
Loading