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: misc fixes to download function #80

Merged
merged 1 commit into from
Dec 23, 2022
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
14 changes: 9 additions & 5 deletions src/__tests__/download.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,21 @@ describe('download module test suite', () => {
)
);
expect(exec.logExecSync).toHaveBeenCalledWith(
'sudo ln -s /usr/local/bin/cri-dockerd /usr/bin/cri-dockerd'
'sudo ln -sf /usr/local/bin/cri-dockerd /usr/bin/cri-dockerd'
);
});
test('should install cri-dockerd service', async () => {
// Given
fs.readFileSync.mockImplementation(
() =>
'ExecStart=/usr/bin/cri-dockerd --container-runtime-endpoint fd://'
);
// When
await download.installCriDockerd({githubToken: 'secret-token'});
// Then
expect(exec.logExecSync).toHaveBeenCalledWith(
expect.stringMatching(
/sed -i 's\/cri-dockerd --\/cri-dockerd --network-plugin=cni --\/g'/
)
expect(fs.writeFileSync).toHaveBeenCalledWith(
'/etc/systemd/system/cri-docker.service',
'ExecStart=/usr/bin/cri-dockerd --network-plugin=cni --container-runtime-endpoint fd://'
);
expect(exec.logExecSync).toHaveBeenCalledWith(
expect.stringMatching(
Expand Down
5 changes: 2 additions & 3 deletions src/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,15 @@ const installCriDockerd = async (inputs = {}) => {
const binaryDir = await tc.extractTar(binaryTar);
const binaryContent = firstDir(binaryDir);
logExecSync(`sudo cp -a ${binaryDir}/${binaryContent}/cri-dockerd /usr/local/bin/`);
logExecSync(`sudo ln -s /usr/local/bin/cri-dockerd /usr/bin/cri-dockerd`);
logExecSync(`sudo ln -sf /usr/local/bin/cri-dockerd /usr/bin/cri-dockerd`);
// Service file
const sourceTar = await tc.downloadTool(`https://github.com/Mirantis/cri-dockerd/archive/refs/tags/${tag}.tar.gz`);
const sourceDir = await tc.extractTar(sourceTar);
const sourceContent = firstDir(sourceDir);
logExecSync(`sed -i 's/cri-dockerd --/cri-dockerd --network-plugin=cni --/g' ${sourceDir}/${sourceContent}/packaging/systemd/cri-docker.service`);
logExecSync(`sudo cp -a ${sourceDir}/${sourceContent}/packaging/systemd/* /etc/systemd/system`);
const serviceFile = '/etc/systemd/system/cri-docker.service';
fs.writeFileSync(serviceFile, fs.readFileSync(serviceFile).toString()
.replace(/\/usr\/bin\/cri-dockerd/g, '/usr/local/bin/cri-dockerd')
.replace(/cri-dockerd --/g, 'cri-dockerd --network-plugin=cni --')
);
const socketFile = '/etc/systemd/system/cri-docker.socket';
fs.writeFileSync(socketFile, fs.readFileSync(socketFile).toString()
Expand Down