Skip to content

Commit

Permalink
feat: recommend settings for log viewer (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
SethFalco authored Sep 27, 2023
1 parent 10b3453 commit 6cb380e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"Juozas Gaigalas <[email protected]>",
"Alexander <[email protected]>",
"Taras Novak <[email protected]>",
"Leonardo Murillo <[email protected]>"
"Leonardo Murillo <[email protected]>",
"Seth Falco <[email protected]>"
],
"publisher": "weaveworks",
"icon": "resources/icons/gitops-logo.png",
Expand Down Expand Up @@ -321,6 +322,11 @@
"type": "string",
"default": "60",
"description": "Seconds until SIGTERM for every shell exec (except `kubectl proxy`). Set to 0 for no timeout."
},
"gitops.ignoreConfigRecommendations": {
"type": "boolean",
"default": false,
"description": "Stop recommending changes to editor or extension settings."
}
}
},
Expand Down
32 changes: 30 additions & 2 deletions src/commands/showLogs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { commands, window } from 'vscode';
import { ConfigurationTarget, commands, window, workspace } from 'vscode';

import { getPodsOfADeployment } from 'cli/kubernetes/kubectlGet';
import { ResourceNode, podResourceKind } from 'types/showLogsTypes';
import { ClusterDeploymentNode } from 'ui/treeviews/nodes/cluster/clusterDeploymentNode';
import { getResourceUri } from 'utils/getResourceUri';
import { ResourceNode, podResourceKind } from 'types/showLogsTypes';

/**
* Show logs in the editor webview (running Kubernetes extension command)
Expand Down Expand Up @@ -31,4 +31,32 @@ export async function showLogs(deploymentNode: ClusterDeploymentNode): Promise<v
};

commands.executeCommand('extension.vsKubernetesLogs', podResourceNode);

const vscGitopsConfig = workspace.getConfiguration('gitops');
if (vscGitopsConfig.get('ignoreConfigRecommendations')) {
return;
}

const vscKubeConfig = workspace.getConfiguration('vscode-kubernetes.log-viewer');
if (vscKubeConfig.get('autorun') && vscKubeConfig.get('follow')) {
return;
}

window.showInformationMessage(
'It\'s recommended to autorun and follow logs by default. Do you want to apply these settings?',
'Apply Settings',
'Never Show Again',
).then(result => {
if (!result) {
return;
}

if (result === 'Never Show Again') {
workspace.getConfiguration('gitops').update('ignoreConfigRecommendations', true, ConfigurationTarget.Global);
return;
}

vscKubeConfig.update('autorun', true, ConfigurationTarget.Global);
vscKubeConfig.update('follow', true, ConfigurationTarget.Global);
});
}

0 comments on commit 6cb380e

Please sign in to comment.