Skip to content

Commit 443c36b

Browse files
committed
Remove resources deployed with previous odo release before odo dev
This PR fixes #2544. Signed-off-by: Denis Golovin dgolovin@redhat.com
1 parent 513944a commit 443c36b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/odo/command.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ function verbose(_: unknown, key: string, descriptor: TypedPropertyDescriptor<Fu
2727

2828
export class Command {
2929

30+
static searchPreviousReleaseResources(name: string): CommandText {
31+
return new CommandText('oc get', 'deployment', [
32+
new CommandOption('-o', `jsonpath="{range .items[?(.metadata.labels.component=='${name}')]}{.metadata.labels.app\\.kubernetes\\.io\\/managed-by}{':'}{.metadata.labels.app\\.kubernetes\\.io\\/managed-by-version}{end}"`)
33+
]);
34+
}
35+
36+
static deletePreviouslyPushedResouces(name: string): CommandText {
37+
return new CommandText('oc delete', 'deployment', [
38+
new CommandOption('-l', `component='${name}'`),
39+
new CommandOption('--cascade')
40+
])
41+
}
42+
3043
static deploy(): CommandText {
3144
return new CommandText('odo', 'deploy');
3245
}

src/openshift/component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ export class Component extends OpenShiftItem {
190190

191191
@vsCommand('openshift.component.dev')
192192
//@clusterRequired() check for user is logged in should be implemented from scratch
193-
static dev(component: ComponentWorkspaceFolder) {
193+
static async dev(component: ComponentWorkspaceFolder) {
194194
const cs = Component.getComponentDevState(component);
195195
cs.devStatus = ComponentContextState.DEV_STARTING;
196196
Component.stateChanged.fire(component.contextPath)
197+
await Component.odo.execute(Command.deletePreviouslyPushedResouces(component.component.devfileData.devfile.metadata.name), undefined, false);
197198
const outputEmitter = new EventEmitter<string>();
198199
let devProcess: ChildProcess;
199200
try {

0 commit comments

Comments
 (0)