Skip to content

Commit 3789438

Browse files
author
Siegfried Puchbauer
authored
Merge pull request #2 from splunk/next
next version
2 parents cfca534 + 49f71cd commit 3789438

11 files changed

Lines changed: 10782 additions & 3641 deletions

File tree

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,30 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
# ...
15-
- uses: splunk/appinspect-api-action@v1
15+
- uses: splunk/appinspect-api-action@v2
1616
with:
1717
filePath: ./dist/myapp.tar.gz
1818
splunkUser: ${{ secrets.SPLUNKBASE_USER }}
1919
splunkPassword: ${{ secrets.SPLUNKBASE_PASSWORD }}
2020
includedTags: cloud
21+
failOnError: true
22+
failOnWarning: true
2123
```
2224
2325
## Inputs
2426
25-
| Name | Description |
26-
| ---------------- | ------------------------------------------------------------------------------ |
27-
| `filePath` | Path to the app bundle file (.tar.gz or .spl) |
28-
| `splunkUser` | Splunk.com user used to login to the appinspect API |
29-
| `splunkPassword` | Splunk.com password used to login to the appinspect API |
30-
| `includedTags` | Optional: Comma separated list of [tags](#tags) to include in appinspect job |
31-
| `excludedTags` | Optional: Comma separated list of [tags](#tags) to exclude from appinspect job |
32-
33-
### Tags
34-
35-
For more info on tags see [Splunk AppInspect tag reference](https://dev.splunk.com/enterprise/docs/reference/appinspecttagreference).
27+
| Name | Description | Notes |
28+
| ---------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------- |
29+
| `filePath` | Path to the app bundle file (.tar.gz or .spl) | **required** |
30+
| `splunkUser` | Splunk.com user used to login to the appinspect API | **required** |
31+
| `splunkPassword` | Splunk.com password used to login to the appinspect API | **required** |
32+
| `includedTags` | Comma separated list of [tags](#reference-docs) to include in appinspect job | |
33+
| `excludedTags` | Comma separated list of [tags](#reference-docs) to exclude from appinspect job | |
34+
| `failOnError` | If enabled the action will fail when errors or failures are reported by AppInspect | default: `true` |
35+
| `failOnWarning` | If enabled the action will fail when warnings are reported by AppInspect | default: `false` |
36+
| `ignoredChecks` | Comma separated list of [check names](#reference-docs) to explicitly ignore | |
37+
| `uploadReportArtifact` | If enabled the action will upload the HTML report from the AppInspect API as an artifact to GitHub actions | default: `true` |
38+
39+
### Reference Docs
40+
41+
For more info on check critera, tags and the API see the [Splunk AppInspect reference](https://dev.splunk.com/enterprise/reference/appinspect).

action.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,18 @@ inputs:
2020
excludedTags:
2121
description: Comma separated list of tags to exclude from appinspect job
2222
required: false
23+
failOnError:
24+
description: If enabled the action will fail when errors or failures are reported by AppInspect (enabled by default)
25+
required: false
26+
default: 'true'
27+
failOnWarning:
28+
description: If enabled the action will fail when warnings are reported by AppInspect
29+
required: false
30+
default: 'false'
31+
ignoredChecks:
32+
description: Comma separated list of check names to explicitly ignore
33+
required: false
34+
uploadReportArtifact:
35+
description: If enabled the action will upload the HTML report from the AppInspect API as an artifact to GitHub actions (enabled by default)
36+
required: false
37+
default: 'true'

dist/index.js

Lines changed: 10429 additions & 3082 deletions
Large diffs are not rendered by default.

lib/api.js

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

lib/main.js

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

package.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,23 @@
44
"private": true,
55
"main": "lib/main.js",
66
"scripts": {
7-
"build": "tsc",
8-
"pack": "ncc build",
9-
"all": "npm run build && npm run pack"
7+
"build": "ncc build src/main.ts"
108
},
119
"license": "UNLICENSED",
1210
"dependencies": {
11+
"@actions/artifact": "^0.5.1",
1312
"@actions/core": "^1.2.0",
1413
"@actions/exec": "^1.0.3",
15-
"@actions/github": "^2.1.1",
16-
"@vercel/ncc": "^0.28.3",
17-
"form-data": "^3.0.0",
14+
"@actions/github": "^4.0.0",
15+
"@vercel/ncc": "^0.28.5",
16+
"form-data": "^4.0.0",
1817
"node-fetch": "^2.6.0"
1918
},
2019
"devDependencies": {
2120
"@types/form-data": "^2.5.0",
22-
"@types/node": "^12.7.12",
21+
"@types/node": "^15.0.2",
2322
"@types/node-fetch": "^2.5.7",
24-
"js-yaml": "^3.13.1",
25-
"typescript": "^3.6.4"
23+
"js-yaml": "^4.1.0",
24+
"typescript": "^4.2.4"
2625
}
2726
}

src/api.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ async function req<T>({
88
method,
99
body,
1010
headers,
11+
json = true,
1112
}: {
1213
method: 'GET' | 'POST';
1314
url: string;
1415
headers?: { [k: string]: string };
1516
body?: any;
17+
json?: boolean;
1618
}): Promise<T> {
1719
const res = await fetch(url, {
1820
method,
@@ -28,7 +30,7 @@ async function req<T>({
2830
}
2931
throw new Error(`HTTP status ${res.status} from ${url}`);
3032
}
31-
return res.json();
33+
return json ? res.json() : res.text();
3234
}
3335

3436
export interface AuthResponse {
@@ -200,12 +202,31 @@ export interface ReportResponse {
200202
}>;
201203
}
202204

203-
export async function getReport(data: { request_id: string; token: string }): Promise<ReportResponse> {
205+
export async function getReportInternal<T>({
206+
request_id,
207+
token,
208+
format = 'json',
209+
}: {
210+
request_id: string;
211+
token: string;
212+
format?: 'json' | 'html';
213+
}): Promise<T> {
214+
const contentType = format === 'html' ? 'text/html' : 'application/json';
204215
return req({
205216
method: 'GET',
206-
url: `https://appinspect.splunk.com/v1/app/report/${encodeURIComponent(data.request_id)}`,
217+
url: `https://appinspect.splunk.com/v1/app/report/${encodeURIComponent(request_id)}`,
207218
headers: {
208-
Authorization: `Bearer ${data.token}`,
219+
Authorization: `Bearer ${token}`,
220+
'Content-Type': contentType,
209221
},
222+
json: format === 'json',
210223
});
211224
}
225+
226+
export async function getReport({ request_id, token }: { request_id: string; token: string }): Promise<ReportResponse> {
227+
return getReportInternal({ request_id, token, format: 'json' });
228+
}
229+
230+
export async function getHtmlReport({ request_id, token }: { request_id: string; token: string }): Promise<string> {
231+
return getReportInternal({ request_id, token, format: 'html' });
232+
}

0 commit comments

Comments
 (0)