Skip to content

Commit 0a901bc

Browse files
committed
[WIP] remove cycle view -> loader -> functions
Signed-off-by: David Thompson <davthomp@redhat.com>
1 parent bb30328 commit 0a901bc

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

src/serverlessFunction/functionModel.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,15 @@ import { CliChannel } from '../cli';
1111
import { DeploymentConfig } from '../k8s/deploymentConfig';
1212
import { Utils } from './commands';
1313
import { Functions } from './functions';
14-
import { DeployedFunction, FunctionContent, FunctionObject, FunctionStatus } from './types';
15-
16-
export interface View {
17-
refresh(): void;
18-
}
14+
import { DeployedFunction, FunctionContent, FunctionObject, FunctionStatus, FunctionView } from './types';
1915

2016
export class ServerlessFunctionModel implements Disposable {
2117

2218
private watchers: fs.FSWatcher[] = [];
2319
private workspaceWatcher: Disposable;
24-
private view: View;
20+
private view: FunctionView;
2521

26-
public constructor(view: View) {
22+
public constructor(view: FunctionView) {
2723
this.view = view;
2824
this.addWatchers();
2925
this.workspaceWatcher = workspace.onDidChangeWorkspaceFolders((_e) => {

src/serverlessFunction/functions.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
* Licensed under the MIT License. See LICENSE file in the project root for license information.
44
*-----------------------------------------------------------------------------------------------*/
55

6-
import { EventEmitter, Terminal, Uri, commands, window } from 'vscode';
7-
import { ClusterVersion, FunctionContent, FunctionObject, InvokeFunction, RunResponse } from './types';
6+
import { ChildProcess, SpawnOptions } from 'child_process';
87
import validator from 'validator';
9-
import { ServerlessCommand, Utils } from './commands';
10-
import { Platform } from '../util/platform';
11-
import { OdoImpl } from '../odo';
8+
import { commands, EventEmitter, Terminal, Uri, window } from 'vscode';
129
import { CliChannel } from '../cli';
13-
import { ChildProcess, SpawnOptions } from 'child_process';
14-
import { ServerlessFunctionView } from './view';
15-
import { multiStep } from './multiStepInput';
10+
import { OdoImpl } from '../odo';
11+
import { Platform } from '../util/platform';
1612
import { Progress } from '../util/progress';
13+
import { ServerlessCommand, Utils } from './commands';
14+
import { multiStep } from './multiStepInput';
15+
import { ClusterVersion, FunctionContent, FunctionObject, FunctionView, InvokeFunction, RunResponse } from './types';
1716

1817
export class Functions {
1918

@@ -51,7 +50,7 @@ export class Functions {
5150
}
5251
}
5352

54-
public async build(context: FunctionObject): Promise<void> {
53+
public async build(context: FunctionObject, view: FunctionView): Promise<void> {
5554
const exisitingTerminal = this.buildTerminalMap.get(`build-${context.folderURI.fsPath}`);
5655
const outputEmitter = this.buildEmiterMap.get(`build-${context.folderURI.fsPath}`);
5756
if (exisitingTerminal) {
@@ -81,18 +80,18 @@ export class Functions {
8180
});
8281
exisitingProcess.on('exit', () => {
8382
context.hadBuilt = true;
84-
ServerlessFunctionView.getInstance().refresh(context);
83+
view.refresh(context);
8584
outputEmitter.fire('\r\nPress any key to close this terminal\r\n');
8685
});
8786
});
8887
}
8988
});
9089
} else {
91-
await this.buildProcess(context);
90+
await this.buildProcess(context, view);
9291
}
9392
}
9493

95-
private async buildProcess(context: FunctionObject) {
94+
private async buildProcess(context: FunctionObject, view: FunctionView) {
9695
const clusterVersion: ClusterVersion | null = await this.checkOpenShiftCluster();
9796
const buildImage = await this.getImage(context.folderURI);
9897
const outputEmitter = new EventEmitter<string>();
@@ -121,7 +120,7 @@ export class Functions {
121120
});
122121
devProcess.on('exit', () => {
123122
context.hadBuilt = true;
124-
ServerlessFunctionView.getInstance().refresh(context);
123+
view.refresh(context);
125124
outputEmitter.fire('\r\nPress any key to close this terminal\r\n');
126125
});
127126
});
@@ -231,7 +230,7 @@ export class Functions {
231230
}
232231

233232
public async deploy(context: FunctionObject) {
234-
const currentNamespace: string = ServerlessFunctionView.getInstance().getCurrentNameSpace();
233+
const currentNamespace: string = await OdoImpl.Instance.getActiveProject();
235234
const yamlContent = await Utils.getFuncYamlContent(context.folderURI.fsPath);
236235
if (yamlContent) {
237236
const deployedNamespace = yamlContent.deploy?.namespace || undefined;

src/serverlessFunction/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
import { Uri } from 'vscode';
77

8+
export interface FunctionView {
9+
refresh(context?: FunctionObject);
10+
}
11+
812
export interface FunctionContent {
913
name?: string;
1014
deploy?: {

src/serverlessFunction/view.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export class ServerlessFunctionView implements TreeDataProvider<ExplorerItem>, D
218218

219219
@vsCommand('openshift.Serverless.build')
220220
static async buildFunction(context: FunctionObject) {
221-
await Functions.getInstance().build(context);
221+
await Functions.getInstance().build(context, this);
222222
}
223223

224224
@vsCommand('openshift.Serverless.buildAndRun')

0 commit comments

Comments
 (0)