This repository has been archived by the owner on Sep 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Create initial Skeleton of the shipper and gRPC service #18
Merged
fearful-symmetry
merged 8 commits into
elastic:main
from
fearful-symmetry:init-grpc-server
Mar 31, 2022
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
abbb20c
init commit
fearful-symmetry 3256e1e
format, cleanup
fearful-symmetry 9282132
rename protobuf dir, add lint
fearful-symmetry 5a1cd3e
make linter mostly happy
fearful-symmetry 177095e
move to auto-generated linter file
fearful-symmetry 7a77453
more linter cleanup, see if we can get ci working
fearful-symmetry 90f1cfe
add file skips to ci
fearful-symmetry 955152b
update magefile
fearful-symmetry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: golangci-lint | ||
on: | ||
pull_request: | ||
permissions: | ||
contents: read | ||
# Optional: allow read access to pull request. Use with `only-new-issues` option. | ||
pull-requests: read | ||
jobs: | ||
golangci: | ||
strategy: | ||
matrix: | ||
include: | ||
- GOOS: windows | ||
- GOOS: linux | ||
- GOOS: darwin | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Echo details | ||
env: | ||
GOOS: ${{ matrix.GOOS }} | ||
run: echo Go GOOS=$GOOS | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
# Uses Go version from the repository. | ||
- name: Read .go-version file | ||
id: goversion | ||
run: echo "::set-output name=version::$(cat .go-version)" | ||
|
||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: "${{ steps.goversion.outputs.version }}" | ||
|
||
- name: golangci-lint | ||
env: | ||
GOOS: ${{ matrix.GOOS }} | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version | ||
version: v1.44.2 | ||
|
||
# Give the job more time to execute. | ||
# Regarding `--whole-files`, the linter is supposed to support linting of changed a patch only but, | ||
# for some reason, it's very unreliable this way - sometimes it does not report any or some | ||
# issues without linting the whole files, so we have to use `--whole-files` | ||
# which can lead to some frustration from developers who would like to | ||
# fix a single line in an existing codebase and the linter would force them | ||
# into fixing all linting issues in the whole file instead | ||
args: --timeout=30m --whole-files | ||
|
||
# Optional: if set to true then the action will use pre-installed Go. | ||
skip-go-installation: true | ||
|
||
# Optional: show only new issues if it's a pull request. The default value is `false`. | ||
only-new-issues: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Directories | ||
/.vagrant | ||
/.idea | ||
/.vscode | ||
/build | ||
/*/*.template*.json | ||
**/html_docs | ||
data | ||
|
||
|
||
# Files | ||
.DS_Store | ||
/beats.iml | ||
*.dev.yml | ||
*.generated.yml | ||
coverage.out | ||
.python-version | ||
beat.db | ||
*.keystore | ||
go_env.properties | ||
mage_output_file.go | ||
|
||
fleet.yml | ||
|
||
# Editor swap files | ||
*.swp | ||
*.swo | ||
*.swn | ||
|
||
# Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
*.o | ||
*.a | ||
*.so | ||
*.exe | ||
*.test | ||
*.prof | ||
*.pyc | ||
|
||
# Terraform | ||
*.terraform | ||
*.tfstate* | ||
|
||
# Files generated with the bump version automations | ||
*.bck | ||
|
||
|
||
# agent | ||
build/ | ||
elastic-agent-shipper | ||
|
||
|
||
# VSCode | ||
/.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.17.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
# DO NOT EDIT! | ||
# This file is a rendered template, the source can be found in "./dev-tools/templates/.golangci.yml" | ||
# | ||
# options for analysis running | ||
run: | ||
# timeout for analysis, e.g. 30s, 5m, default is 1m | ||
timeout: 15m | ||
|
||
issues: | ||
# Maximum count of issues with the same text. | ||
# Set to 0 to disable. | ||
# Default: 3 | ||
max-same-issues: 3 | ||
# Maximum issues count per one linter. | ||
# Set to 0 to disable. | ||
# Default: 50 | ||
max-issues-per-linter: 50 | ||
exclude-rules: | ||
# Exclude package name contains '-' issue because we have at least one package with | ||
# it on its name. | ||
- text: "ST1003:" | ||
linters: | ||
- stylecheck | ||
|
||
output: | ||
sort-results: true | ||
|
||
# Uncomment and add a path if needed to exclude | ||
# skip-dirs: | ||
# - some/path | ||
# skip-files: | ||
# - ".*\\.my\\.go$" | ||
# - lib/bad.go | ||
|
||
# Find the whole list here https://golangci-lint.run/usage/linters/ | ||
linters: | ||
disable-all: true | ||
enable: | ||
- deadcode # finds unused code | ||
- errcheck # checking for unchecked errors in go programs | ||
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. | ||
- goconst # finds repeated strings that could be replaced by a constant | ||
- dupl # tool for code clone detection | ||
- forbidigo # forbids identifiers matched by reg exps | ||
- gosimple # linter for Go source code that specializes in simplifying a code | ||
- misspell # finds commonly misspelled English words in comments | ||
- nakedret # finds naked returns in functions greater than a specified function length | ||
- prealloc # finds slice declarations that could potentially be preallocated | ||
- nolintlint # reports ill-formed or insufficient nolint directives | ||
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks | ||
- stylecheck # a replacement for golint | ||
- unparam # reports unused function parameters | ||
- unused # checks Go code for unused constants, variables, functions and types | ||
|
||
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string | ||
- ineffassign # detects when assignments to existing variables are not used | ||
- structcheck # finds unused struct fields | ||
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code | ||
- varcheck # Finds unused global variables and constants | ||
- asciicheck # simple linter to check that your code does not contain non-ASCII identifiers | ||
- bodyclose # checks whether HTTP response body is closed successfully | ||
- durationcheck # check for two durations multiplied together | ||
- exportloopref # checks for pointers to enclosing loop variables | ||
- goimports # Goimports does everything that gofmt does. Additionally it checks unused imports | ||
- gosec # inspects source code for security problems | ||
- importas # enforces consistent import aliases | ||
- nilerr # finds the code that returns nil even if it checks that the error is not nil. | ||
- noctx # noctx finds sending http request without context.Context | ||
- unconvert # Remove unnecessary type conversions | ||
- wastedassign # wastedassign finds wasted assignment statements. | ||
- godox # tool for detection of FIXME, TODO and other comment keywords | ||
- gomodguard # check for blocked dependencies | ||
|
||
# all available settings of specific linters | ||
linters-settings: | ||
errcheck: | ||
# report about not checking of errors in type assertions: `a := b.(MyStruct)`; | ||
# default is false: such cases aren't reported by default. | ||
check-type-assertions: true | ||
|
||
errorlint: | ||
# Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats | ||
errorf: true | ||
# Check for plain type assertions and type switches | ||
asserts: true | ||
# Check for plain error comparisons | ||
comparison: true | ||
|
||
goconst: | ||
# minimal length of string constant, 3 by default | ||
min-len: 3 | ||
# minimal occurrences count to trigger, 3 by default | ||
min-occurrences: 2 | ||
|
||
dupl: | ||
# tokens count to trigger issue, 150 by default | ||
threshold: 100 | ||
|
||
forbidigo: | ||
# Forbid the following identifiers | ||
forbid: | ||
- fmt.Print.* # too much log noise | ||
# Exclude godoc examples from forbidigo checks. Default is true. | ||
exclude_godoc_examples: true | ||
|
||
goimports: | ||
local-prefixes: github.com/elastic | ||
|
||
gomodguard: | ||
blocked: | ||
# List of blocked modules. | ||
modules: | ||
# Blocked module. | ||
- github.com/pkg/errors: | ||
# Recommended modules that should be used instead. (Optional) | ||
recommendations: | ||
- errors | ||
- fmt | ||
reason: "This package is deprecated, use `fmt.Errorf` with `%w` instead" | ||
|
||
gosimple: | ||
# Select the Go version to target. The default is '1.13'. | ||
go: "1.17.8" | ||
|
||
misspell: | ||
# Correct spellings using locale preferences for US or UK. | ||
# Default is to use a neutral variety of English. | ||
# Setting locale to US will correct the British spelling of 'colour' to 'color'. | ||
# locale: US | ||
# ignore-words: | ||
# - IdP | ||
|
||
nakedret: | ||
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30 | ||
max-func-lines: 0 | ||
|
||
prealloc: | ||
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. | ||
# True by default. | ||
simple: true | ||
range-loops: true # Report preallocation suggestions on range loops, true by default | ||
for-loops: false # Report preallocation suggestions on for loops, false by default | ||
|
||
nolintlint: | ||
# Enable to ensure that nolint directives are all used. Default is true. | ||
allow-unused: false | ||
# Disable to ensure that nolint directives don't have a leading space. Default is true. | ||
allow-leading-space: false | ||
# Exclude following linters from requiring an explanation. Default is []. | ||
allow-no-explanation: [] | ||
# Enable to require an explanation of nonzero length after each nolint directive. Default is false. | ||
require-explanation: true | ||
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false. | ||
require-specific: false | ||
|
||
staticcheck: | ||
# Select the Go version to target. The default is '1.13'. | ||
go: "1.17.8" | ||
checks: ["all"] | ||
|
||
stylecheck: | ||
# Select the Go version to target. The default is '1.13'. | ||
go: "1.17.8" | ||
checks: ["all"] | ||
|
||
unparam: | ||
# Inspect exported functions, default is false. Set to true if no external program/library imports your code. | ||
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: | ||
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations | ||
# with golangci-lint call it on a directory with the changed file. | ||
check-exported: false | ||
|
||
unused: | ||
# Select the Go version to target. The default is '1.13'. | ||
go: "1.17.8" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a template in the other repositories to allow substituting in at least the go-version from the
.go-version
file we haven't added to this repo yet.We should probably do the same. Here's the commit that added linting to beats for example: elastic/beats@0a749b5
To get CI to run it you'd just need to drop the github action in: https://github.com/elastic/elastic-agent-libs/blob/main/.github/workflows/golangci-lint.yml
We don't need to do the linter setup as part of this commit if it is adding too much work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's interesting. I coped the out out of the
elastic-agent
repo, which didn't have the autogen warning.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright, copied in the CI files and fixed the file generation, not sure if there's anything else we need to do to make the linter happy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we also need to exclude generated go files (
*.pb.go
) from linting (seeskip-files
in the docs). The change must be made in the template and then rendered viamage linter:updategoversion
.And we definitely need to try run the linter after the final config is rendered just to make sure the next PR would not fail (the current PR is not running the linter workflow yet).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, added the
skip-files
section.You mean the protobuf files? Right now the
mage
command that generates that isn't in CI, I assume we want it to be?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cmacknz the GitHub action is already a part of this PR. I just thought would be nice to adjust the configuration and fix issues in the current code (if any). For that you need to run the linter locally because when you add the Github Action (in this PR) it's not activated until merged into
main
. Otherwise all these linter issues would surface in a next PR.