Skip to content

Commit

Permalink
Added Run, undeploy and configure function command
Browse files Browse the repository at this point in the history
  • Loading branch information
sudhirverma committed Apr 25, 2022
1 parent 9ea9fb5 commit b348b08
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
17 changes: 10 additions & 7 deletions USAGE_DATA.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

### Usage Data

* when the extension is activated
* when following command(s) contributed by extension is executed
* command's ID
* command's error message (in case of exception)
* command's specific data like kn version, fn version and to check which command user has used.
* when the extension is deactivated
* When the extension is activated
* When following command(s) contributed by extension is executed
* Command's ID
* Command's error message (in case of exception)
* Command's specific data like kn version, fn version and to check which command user has used.
* When the extension is deactivated
* Following are the commands which send data to telemetry.
* Build and Deploy command.
* Create function command.
* Invoke function command.
* Invoke function command.
* Run function command.
* Undeploy function command.
* Configure function command.
5 changes: 5 additions & 0 deletions src/functions/function-command/configure-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { selectFunctionFolder } from './build-and-deploy-function';
import { CliCommand } from '../../cli/cmdCli';
import { knExecutor } from '../../cli/execute';
import { FuncAPI } from '../../cli/func-api';
import { telemetryLog } from '../../telemetry';
import { FunctionNode } from '../function-tree-view/functionsTreeItem';

export const enum ConfigAction {
Expand All @@ -21,15 +22,19 @@ export const VOLUMES = 'Volumes';

function getConfigEnvsCliCommand(action: ConfigAction, funcPath: string) {
if (action === ConfigAction.Add) {
telemetryLog('Function_add_environment_variable', 'Click on add environment variable command');
return FuncAPI.addEnvironmentVariable(funcPath);
}
telemetryLog('Function_remove_environment_variable', 'Click on remove environment variable command');
return FuncAPI.removeEnvironmentVariable(funcPath);
}

function getConfigVolumesCliCommand(action: ConfigAction, funcPath: string) {
if (action === ConfigAction.Add) {
telemetryLog('Function_add_volume', 'Click on add volume command');
return FuncAPI.addVolumes(funcPath);
}
telemetryLog('Function_remove_volume', 'Click on remove volume command');
return FuncAPI.removeVolumes(funcPath);
}

Expand Down
2 changes: 2 additions & 0 deletions src/functions/function-command/run-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

import { knExecutor } from '../../cli/execute';
import { FuncAPI } from '../../cli/func-api';
import { telemetryLog } from '../../telemetry';
import { FunctionNode } from '../function-tree-view/functionsTreeItem';

export async function runFunction(context?: FunctionNode): Promise<void> {
if (!context) {
return null;
}
telemetryLog('Function_run_command', `Function run command click name: ${context.getName()}`);
// TO DO
await knExecutor.executeInTerminal(FuncAPI.runFunc(context.contextPath.fsPath));
}
3 changes: 3 additions & 0 deletions src/functions/function-command/undeploy-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import * as vscode from 'vscode';
import { CliExitData, executeCmdCli } from '../../cli/cmdCli';
import { FuncAPI } from '../../cli/func-api';
import { telemetryLog, telemetryLogError } from '../../telemetry';
import { getStderrString } from '../../util/stderrstring';
import { FunctionNode } from '../function-tree-view/functionsTreeItem';
import { functionExplorer } from '../functionsExplorer';
Expand Down Expand Up @@ -36,12 +37,14 @@ export async function undeployFunction(context: FunctionNode): Promise<string> {
vscode.window.showErrorMessage(
`Failed to undeploy function ${context.getName()} - error ${getStderrString(result.error)}`,
);
telemetryLogError('Function_undeploy_error', getStderrString(result.error));
return null;
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
vscode.window.showInformationMessage(`Function ${context.getName()} successfully undeployed`);
// eslint-disable-next-line @typescript-eslint/no-floating-promises
functionExplorer.refresh();
telemetryLog('Function_successfully_undeploy', context.getName());
return null;
},
);
Expand Down

0 comments on commit b348b08

Please # to comment.