Skip to content

Commit

Permalink
enable cloud tag for appinspect
Browse files Browse the repository at this point in the history
  • Loading branch information
ziegfried committed Jun 16, 2020
1 parent 5919acf commit 67823b4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .github/actions/appinspect/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ inputs:
splunkPassword:
description: Splunk.com password used to login to the appinspect API
required: true
includedTags:
description: Comma separated list of tags to include in appinspect job
required: false
excludedTags:
description: Comma separated list of tags to exclude from appinspect job
required: false
15 changes: 11 additions & 4 deletions .github/actions/appinspect/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ const core_1 = __webpack_require__(470);
const fs = __importStar(__webpack_require__(747));
const api_1 = __webpack_require__(85);
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
function appInspect({ user, password, filePath, }) {
function appInspect({ user, password, filePath, includedTags, excludedTags, }) {
return __awaiter(this, void 0, void 0, function* () {
core_1.info(`Submitting file ${filePath} to appinspect API...`);
if (!fs.existsSync(filePath)) {
Expand All @@ -488,8 +488,8 @@ function appInspect({ user, password, filePath, }) {
const submitRes = yield api_1.submit({
filePath,
token,
// includedTags: ['cloud'],
excludedTags: ['cloud'],
includedTags,
excludedTags,
});
const reqId = submitRes.request_id;
core_1.info(`Submitted and received reqId=${reqId}`);
Expand Down Expand Up @@ -548,13 +548,20 @@ function appInspect({ user, password, filePath, }) {
}
});
}
const splitTags = (value) => {
if (value) {
return value.trim().split(/\s*,\s*/);
}
};
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const filePath = core_1.getInput('filePath');
const user = core_1.getInput('splunkUser');
const password = core_1.getInput('splunkPassword');
yield appInspect({ user, password, filePath });
const includedTags = splitTags(core_1.getInput('includedTags'));
const excludedTags = splitTags(core_1.getInput('includedTags'));
yield appInspect({ user, password, filePath, includedTags, excludedTags });
}
catch (error) {
core_1.setFailed(error.message);
Expand Down
18 changes: 15 additions & 3 deletions .github/actions/appinspect/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ async function appInspect({
user,
password,
filePath,
includedTags,
excludedTags,
}: {
filePath: string;
user: string;
password: string;
includedTags?: string[];
excludedTags?: string[];
}): Promise<void> {
info(`Submitting file ${filePath} to appinspect API...`);
if (!fs.existsSync(filePath)) {
Expand All @@ -22,8 +26,8 @@ async function appInspect({
const submitRes: SubmitResponse = await submit({
filePath,
token,
// includedTags: ['cloud'],
excludedTags: ['cloud'],
includedTags,
excludedTags,
});

const reqId = submitRes.request_id;
Expand Down Expand Up @@ -96,13 +100,21 @@ async function appInspect({
}
}

const splitTags = (value: string | null | undefined): string[] | undefined => {
if (value) {
return value.trim().split(/\s*,\s*/);
}
};

async function run(): Promise<void> {
try {
const filePath: string = getInput('filePath');
const user = getInput('splunkUser');
const password = getInput('splunkPassword');
const includedTags = splitTags(getInput('includedTags'));
const excludedTags = splitTags(getInput('includedTags'));

await appInspect({ user, password, filePath });
await appInspect({ user, password, filePath, includedTags, excludedTags });
} catch (error) {
setFailed(error.message);
}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/appinspect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ jobs:
filePath: ./dist/slack-alerts.spl
splunkUser: ${{ secrets.SPLUNKBASE_USER }}
splunkPassword: ${{ secrets.SPLUNKBASE_PASSWORD }}
includedTags: cloud

0 comments on commit 67823b4

Please sign in to comment.