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

Unix integration: Symlink docker CLI plugins to bin #7462

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describeUnix('UnixIntegrationManager', () => {
const pluginPath = path.join(dockerCLIPluginDest, name);
const expectedValue = path.join(dockerCLIPluginSource, name);

await expect(fs.promises.readlink(pluginPath, 'utf8')).resolves.toEqual(expectedValue);
await expect(fs.promises.readlink(pluginPath, 'utf8')).resolves.toEqual(binPath);
await expect(fs.promises.readlink(binPath, 'utf8')).resolves.toEqual(expectedValue);
}
});
Expand All @@ -90,7 +90,7 @@ describeUnix('UnixIntegrationManager', () => {
test('should update an existing docker CLI plugin that is a dangling symlink', async() => {
const existingPluginPath = path.join(dockerCLIPluginDest, 'docker-compose');
const nonExistentPath = '/somepaththatshouldnevereverexist';
const expectedTarget = path.join(dockerCLIPluginSource, 'docker-compose');
const expectedTarget = path.join(integrationDir, 'docker-compose');

await fs.promises.mkdir(dockerCLIPluginDest, { mode: 0o755 });
await fs.promises.symlink(nonExistentPath, existingPluginPath);
Expand All @@ -102,13 +102,13 @@ describeUnix('UnixIntegrationManager', () => {
expect(newTarget).toEqual(expectedTarget);
});

test('should update an existing docker CLI plugin whose target is integrations directory', async() => {
test('should update an existing docker CLI plugin whose target is resources directory', async() => {
const existingPluginPath = path.join(dockerCLIPluginDest, 'docker-compose');
const integrationsPath = path.join(integrationDir, 'docker-compose');
const expectedTarget = path.join(dockerCLIPluginSource, 'docker-compose');
const sourceDir = path.join(dockerCLIPluginSource, 'docker-compose');
const expectedTarget = path.join(integrationDir, 'docker-compose');

await fs.promises.mkdir(dockerCLIPluginDest, { mode: 0o755 });
await fs.promises.symlink(integrationsPath, existingPluginPath);
await fs.promises.symlink(sourceDir, existingPluginPath);

await integrationManager.enforce();

Expand Down
4 changes: 3 additions & 1 deletion pkg/rancher-desktop/integrations/unixIntegrationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ export default class UnixIntegrationManager implements IntegrationManager {

// create or remove the plugin links
for (const name of pluginNames) {
const sourcePath = path.join(this.dockerCLIPluginSource, name);
// We create symlinks to the integration directory instead of the file
// directly, to avoid factory reset having to deal with it.
const sourcePath = path.join(this.integrationDir, name);
const destPath = path.join(this.dockerCLIPluginDest, name);

if (!await this.weOwnDockerCliFile(destPath)) {
Expand Down
Loading