Skip to content

Commit

Permalink
Initial library idea
Browse files Browse the repository at this point in the history
Create library that allows for `ecs.Lookup("host.os.name", "8")`
to return information about the specified field obtained for a
specific ECS version.
  • Loading branch information
andrewkroh committed Sep 16, 2023
0 parents commit 886ceb7
Show file tree
Hide file tree
Showing 46 changed files with 33,958 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 2
- package-ecosystem: "gomod"
directory: "/internal/generator"
schedule:
interval: "weekly"
open-pull-requests-limit: 2
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
open-pull-requests-limit: 2
50 changes: 50 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This is a hack to update the code when new ECS tags are pushed.
name: generate

on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- 'main'
workflow_dispatch:

jobs:
ecs-generate:
permissions:
# Allow job to write to the branch.
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: 1.21
cache-dependency-path: ./internal/generator/go.sum

- name: generate
working-directory: ./internal/generator
run: go run .

- name: check for modified versions
id: is-changed
run: echo "modified=$(if git status --porcelain | grep -q -E 'internal/version'; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT

- name: get elastic/ecs version
id: ecs-version
run: echo "version=$(cd ~/.ecs-generator/git/ecs; git describe --tags)" >> $GITHUB_OUTPUT

- name: commit updated code
if: steps.is-changed.outputs.modified == 'true'
env:
ECS_VERSION: ${{ steps.ecs-version.outputs.version }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add -A
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git commit -m "ecs@${ECS_VERSION} update
Update code based on https://github.com/elastic/ecs/releases/tag/${ECS_VERSION}"
git push
40 changes: 40 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Go

on:
push:
tags:
- 'v*'
branches:
- main
pull_request:

permissions:
contents: read

jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Test
run: go test ./...

test-generator:
name: test-generator
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Test
working-directory: ./internal/generator
run: go run .
66 changes: 66 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---

name: lint
on:
pull_request:

permissions:
contents: read

jobs:
golangci:
name: golangci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'

- uses: actions/setup-go@v4
with:
go-version: '1.21'
cache: false

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
working-directory: ./internal/generator

go-mod-tidy:
name: go-mod-tidy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Run go mod tidy
run: go mod tidy

- name: Run go mod tidy
working-directory: ./internal/generator
run: go mod tidy

- name: Check git diff
run: git diff --exit-code

go-licenser:
name: go-licenser
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Check headers
run: go run github.com/elastic/go-licenser@latest -d
43 changes: 43 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---

run:
issues-exit-code: 1
modules-download-mode: readonly

linters:
disable-all: true
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- stylecheck
- typecheck
- unused
- errorlint
- gofumpt
- goimports
- godox
- misspell
- prealloc
- unconvert
- unused
- revive
fast: false

linters-settings:
goimports:
local-prefixes: github.com/andrewkroh/go-ecs
gofumpt:
extra-rules: true
stylecheck:
checks:
- all

issues:
include:
# If you're going to write a comment follow the conventions.
# https://go.dev/doc/effective_go#commentary.
# comment on exported (.+) should be of the form "(.+)..."
- EXC0014
Loading

0 comments on commit 886ceb7

Please sign in to comment.