Skip to content

Commit 32fb269

Browse files
authored
remove flags from storage commands (#1243)
* remove flags from storage commands * remove unused declarations
1 parent 9af034b commit 32fb269

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

src/odo.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class Command {
107107
static listCatalogServicesJson () {
108108
return `${Command.listCatalogServices()} -o json`;
109109
}
110-
static listStorageNames(project: string, app: string, component: string) {
110+
static listStorageNames() {
111111
return `odo storage list -o json`;
112112
}
113113
static printOcVersion() {
@@ -141,11 +141,11 @@ export class Command {
141141
return `odo login ${clusterURL} --token=${ocToken} --insecure-skip-tls-verify`;
142142
}
143143
@verbose
144-
static createStorage(project: string, app: string, component: string, storageName: string, mountPath: string, storageSize: string) {
145-
return `odo storage create ${storageName} --path=${mountPath} --size=${storageSize} --project ${project} --app ${app} --component ${component}`;
144+
static createStorage(storageName: string, mountPath: string, storageSize: string) {
145+
return `odo storage create ${storageName} --path=${mountPath} --size=${storageSize}}`;
146146
}
147-
static deleteStorage(project: string, app: string, component: string, storage: string) {
148-
return `odo storage delete ${storage} -f --project ${project} --app ${app} --component ${component}`;
147+
static deleteStorage(storage: string) {
148+
return `odo storage delete ${storage} -f`;
149149
}
150150
static waitForStorageToBeGone(project: string, app: string, storage: string) {
151151
return `oc wait pvc/${storage}-${app}-pvc --for=delete --namespace ${project}`;
@@ -761,10 +761,7 @@ export class OdoImpl implements Odo {
761761
}
762762

763763
public async _getStorageNames(component: OpenShiftObject): Promise<OpenShiftObject[]> {
764-
const app = component.getParent();
765-
const appName = app.getName();
766-
const projName = app.getParent().getName();
767-
const result: cliInstance.CliExitData = await this.execute(Command.listStorageNames(projName, appName, component.getName()), component.contextPath ? component.contextPath.fsPath : Platform.getUserHomePath());
764+
const result: cliInstance.CliExitData = await this.execute(Command.listStorageNames(), component.contextPath ? component.contextPath.fsPath : Platform.getUserHomePath());
768765
return this.loadItems(result).map<OpenShiftObject>((value) => new OpenShiftObjectImpl(component, value.metadata.name, ContextType.STORAGE, false, OdoImpl.instance, TreeItemCollapsibleState.None));
769766
}
770767

@@ -1022,13 +1019,13 @@ export class OdoImpl implements Odo {
10221019
}
10231020

10241021
public async createStorage(component: OpenShiftObject, name: string, mountPath: string, size: string): Promise<OpenShiftObject> {
1025-
await this.execute(Command.createStorage(component.getParent().getParent().getName(), component.getParent().getName(), component.getName(), name, mountPath, size), component.contextPath.fsPath);
1022+
await this.execute(Command.createStorage(name, mountPath, size), component.contextPath.fsPath);
10261023
return this.insertAndReveal(new OpenShiftObjectImpl(component, name, ContextType.STORAGE, false, this, TreeItemCollapsibleState.None));
10271024
}
10281025

10291026
public async deleteStorage(storage: OpenShiftObject): Promise<OpenShiftObject> {
10301027
const component = storage.getParent();
1031-
await this.execute(Command.deleteStorage(component.getParent().getParent().getName(), component.getParent().getName(), component.getName(), storage.getName()), component.contextPath.fsPath);
1028+
await this.execute(Command.deleteStorage(storage.getName()), component.contextPath.fsPath);
10321029
await this.execute(Command.waitForStorageToBeGone(storage.getParent().getParent().getParent().getName(), storage.getParent().getParent().getName(), storage.getName()), process.cwd(), false);
10331030
return this.deleteAndRefresh(storage);
10341031
}

src/openshift/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ export class Component extends OpenShiftItem {
563563
const pvcJson = JSON.parse(pvcResult.stdout);
564564
const storageName = pvcJson.metadata.labels['app.kubernetes.io/storage-name'];
565565
const size = pvcJson.spec.resources.requests.storage;
566-
await Component.odo.execute(Command.createStorage(prjName, appName, compName, storageName, storage.mountPath, size), workspaceFolder.fsPath);
566+
await Component.odo.execute(Command.createStorage(storageName, storage.mountPath, size), workspaceFolder.fsPath);
567567
} catch (ignore) {
568568
// means there is no storage attached to component
569569
}

test/unit/openshift/storage.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ suite('OpenShift/Storage', () => {
153153
const result = await Storage.create(componentItem);
154154

155155
expect(result).equals(`Storage '${storageItem.getName()}' successfully created for Component '${componentItem.getName()}'`);
156-
expect(execStub).calledOnceWith(Command.createStorage(projectItem.getName(), appItem.getName(), componentItem.getName(), storageItem.getName(), mountPath, size));
156+
expect(execStub).calledOnceWith(Command.createStorage(storageItem.getName(), mountPath, size));
157157
});
158158

159159
test('returns null when no storage name selected', async () => {
@@ -306,15 +306,15 @@ suite('OpenShift/Storage', () => {
306306
const result = await Storage.del(storageItem);
307307

308308
expect(result).equals(`Storage '${storageItem.getName()}' from Component '${componentItem.getName()}' successfully deleted`);
309-
expect(execStub.getCall(0).args[0]).equals(Command.deleteStorage(projectItem.getName(), appItem.getName(), componentItem.getName(), storageItem.getName()));
309+
expect(execStub.getCall(0).args[0]).equals(Command.deleteStorage(storageItem.getName()));
310310
expect(execStub.getCall(1).args[0]).equals(Command.waitForStorageToBeGone(projectItem.getName(), appItem.getName(), storageItem.getName()));
311311
});
312312

313313
test('works without set tree item', async () => {
314314
const result = await Storage.del(null);
315315

316316
expect(result).equals(`Storage '${storageItem.getName()}' from Component '${componentItem.getName()}' successfully deleted`);
317-
expect(execStub.getCall(0).args[0]).equals(Command.deleteStorage(projectItem.getName(), appItem.getName(), componentItem.getName(), storageItem.getName()));
317+
expect(execStub.getCall(0).args[0]).equals(Command.deleteStorage(storageItem.getName()));
318318
expect(execStub.getCall(1).args[0]).equals(Command.waitForStorageToBeGone(projectItem.getName(), appItem.getName(), storageItem.getName()));
319319
});
320320

0 commit comments

Comments
 (0)