Skip to content

Commit

Permalink
chore: fix auth file registry removal (podman-desktop#7746)
Browse files Browse the repository at this point in the history
### What does this PR do?

Removes the dispose for registerRegistry which was causing an unregister
on shut down resulting in the auth file deletion.

### Screenshot / video of UI

<!-- If this PR is changing UI, please include
screenshots or screencasts showing the difference -->

N/lA

### What issues does this PR fix or reference?

<!-- Include any related issues from Podman Desktop
repository (or from another issue tracker). -->

Closes podman-desktop#7742

### How to test this PR?

<!-- Please explain steps to verify the functionality,
do not forget to provide unit/component tests -->

- [X] Tests are covering the bug fix or the new feature

Signed-off-by: Charlie Drage <[email protected]>
  • Loading branch information
cdrage authored Jun 19, 2024
1 parent 0ec8499 commit 5e9003e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
23 changes: 22 additions & 1 deletion packages/main/src/plugin/extension-loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ const configurationRegistry: ConfigurationRegistry = {
updateConfigurationValue: configurationRegistryUpdateConfigurationMock,
} as unknown as ConfigurationRegistry;

const imageRegistry: ImageRegistry = {} as unknown as ImageRegistry;
const imageRegistry: ImageRegistry = {
registerRegistry: vi.fn(),
} as unknown as ImageRegistry;

const apiSender: ApiSenderType = { send: vi.fn() } as unknown as ApiSenderType;

Expand Down Expand Up @@ -2207,3 +2209,22 @@ test('load extensions sequentially', async () => {
expect(loadExtensionMock.mock.calls[1][0]).toBe(analyzedExtension2);
expect(loadExtensionMock.mock.calls[2][0]).toBe(analyzedExtension3);
});

test('when loading registry registerRegistry, do not push to disposables', async () => {
const disposables: IDisposable[] = [];

const api = extensionLoader.createApi('/path', {}, disposables);
expect(api).toBeDefined();

const fakeRegistry = {
source: 'fake',
serverUrl: 'http://fake',
username: 'foo',
password: 'bar',
secret: 'baz',
};

api.registry.registerRegistry(fakeRegistry);

expect(disposables.length).toBe(0);
});
4 changes: 1 addition & 3 deletions packages/main/src/plugin/extension-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -888,9 +888,7 @@ export class ExtensionLoader {
const imageRegistry = this.imageRegistry;
const registry: typeof containerDesktopAPI.registry = {
registerRegistry: (registry: containerDesktopAPI.Registry): Disposable => {
const registration = imageRegistry.registerRegistry(registry);
disposables.push(registration);
return registration;
return imageRegistry.registerRegistry(registry);
},

suggestRegistry: (registry: containerDesktopAPI.RegistrySuggestedProvider): Disposable => {
Expand Down

0 comments on commit 5e9003e

Please sign in to comment.