Skip to content

Commit

Permalink
Merge pull request #46 from splunk/develop
Browse files Browse the repository at this point in the history
Version 0.2.7
  • Loading branch information
JasonConger authored Aug 28, 2021
2 parents f1eee34 + 2ad79f4 commit 1054f94
Show file tree
Hide file tree
Showing 159 changed files with 69,609 additions and 1,836 deletions.
23 changes: 23 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"env": {
"browser": false,
"commonjs": true,
"es6": true,
"node": true
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module"
},
"rules": {
"no-const-assign": "warn",
"no-this-before-super": "warn",
"no-undef": "warn",
"no-unreachable": "warn",
"no-unused-vars": "warn",
"constructor-super": "warn",
"valid-typeof": "warn"
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ Icon?
*.bak
*.pyc
package-lock.json
conf_diff.py
*.vsix
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

## [0.2.7]
- Added spec files for Splunk 8.1 and 8.2
- Slight code refactor to support unit testing. Also, Mocha unit tests were added.
- Fixed issue where settings containing curly braces (`{}`) did not render choices. Issue [#40](https://github.com/splunk/vscode-extension-splunk/issues/40)
- Fixed syntax highlighting issue for settings that contain a comma (`,`). Issue [#42](https://github.com/splunk/vscode-extension-splunk/issues/42)
- Added support for `eventgen.conf` files. Issue [#27](https://github.com/splunk/vscode-extension-splunk/issues/27)
- Replaced [request](https://www.npmjs.com/package/request) package with [axios](https://www.npmjs.com/package/axios) since request has been deprecated.
- Added dynamic snippets. Issue [#20](https://github.com/splunk/vscode-extension-splunk/issues/20)
- Added snippets for globalConfig.json files.

## [0.2.6]
- Fixed an issue where setting names contained `<name>`. Issue [#33](https://github.com/splunk/vscode-extension-splunk/issues/33)
- Fixed an issue reading serverclass.conf.spec. Issue [#35](https://github.com/splunk/vscode-extension-splunk/issues/35)
Expand Down
13 changes: 13 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"checkJs": false, /* Typecheck .js files. */
"lib": [
"es6"
]
},
"exclude": [
"node_modules"
]
}
58 changes: 25 additions & 33 deletions out/embeddedReportProvider.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vscode = require("vscode");
const request = require("request");
const splunkSavedSearchProvider = require("./savedSearchProvider.js");
const splunkToken = vscode.workspace.getConfiguration().get('splunk.commands.token');
const splunkUrl = vscode.workspace.getConfiguration().get('splunk.commands.splunkRestUrl');
const https = require("https");
const agent = new https.Agent({
rejectUnauthorized: false
});
const axios = require("axios");
axios.defaults.headers.common["Authorization"] = `Bearer ${splunkToken}`;

const splunkSavedSearchProvider = require("./searchProvider.js");

class SplunkReportProvider {
constructor() {
Expand All @@ -27,38 +35,24 @@ exports.SplunkReportProvider = SplunkReportProvider;


async function getSavedSearchEmbedToken(searchLink) {

let splunkUrl = vscode.workspace.getConfiguration().get('splunk.commands.splunkRestUrl');
let splunkToken = vscode.workspace.getConfiguration().get('splunk.commands.token');

if ((!splunkUrl) || (!splunkToken)) {
return [new vscode.TreeItem("Splunk URL and Token required. Check extension settings.")];
}

let embedToken = new Promise(function(resolve, reject){
request(
{
method: "GET",
uri: `${splunkUrl}${searchLink}?output_mode=json&f=embed*`,
strictSSL: false,
headers : {
"Authorization": `Bearer ${splunkToken}`
},
},
function (error, response, body) {
if(error) {
vscode.window.showErrorMessage(error.message);
reject(Error("Could not get saved search. Check extension settings."))
} else {
let search = JSON.parse(body)["entry"][0];
if((search) && (search["content"].hasOwnProperty("embed.token"))) {
resolve(search["content"]["embed.token"]);
}
}
}
);
})

return await(embedToken);
let embedToken = null;

await axios.get(`${splunkUrl}${searchLink}?output_mode=json&f=embed*`, {httpsAgent: agent})
.then(response => {
let search = response.data.entry[0];
if((search) && (search["content"].hasOwnProperty("embed.token"))) {
embedToken = search["content"]["embed.token"]
}
})
.catch(error => {
vscode.window.showErrorMessage(`Could not get saved search. Check extension settings. ${error.message}`);
})
return(embedToken);
}

async function getWebviewContent(search) {
Expand All @@ -76,6 +70,4 @@ async function getWebviewContent(search) {
</html>`;
}

exports.getWebviewContent = getWebviewContent

//# sourceMappingURL=embeddedReportProvider.js.map
exports.getWebviewContent = getWebviewContent
Loading

0 comments on commit 1054f94

Please sign in to comment.