Skip to content

Commit 7470ff4

Browse files
authored
Disable odo telemetry using env variable when running through extension (#2131)
Signed-off-by: Denis Golovin [email protected]
1 parent 583d506 commit 7470ff4

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

config/preference.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/odo.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,16 +761,22 @@ export class OdoImpl implements Odo {
761761
return services;
762762
}
763763

764+
public createEnv(): {} {
765+
const env = {...process.env };
766+
env.ODO_DISABLE_TELEMETRY = 'true';
767+
return env;
768+
}
769+
764770
public async executeInTerminal(command: CommandText, cwd: string = process.cwd(), name = 'OpenShift'): Promise<void> {
765771
const [cmd] = `${command}`.split(' ');
766772
const toolLocation = await ToolsConfig.detect(cmd);
767-
const terminal: Terminal = WindowUtil.createTerminal(name, cwd);
773+
const terminal: Terminal = WindowUtil.createTerminal(name, cwd, this.createEnv());
768774
terminal.sendText(toolLocation === cmd ? `${command}` : `${command}`.replace(cmd, `"${toolLocation}"`), true);
769775
terminal.show();
770776
}
771777

772778
public async execute(command: CommandText, cwd?: string, fail = true, addEnv = {}): Promise<cliInstance.CliExitData> {
773-
const env = {...process.env };
779+
const env = this.createEnv();
774780
const commandActual = `${command}`;
775781
const commandPrivacy = `${command.privacyMode(true)}`;
776782
const [cmd] = commandActual.split(' ');

test/unit/odo.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ suite('odo', () => {
8989
const cwd = 'path/to/some/dir';
9090
await odoCli.execute(command, cwd);
9191

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

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

0 commit comments

Comments
 (0)