From 4d39b54fcc6a41c0eb70230e8c02d5f20669f42a Mon Sep 17 00:00:00 2001 From: David Kwon Date: Mon, 2 May 2022 18:51:56 +0000 Subject: [PATCH 1/2] fix: edit command when entrypoint is tweaked Signed-off-by: David Kwon --- .../src/devfile/dev-container-component-updater.ts | 3 ++- .../tests/devfile/dev-container-component-updater.spec.ts | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/devworkspace-handler/src/devfile/dev-container-component-updater.ts b/tools/devworkspace-handler/src/devfile/dev-container-component-updater.ts index f047bfebc..7ccdd099e 100644 --- a/tools/devworkspace-handler/src/devfile/dev-container-component-updater.ts +++ b/tools/devworkspace-handler/src/devfile/dev-container-component-updater.ts @@ -92,7 +92,8 @@ export class DevContainerComponentUpdater { }); // need to tweak the entrypoint to call the ${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE} - devContainer.args = ['sh', '-c', '${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}']; + devContainer.command = ['sh', '-c']; + devContainer.args = ['${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}']; // now, need to add the common stuff this.containerPluginRemoteUpdater.update(devContainerComponent.name, devContainer); diff --git a/tools/devworkspace-handler/tests/devfile/dev-container-component-updater.spec.ts b/tools/devworkspace-handler/tests/devfile/dev-container-component-updater.spec.ts index 90170f4e2..a2f7e28cf 100644 --- a/tools/devworkspace-handler/tests/devfile/dev-container-component-updater.spec.ts +++ b/tools/devworkspace-handler/tests/devfile/dev-container-component-updater.spec.ts @@ -78,6 +78,7 @@ describe('Test DevContainerComponentUpdater', () => { path: '/existing', }, ], + command: ['tail'], }, }; devContainerComponentFinderFindMethod.mockResolvedValue(devContainerComponent); @@ -137,7 +138,8 @@ describe('Test DevContainerComponentUpdater', () => { }, ]); // args updated - expect(devContainerComponent?.container?.args).toStrictEqual(['sh', '-c', '${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}']); + expect(devContainerComponent?.container?.command).toEqual(['sh', '-c']); + expect(devContainerComponent?.container?.args).toStrictEqual(['${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}']); // check we have a new volume added const components = devfileContext.devWorkspace.spec?.template?.components || []; @@ -169,7 +171,8 @@ describe('Test DevContainerComponentUpdater', () => { expect(devContainerComponent?.container?.endpoints).toBeUndefined(); expect(devContainerComponent?.container?.volumeMounts).toBeUndefined(); // args updated - expect(devContainerComponent?.container?.args).toStrictEqual(['sh', '-c', '${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}']); + expect(devContainerComponent?.container?.command).toEqual(['sh', '-c']); + expect(devContainerComponent?.container?.args).toStrictEqual(['${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}']); }); test('not a dev container', async () => { From 69622af04d9062bb1b220af019d1fb823b38d292 Mon Sep 17 00:00:00 2001 From: David Kwon Date: Tue, 3 May 2022 10:51:45 -0400 Subject: [PATCH 2/2] Use toStrictEqual Signed-off-by: David Kwon --- .../tests/devfile/dev-container-component-updater.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/devworkspace-handler/tests/devfile/dev-container-component-updater.spec.ts b/tools/devworkspace-handler/tests/devfile/dev-container-component-updater.spec.ts index a2f7e28cf..65d0a32d9 100644 --- a/tools/devworkspace-handler/tests/devfile/dev-container-component-updater.spec.ts +++ b/tools/devworkspace-handler/tests/devfile/dev-container-component-updater.spec.ts @@ -138,7 +138,7 @@ describe('Test DevContainerComponentUpdater', () => { }, ]); // args updated - expect(devContainerComponent?.container?.command).toEqual(['sh', '-c']); + expect(devContainerComponent?.container?.command).toStrictEqual(['sh', '-c']); expect(devContainerComponent?.container?.args).toStrictEqual(['${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}']); // check we have a new volume added @@ -171,7 +171,7 @@ describe('Test DevContainerComponentUpdater', () => { expect(devContainerComponent?.container?.endpoints).toBeUndefined(); expect(devContainerComponent?.container?.volumeMounts).toBeUndefined(); // args updated - expect(devContainerComponent?.container?.command).toEqual(['sh', '-c']); + expect(devContainerComponent?.container?.command).toStrictEqual(['sh', '-c']); expect(devContainerComponent?.container?.args).toStrictEqual(['${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}']); });