Skip to content

Commit 1054f94

Browse files
authored
Merge pull request #46 from splunk/develop
Version 0.2.7
2 parents f1eee34 + 2ad79f4 commit 1054f94

File tree

159 files changed

+69609
-1836
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+69609
-1836
lines changed

.eslintrc.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"env": {
3+
"browser": false,
4+
"commonjs": true,
5+
"es6": true,
6+
"node": true
7+
},
8+
"parserOptions": {
9+
"ecmaFeatures": {
10+
"jsx": true
11+
},
12+
"sourceType": "module"
13+
},
14+
"rules": {
15+
"no-const-assign": "warn",
16+
"no-this-before-super": "warn",
17+
"no-undef": "warn",
18+
"no-unreachable": "warn",
19+
"no-unused-vars": "warn",
20+
"constructor-super": "warn",
21+
"valid-typeof": "warn"
22+
}
23+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ Icon?
1313
*.bak
1414
*.pyc
1515
package-lock.json
16+
conf_diff.py
17+
*.vsix

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Change Log
22

3+
## [0.2.7]
4+
- Added spec files for Splunk 8.1 and 8.2
5+
- Slight code refactor to support unit testing. Also, Mocha unit tests were added.
6+
- Fixed issue where settings containing curly braces (`{}`) did not render choices. Issue [#40](https://github.com/splunk/vscode-extension-splunk/issues/40)
7+
- Fixed syntax highlighting issue for settings that contain a comma (`,`). Issue [#42](https://github.com/splunk/vscode-extension-splunk/issues/42)
8+
- Added support for `eventgen.conf` files. Issue [#27](https://github.com/splunk/vscode-extension-splunk/issues/27)
9+
- Replaced [request](https://www.npmjs.com/package/request) package with [axios](https://www.npmjs.com/package/axios) since request has been deprecated.
10+
- Added dynamic snippets. Issue [#20](https://github.com/splunk/vscode-extension-splunk/issues/20)
11+
- Added snippets for globalConfig.json files.
12+
313
## [0.2.6]
414
- Fixed an issue where setting names contained `<name>`. Issue [#33](https://github.com/splunk/vscode-extension-splunk/issues/33)
515
- Fixed an issue reading serverclass.conf.spec. Issue [#35](https://github.com/splunk/vscode-extension-splunk/issues/35)

jsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es6",
5+
"checkJs": false, /* Typecheck .js files. */
6+
"lib": [
7+
"es6"
8+
]
9+
},
10+
"exclude": [
11+
"node_modules"
12+
]
13+
}

out/embeddedReportProvider.js

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
33
const vscode = require("vscode");
4-
const request = require("request");
5-
const splunkSavedSearchProvider = require("./savedSearchProvider.js");
4+
const splunkToken = vscode.workspace.getConfiguration().get('splunk.commands.token');
5+
const splunkUrl = vscode.workspace.getConfiguration().get('splunk.commands.splunkRestUrl');
6+
const https = require("https");
7+
const agent = new https.Agent({
8+
rejectUnauthorized: false
9+
});
10+
const axios = require("axios");
11+
axios.defaults.headers.common["Authorization"] = `Bearer ${splunkToken}`;
12+
13+
const splunkSavedSearchProvider = require("./searchProvider.js");
614

715
class SplunkReportProvider {
816
constructor() {
@@ -27,38 +35,24 @@ exports.SplunkReportProvider = SplunkReportProvider;
2735

2836

2937
async function getSavedSearchEmbedToken(searchLink) {
30-
31-
let splunkUrl = vscode.workspace.getConfiguration().get('splunk.commands.splunkRestUrl');
32-
let splunkToken = vscode.workspace.getConfiguration().get('splunk.commands.token');
38+
3339
if ((!splunkUrl) || (!splunkToken)) {
3440
return [new vscode.TreeItem("Splunk URL and Token required. Check extension settings.")];
3541
}
36-
37-
let embedToken = new Promise(function(resolve, reject){
38-
request(
39-
{
40-
method: "GET",
41-
uri: `${splunkUrl}${searchLink}?output_mode=json&f=embed*`,
42-
strictSSL: false,
43-
headers : {
44-
"Authorization": `Bearer ${splunkToken}`
45-
},
46-
},
47-
function (error, response, body) {
48-
if(error) {
49-
vscode.window.showErrorMessage(error.message);
50-
reject(Error("Could not get saved search. Check extension settings."))
51-
} else {
52-
let search = JSON.parse(body)["entry"][0];
53-
if((search) && (search["content"].hasOwnProperty("embed.token"))) {
54-
resolve(search["content"]["embed.token"]);
55-
}
56-
}
57-
}
58-
);
59-
})
6042

61-
return await(embedToken);
43+
let embedToken = null;
44+
45+
await axios.get(`${splunkUrl}${searchLink}?output_mode=json&f=embed*`, {httpsAgent: agent})
46+
.then(response => {
47+
let search = response.data.entry[0];
48+
if((search) && (search["content"].hasOwnProperty("embed.token"))) {
49+
embedToken = search["content"]["embed.token"]
50+
}
51+
})
52+
.catch(error => {
53+
vscode.window.showErrorMessage(`Could not get saved search. Check extension settings. ${error.message}`);
54+
})
55+
return(embedToken);
6256
}
6357

6458
async function getWebviewContent(search) {
@@ -76,6 +70,4 @@ async function getWebviewContent(search) {
7670
</html>`;
7771
}
7872

79-
exports.getWebviewContent = getWebviewContent
80-
81-
//# sourceMappingURL=embeddedReportProvider.js.map
73+
exports.getWebviewContent = getWebviewContent

0 commit comments

Comments
 (0)