Skip to content

Commit d1857ad

Browse files
committed
Delete components without context using 'oc delete'
This PR fixes #2339. Signed-off-by: Denis Golovin dgolovin@redhat.com
1 parent 666bafb commit d1857ad

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

src/odo.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -910,15 +910,26 @@ export class OdoImpl implements Odo {
910910

911911
public async deleteComponent(component: OpenShiftObject): Promise<OpenShiftObject> {
912912
const app = component.getParent();
913-
await this.execute(
914-
Command.deleteComponent(
915-
app.getParent().getName(),
916-
app.getName(), component.getName(),
917-
!!component.contextPath
918-
),
919-
component.contextPath ? component.contextPath.fsPath : Platform.getUserHomePath()
920-
);
921-
913+
if (component.contextValue === ContextType.COMPONENT_NO_CONTEXT) {
914+
await this.execute(
915+
Command.deleteComponentNoContext(
916+
app.getParent().getName(),
917+
app.getName(),
918+
component.getName()
919+
),
920+
component.contextPath ? component.contextPath.fsPath : Platform.getUserHomePath()
921+
);
922+
} else {
923+
await this.execute(
924+
Command.deleteComponent(
925+
app.getParent().getName(),
926+
app.getName(),
927+
component.getName(),
928+
!!component.contextPath
929+
),
930+
component.contextPath ? component.contextPath.fsPath : Platform.getUserHomePath()
931+
);
932+
}
922933
await this.deleteAndRefresh(component);
923934
const children = await app.getChildren();
924935
if (children.length === 0) {

src/odo/command.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,16 @@ export class Command {
310310
return ct;
311311
}
312312

313+
static deleteComponentNoContext(project: string, app: string, component: string): CommandText {
314+
return new CommandText('oc delete',
315+
'deployment', [
316+
new CommandOption('-n', project),
317+
new CommandOption('-l', `component=${component},app=${app}`),
318+
new CommandOption('--wait=true'),
319+
]
320+
);
321+
}
322+
313323
static describeComponentNoContext(project: string, app: string, component: string): CommandText {
314324
return new CommandText('odo describe',
315325
component, [

src/openshift/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class Component extends OpenShiftItem {
132132

133133
if (value === 'Yes') {
134134
return Progress.execFunctionWithProgress(`Deleting the Component '${component.getName()} '`, async () => {
135-
if (component.contextValue === ContextType.COMPONENT_NO_CONTEXT || component.contextValue === ContextType.COMPONENT_PUSHED || component.kind === ComponentKind.S2I) {
135+
if (component.contextValue === ContextType.COMPONENT_PUSHED || component.kind === ComponentKind.S2I) {
136136
await Component.unlinkAllComponents(component);
137137
}
138138
Component.stopDebugSession(component);

0 commit comments

Comments
 (0)