Skip to content

Commit

Permalink
Merge pull request #459 from weaveworks/suppress-debug-option
Browse files Browse the repository at this point in the history
(Prerelease) Suppress debug option
  • Loading branch information
Kingdon Barrett authored Jul 31, 2023
2 parents e6e2494 + 36c8cb2 commit d61f2be
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@
"default": true,
"description": "Enable Flux Check (uncheck to skip flux check)"
},
"gitops.suppressDebugMessages": {
"type": "boolean",
"default": false,
"description": "Do not emit debug-level messages (only error, info, warn)"
},
"gitops.weaveGitopsEnterprise": {
"type": "boolean",
"default": false,
Expand Down
6 changes: 4 additions & 2 deletions src/cli/checkVersions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { commands, Uri, window } from 'vscode';

import { enabledWGE, telemetry, enabledFluxChecks } from 'extension';
import { enabledWGE, telemetry, enabledFluxChecks, suppressDebugMessages } from 'extension';
import { Errorable, failed } from 'types/errorable';
import { CommandId } from 'types/extensionIds';
import { TelemetryError } from 'types/telemetryEventNames';
Expand Down Expand Up @@ -114,7 +114,9 @@ export async function checkFluxPrerequisites() {
}
}
} else {
window.showInformationMessage('DEBUG: not running `flux check`');
if(!suppressDebugMessages()) {
window.showInformationMessage('DEBUG: not running `flux check`');
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/commands/fluxCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import safesh from 'shell-escape-tag';

import { shell } from 'cli/shell/exec';
import { ClusterNode } from 'ui/treeviews/nodes/cluster/clusterNode';
import { enabledFluxChecks } from 'extension';
import { enabledFluxChecks, suppressDebugMessages } from 'extension';
import { window } from 'vscode';

/**
Expand All @@ -14,6 +14,8 @@ export async function fluxCheck(clusterNode: ClusterNode) {
shell.execWithOutput(safesh`flux check --context ${clusterNode.context.name}`);
} else {
// user called for health checking, notify them it isn't being performed
window.showInformationMessage('DEBUG: not running `flux check`');
if(!suppressDebugMessages()) {
window.showInformationMessage('DEBUG: not running `flux check`');
}
}
}
9 changes: 9 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ export function enabledFluxChecks(): boolean {
}
}

export function suppressDebugMessages(): boolean {
let ret = workspace.getConfiguration('gitops').get('suppressDebugMessages');
if(ret === true) {
return true;
} else {
return false;
}
}


/**
* Called when extension is deactivated.
Expand Down
6 changes: 4 additions & 2 deletions src/ui/treeviews/dataProviders/clusterDataProvider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fluxTools } from 'cli/flux/fluxTools';
import { getFluxControllers } from 'cli/kubernetes/kubectlGet';
import { kubeConfig } from 'cli/kubernetes/kubernetesConfig';
import { enabledFluxChecks, setVSCodeContext } from 'extension';
import { enabledFluxChecks, setVSCodeContext, suppressDebugMessages } from 'extension';
import { ContextId } from 'types/extensionIds';
import { statusBar } from 'ui/statusBar';
import { TreeItem, window } from 'vscode';
Expand Down Expand Up @@ -138,7 +138,9 @@ export class ClusterDataProvider extends DataProvider {
refreshClustersTreeView(clusterController);
}
} else {
window.showInformationMessage('DEBUG: not running `flux check`');
if(!suppressDebugMessages()) {
window.showInformationMessage('DEBUG: not running `flux check`');
}
}
}
}

0 comments on commit d61f2be

Please sign in to comment.