Skip to content

Commit

Permalink
Merge pull request #7462 from mook-as/docker-cli/lima-plugin-dir-rd-bin
Browse files Browse the repository at this point in the history
Unix integration: Symlink docker CLI plugins to bin
  • Loading branch information
jandubois authored Sep 11, 2024
2 parents 6693cfc + 33750b5 commit 3985d2d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
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

0 comments on commit 3985d2d

Please sign in to comment.