Skip to content

Commit

Permalink
Disable odo telemetry using env variable when running through extensi…
Browse files Browse the repository at this point in the history
…on (#2131)

Signed-off-by: Denis Golovin dgolovin@redhat.com
  • Loading branch information
dgolovin committed May 11, 2021
1 parent 583d506 commit 7470ff4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
8 changes: 0 additions & 8 deletions config/preference.yaml

This file was deleted.

10 changes: 8 additions & 2 deletions src/odo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -761,16 +761,22 @@ export class OdoImpl implements Odo {
return services;
}

public createEnv(): {} {
const env = {...process.env };
env.ODO_DISABLE_TELEMETRY = 'true';
return env;
}

public async executeInTerminal(command: CommandText, cwd: string = process.cwd(), name = 'OpenShift'): Promise<void> {
const [cmd] = `${command}`.split(' ');
const toolLocation = await ToolsConfig.detect(cmd);
const terminal: Terminal = WindowUtil.createTerminal(name, cwd);
const terminal: Terminal = WindowUtil.createTerminal(name, cwd, this.createEnv());
terminal.sendText(toolLocation === cmd ? `${command}` : `${command}`.replace(cmd, `"${toolLocation}"`), true);
terminal.show();
}

public async execute(command: CommandText, cwd?: string, fail = true, addEnv = {}): Promise<cliInstance.CliExitData> {
const env = {...process.env };
const env = this.createEnv();
const commandActual = `${command}`;
const commandPrivacy = `${command.privacyMode(true)}`;
const [cmd] = commandActual.split(' ');
Expand Down
2 changes: 1 addition & 1 deletion test/unit/odo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ suite('odo', () => {
const cwd = 'path/to/some/dir';
await odoCli.execute(command, cwd);

expect(execStub).calledOnceWith(`${command}`, { cwd, env: process.env });
expect(execStub).calledOnceWith(`${command}`, { cwd, env: (odo.getInstance() as odo.OdoImpl).createEnv() });
});

test('execute rejects if an error occurs in the shell command', async () => {
Expand Down

0 comments on commit 7470ff4

Please sign in to comment.