Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[updatecli] Update to elastic/beats@4c04c1ad8631 #2173

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/arm-template-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: ARM Templates

on:
pull_request:
paths:
- "deploy/azure/*.json"
push:
branches:
- main
paths:
- "deploy/azure/*.json"

jobs:
lint-arm-ttk:
name: Lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
template: [ "ARM-for-organization-account", "ARM-for-single-account" ]
steps:
- uses: actions/checkout@v4

# Copy files to its own folder because it's what the official ARM-TTK action expects
# Docs https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/test-toolkit#test-parameters
- name: copy file
working-directory: ./deploy/azure
run: |
mkdir ${{ matrix.template }}
cp ${{ matrix.template }}.json ${{ matrix.template }}/azuredeploy.json

- uses: microsoft/action-armttk@v1
name: lint ${{ matrix.template }}
with:
github_token: ${{ secrets.github_token }}
workdir: "./deploy/azure/${{ matrix.template }}"
105 changes: 105 additions & 0 deletions .github/workflows/ci-pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Unit Tests and Lints

on:
pull_request:
branches:
- main
- "[0-9]+.[0-9]+"
types: [opened, synchronize, reopened]
push:
branches:
- main
- "[0-9]+.[0-9]+"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:

lint:
name: Lint
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Initialize hermit
shell: bash
run: |
./bin/hermit env --raw >> "$GITHUB_ENV"

- name: Initialize poetry
shell: bash
run: |
pip3 install poetry
(cd security-policies && poetry install --no-root)

- name: Pre-commit Hooks
env:
# Skipping golangci-lint as it's tested by golangci-lint
SKIP: golangci-lint
shell: bash
run: |
pre-commit run --all-files

- name: golangci-lint
shell: bash
run: golangci-lint run --out-format github-actions

- name: Mage Check
shell: bash
run: mage check

- name: Mage checkLicenseHeaders
shell: bash
run: mage checkLicenseHeaders

- name: Validate mocks
shell: bash
run: just validate-mocks

- name: Terraform fmt
shell: bash
run: terraform fmt -check -recursive

unit-test:
name: Unit Test
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Initialize hermit
shell: bash
run: |
./bin/hermit env --raw >> "$GITHUB_ENV"

- name: Build opa bundle
shell: bash
run: mage buildOpaBundle

- name: Unit-Test
shell: bash
run: |
go install gotest.tools/gotestsum
GOOS=linux TEST_DIRECTORY=./... gotestsum --format pkgname -- -race -coverpkg=./... -coverprofile=cover.out.tmp
cat cover.out.tmp | grep -v "mock_.*.go" > cover.out # remove mock files from coverage report

- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-file
path: cover.out
overwrite: true

- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
go install github.com/mattn/goveralls@latest
goveralls -coverprofile=cover.out -service=github
94 changes: 0 additions & 94 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,100 +29,6 @@ jobs:
with:
init-tools: 'true'

lint:
name: Lint
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'push' && github.ref || format('refs/pull/{0}/merge', github.event.number) }}
# If the event is push to branch use the default ref.
# If the event is pull request (`pull_request_target` in our case) use merge commit as ref to run lint over the PR's code.

- name: Initialize hermit
shell: bash
run: |
./bin/hermit env --raw >> "$GITHUB_ENV"

- name: Initialize poetry
shell: bash
run: |
pip3 install poetry
(cd security-policies && poetry install --no-root)

- name: Pre-commit Hooks
env:
# Skipping golangci-lint as it's tested by golangci-lint
SKIP: golangci-lint
shell: bash
run: |
pre-commit run --all-files

- name: golangci-lint
shell: bash
run: golangci-lint run --out-format github-actions

- name: Mage Check
shell: bash
run: mage check

- name: Mage checkLicenseHeaders
shell: bash
run: mage checkLicenseHeaders

- name: Validate mocks
shell: bash
run: just validate-mocks

- name: Terraform fmt
shell: bash
run: terraform fmt -check -recursive

unit-test:
name: Unit Test
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'push' && github.ref || format('refs/pull/{0}/merge', github.event.number) }}
# If the event is push to branch use the default ref.
# If the event is pull request (`pull_request_target` in our case) use merge commit as ref to run unit tests over the PR's code.

- name: Initialize hermit
shell: bash
run: |
./bin/hermit env --raw >> "$GITHUB_ENV"

- name: Build opa bundle
shell: bash
run: mage buildOpaBundle

- name: Unit-Test
shell: bash
run: |
go install gotest.tools/gotestsum
GOOS=linux TEST_DIRECTORY=./... gotestsum --format pkgname -- -race -coverpkg=./... -coverprofile=cover.out.tmp
cat cover.out.tmp | grep -v "mock_.*.go" > cover.out # remove mock files from coverage report

- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-file
path: cover.out
overwrite: true

- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
go install github.com/mattn/goveralls@latest
goveralls -coverprofile=cover.out -service=github

ci-azure:
needs: [ init-hermit ]
name: CIS Azure CI
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/periodic-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.9.0
uses: helm/kind-action@v1.10.0
with:
config: deploy/k8s/kind/kind-mono.yml

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/weekly-enviroment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:

# Once https://github.com/slackapi/slack-github-action/issues/84 will be resolved we can push the payload to a different file
- name: Send custom JSON data to Slack workflow
uses: slackapi/slack-github-action@v1.25.0
uses: slackapi/slack-github-action@v1.26.0
with:
payload: |
{
Expand Down
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.21.8
1.22.2
13 changes: 13 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,16 @@ pull_request_rules:
labels:
- "backport"
title: "[{{ destination_branch }}](backport #{{ number }}) {{ title }}"
- name: backport patches to 8.14 branch
conditions:
- merged
- label=backport-v8.14.0
actions:
backport:
assignees:
- "{{ author }}"
branches:
- "8.14"
labels:
- "backport"
title: "[{{ destination_branch }}](backport #{{ number }}) {{ title }}"
3 changes: 2 additions & 1 deletion _meta/config/processors.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Configure processors to enhance or manipulate events generated by the beat.

processors:
- add_host_metadata: ~
# in case you run in EKS/Kubernetes environment, you can use the following processor to add node metadata
# - add_host_metadata: ~
- add_cloud_metadata: ~
- add_docker_metadata: ~
# in case you run in EKS/Kubernetes environment, you can use the following processor to add cluster id
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/go
2 changes: 1 addition & 1 deletion bin/gofmt
2 changes: 1 addition & 1 deletion bin/hermit.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
env = {
"CLOUDBEAT_VERSION": "8.14.0",
"CLOUDBEAT_VERSION": "8.15.0",
"ELK_VERSION": "${CLOUDBEAT_VERSION}-SNAPSHOT",
}
3 changes: 2 additions & 1 deletion cloudbeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ output.elasticsearch:
# Configure processors to enhance or manipulate events generated by the beat.

processors:
- add_host_metadata: ~
# in case you run in EKS/Kubernetes environment, you can use the following processor to add node metadata
# - add_host_metadata: ~
- add_cloud_metadata: ~
- add_docker_metadata: ~
# in case you run in EKS/Kubernetes environment, you can use the following processor to add cluster id
Expand Down
12 changes: 11 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/elastic/beats/v7/libbeat/cmd"
"github.com/elastic/beats/v7/libbeat/cmd/instance"
"github.com/elastic/beats/v7/libbeat/common/reload"
"github.com/elastic/beats/v7/libbeat/publisher/processing"
_ "github.com/elastic/beats/v7/x-pack/libbeat/include"
"github.com/elastic/beats/v7/x-pack/libbeat/management"
"github.com/elastic/elastic-agent-client/v7/pkg/client"
Expand All @@ -36,7 +37,16 @@ import (
var Name = "cloudbeat"

// RootCmd to handle beats cli
var RootCmd = cmd.GenRootCmdWithSettings(beater.New, instance.Settings{Name: Name, Version: version.CloudbeatSemanticVersion()})
var RootCmd = cmd.GenRootCmdWithSettings(
beater.New,
instance.Settings{
Name: Name,
Version: version.CloudbeatSemanticVersion(),
// Supply our own processing pipeline. Same as processing.MakeDefaultBeatSupport, but without
// `processing.WithHost`.
Processing: processing.MakeDefaultSupport(true, nil, processing.WithECS, processing.WithAgentMeta()),
},
)

func cloudbeatCfg(rawIn *proto.UnitExpectedConfig, agentInfo *client.AgentInfo) ([]*reload.ConfigWithMeta, error) {
modules, err := management.CreateInputsFromStreams(rawIn, "logs", agentInfo)
Expand Down
1 change: 0 additions & 1 deletion deploy/aws/cloudbeat-aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ output.elasticsearch:

# ================================= Processors =================================
processors:
- add_host_metadata: ~
- add_cloud_metadata: ~
- add_docker_metadata: ~

Expand Down
Loading
Loading