Skip to content

Commit

Permalink
Merge branch 'master' into remove-actions-side-car
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankHassanabad committed Aug 25, 2021
2 parents d9d65e7 + 41f7b42 commit fd2ef0e
Show file tree
Hide file tree
Showing 285 changed files with 9,214 additions and 3,657 deletions.
3 changes: 0 additions & 3 deletions .buildkite/hooks/post-command

This file was deleted.

8 changes: 8 additions & 0 deletions .buildkite/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "kibana-buildkite",
"version": "1.0.0",
"private": true,
"dependencies": {
"kibana-buildkite-library": "elastic/kibana-buildkite-library"
}
}
17 changes: 17 additions & 0 deletions .buildkite/pipelines/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
env:
GITHUB_COMMIT_STATUS_ENABLED: 'true'
GITHUB_COMMIT_STATUS_CONTEXT: 'buildkite/kibana-pull-request'
steps:
- command: .buildkite/scripts/lifecycle/pre_build.sh
label: Pre-Build

- wait

- command: echo 'Hello World'
label: Test

- wait: ~
continue_on_failure: true

- command: .buildkite/scripts/lifecycle/post_build.sh
label: Post-Build
17 changes: 17 additions & 0 deletions .buildkite/scripts/lifecycle/build_status.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { BuildkiteClient } = require('kibana-buildkite-library');

(async () => {
try {
const client = new BuildkiteClient();
const status = await client.getCurrentBuildStatus();
console.log(status.success ? 'true' : 'false');
process.exit(0);
} catch (ex) {
if (ex.response) {
console.error('HTTP Error Response Body', ex.response.data);
console.error('HTTP Error Response Status', ex.response.status);
}
console.error(ex);
process.exit(1);
}
})();
59 changes: 0 additions & 59 deletions .buildkite/scripts/lifecycle/ci_stats.js

This file was deleted.

11 changes: 2 additions & 9 deletions .buildkite/scripts/lifecycle/ci_stats_complete.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
const ciStats = require('./ci_stats');

// TODO - this is okay for now but should really be replaced with an API call, especially once retries are enabled
const BUILD_STATUS = process.env.BUILD_FAILED === 'true' ? 'FAILURE' : 'SUCCESS';
const { CiStats } = require('kibana-buildkite-library');

(async () => {
try {
if (process.env.CI_STATS_BUILD_ID) {
await ciStats.post(`/v1/build/_complete?id=${process.env.CI_STATS_BUILD_ID}`, {
result: BUILD_STATUS,
});
}
await CiStats.onComplete();
} catch (ex) {
console.error(ex);
process.exit(1);
Expand Down
24 changes: 2 additions & 22 deletions .buildkite/scripts/lifecycle/ci_stats_start.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
const { execSync } = require('child_process');
const ciStats = require('./ci_stats');
const { CiStats } = require('kibana-buildkite-library');

(async () => {
try {
const build = await ciStats.post('/v1/build', {
jenkinsJobName: process.env.BUILDKITE_PIPELINE_NAME,
jenkinsJobId: process.env.BUILDKITE_BUILD_ID,
jenkinsUrl: process.env.BUILDKITE_BUILD_URL,
prId: process.env.GITHUB_PR_NUMBER || null,
});

execSync(`buildkite-agent meta-data set ci_stats_build_id "${build.id}"`);

// TODO Will need to set MERGE_BASE for PRs

await ciStats.post(`/v1/git_info?buildId=${build.id}`, {
branch: process.env.BUILDKITE_BRANCH.replace(/^(refs\/heads\/|origin\/)/, ''),
commit: process.env.BUILDKITE_COMMIT,
targetBranch:
process.env.GITHUB_PR_TARGET_BRANCH ||
process.env.BUILDKITE_PULL_REQUEST_BASE_BRANCH ||
null,
mergeBase: process.env.GITHUB_PR_MERGE_BASE || null, // TODO confirm GITHUB_PR_MERGE_BASE or switch to final var
});
await CiStats.onStart();
} catch (ex) {
console.error(ex);
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/scripts/lifecycle/commit_status_complete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

if [[ "${GITHUB_COMMIT_STATUS_ENABLED:-}" == "true" ]]; then
COMMIT_STATUS=success
if [[ "${BUILD_FAILED:-}" == "true" ]]; then
if [[ "${BUILD_SUCCESSFUL:-}" != "true" ]]; then
COMMIT_STATUS=failure
fi

Expand Down
4 changes: 2 additions & 2 deletions .buildkite/scripts/lifecycle/post_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

set -euo pipefail

BUILD_FAILED=$(buildkite-agent meta-data get build_failed --default "false")
export BUILD_FAILED
BUILD_SUCCESSFUL=$(node "$(dirname "${0}")/build_status.js")
export BUILD_SUCCESSFUL

"$(dirname "${0}")/commit_status_complete.sh"

Expand Down
7 changes: 0 additions & 7 deletions .buildkite/scripts/lifecycle/post_command.sh

This file was deleted.

7 changes: 7 additions & 0 deletions .buildkite/scripts/lifecycle/pre_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

set -euo pipefail

cd '.buildkite'
yarn install
cd -

BUILDKITE_TOKEN="$(vault read -field=buildkite_token_all_jobs secret/kibana-issues/dev/buildkite-ci)"
export BUILDKITE_TOKEN

# Set up a custom ES Snapshot Manifest if one has been specified for this build
{
ES_SNAPSHOT_MANIFEST=${ES_SNAPSHOT_MANIFEST:-$(buildkite-agent meta-data get ES_SNAPSHOT_MANIFEST --default '')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
type: string;
type?: string;
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
typeMeta: string;
typeMeta?: string;
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
type: string;
type?: string;
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
typeMeta: string;
typeMeta?: string;
```
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
"yarn": "^1.21.1"
},
"dependencies": {
"@elastic/apm-rum": "^5.8.0",
"@elastic/apm-rum-react": "^1.2.11",
"@elastic/apm-rum": "^5.9.1",
"@elastic/apm-rum-react": "^1.3.1",
"@elastic/charts": "34.1.1",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.18",
Expand Down Expand Up @@ -227,7 +227,7 @@
"deep-freeze-strict": "^1.1.1",
"deepmerge": "^4.2.2",
"del": "^5.1.0",
"elastic-apm-node": "^3.16.0",
"elastic-apm-node": "^3.20.0",
"execa": "^4.0.2",
"exit-hook": "^2.2.0",
"expiry-js": "0.1.7",
Expand Down Expand Up @@ -772,7 +772,7 @@
"jsondiffpatch": "0.4.1",
"license-checker": "^16.0.0",
"listr": "^0.14.1",
"lmdb-store": "^1.2.4",
"lmdb-store": "^1.6.6",
"load-grunt-config": "^3.0.1",
"marge": "^1.0.1",
"micromatch": "3.1.10",
Expand Down
12 changes: 2 additions & 10 deletions packages/kbn-rule-data-utils/src/alerts_as_data_rbac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,9 @@ export const AlertConsumers = {
export type AlertConsumers = typeof AlertConsumers[keyof typeof AlertConsumers];
export type STATUS_VALUES = 'open' | 'acknowledged' | 'closed' | 'in-progress'; // TODO: remove 'in-progress' after migration to 'acknowledged'

export const mapConsumerToIndexName: Record<AlertConsumers, string | string[]> = {
apm: '.alerts-observability-apm',
logs: '.alerts-observability.logs',
infrastructure: '.alerts-observability.metrics',
observability: '.alerts-observability',
siem: '.alerts-security.alerts',
uptime: '.alerts-observability.uptime',
};
export type ValidFeatureId = keyof typeof mapConsumerToIndexName;
export type ValidFeatureId = AlertConsumers;

export const validFeatureIds = Object.keys(mapConsumerToIndexName);
export const validFeatureIds = Object.values(AlertConsumers).map((v) => v as string);
export const isValidFeatureId = (a: unknown): a is ValidFeatureId =>
typeof a === 'string' && validFeatureIds.includes(a);

Expand Down
Loading

0 comments on commit fd2ef0e

Please sign in to comment.