-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: lint code in preparation for rekres
Just adds in the golangcilint file from kres so this should be a no-op PR. Part of: #14 Signed-off-by: Noel Georgi <[email protected]>
- Loading branch information
1 parent
737c8f2
commit 8d26e25
Showing
11 changed files
with
405 additions
and
89 deletions.
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,160 @@ | ||
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. | ||
# | ||
# Generated on 2024-03-28T09:36:34Z by kres 88d1199. | ||
|
||
# options for analysis running | ||
run: | ||
timeout: 10m | ||
issues-exit-code: 1 | ||
tests: true | ||
build-tags: [ ] | ||
modules-download-mode: readonly | ||
|
||
# output configuration options | ||
output: | ||
formats: | ||
- format: colored-line-number | ||
path: stdout | ||
print-issued-lines: true | ||
print-linter-name: true | ||
uniq-by-line: true | ||
path-prefix: "" | ||
|
||
# all available settings of specific linters | ||
linters-settings: | ||
dogsled: | ||
max-blank-identifiers: 2 | ||
dupl: | ||
threshold: 150 | ||
errcheck: | ||
check-type-assertions: true | ||
check-blank: true | ||
exhaustive: | ||
default-signifies-exhaustive: false | ||
gci: | ||
sections: | ||
- standard # Standard section: captures all standard packages. | ||
- default # Default section: contains all imports that could not be matched to another section type. | ||
- prefix(github.com/siderolabs/talos-vmtoolsd/) # Custom section: groups all imports with the specified Prefix. | ||
gocognit: | ||
min-complexity: 30 | ||
nestif: | ||
min-complexity: 5 | ||
goconst: | ||
min-len: 3 | ||
min-occurrences: 3 | ||
gocritic: | ||
disabled-checks: [ ] | ||
gocyclo: | ||
min-complexity: 20 | ||
godot: | ||
scope: declarations | ||
gofmt: | ||
simplify: true | ||
goimports: | ||
local-prefixes: github.com/siderolabs/talos-vmtoolsd/ | ||
gomodguard: { } | ||
gomnd: { } | ||
govet: | ||
enable-all: true | ||
lll: | ||
line-length: 200 | ||
tab-width: 4 | ||
misspell: | ||
locale: US | ||
ignore-words: [ ] | ||
nakedret: | ||
max-func-lines: 30 | ||
prealloc: | ||
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: | ||
allow-unused: false | ||
allow-no-explanation: [ ] | ||
require-explanation: false | ||
require-specific: true | ||
rowserrcheck: { } | ||
testpackage: { } | ||
unparam: | ||
check-exported: false | ||
unused: | ||
local-variables-are-used: false | ||
whitespace: | ||
multi-if: false # Enforces newlines (or comments) after every multi-line if statement | ||
multi-func: false # Enforces newlines (or comments) after every multi-line function signature | ||
wsl: | ||
strict-append: true | ||
allow-assign-and-call: true | ||
allow-multiline-assign: true | ||
allow-cuddle-declarations: false | ||
allow-trailing-comment: false | ||
force-case-trailing-whitespace: 0 | ||
force-err-cuddling: false | ||
allow-separated-leading-comment: false | ||
gofumpt: | ||
extra-rules: false | ||
cyclop: | ||
# the maximal code complexity to report | ||
max-complexity: 20 | ||
# depguard: | ||
# Main: | ||
# deny: | ||
# - github.com/OpenPeeDeeP/depguard # this is just an example | ||
|
||
linters: | ||
enable-all: true | ||
disable-all: false | ||
fast: false | ||
disable: | ||
- exhaustivestruct | ||
- exhaustruct | ||
- forbidigo | ||
- funlen | ||
- gochecknoglobals | ||
- gochecknoinits | ||
- godox | ||
- goerr113 | ||
- gomnd | ||
- gomoddirectives | ||
- gosec | ||
- inamedparam | ||
- ireturn | ||
- nestif | ||
- nonamedreturns | ||
- nosnakecase | ||
- paralleltest | ||
- tagalign | ||
- tagliatelle | ||
- thelper | ||
- typecheck | ||
- varnamelen | ||
- wrapcheck | ||
- depguard # Disabled because starting with golangci-lint 1.53.0 it doesn't allow denylist alone anymore | ||
- testifylint # complains about our assert recorder and has a number of false positives for assert.Greater(t, thing, 1) | ||
- protogetter # complains about us using Value field on typed spec, instead of GetValue which has a different signature | ||
- perfsprint # complains about us using fmt.Sprintf in non-performance critical code, updating just kres took too long | ||
# abandoned linters for which golangci shows the warning that the repo is archived by the owner | ||
- deadcode | ||
- golint | ||
- ifshort | ||
- interfacer | ||
- maligned | ||
- scopelint | ||
- structcheck | ||
- varcheck | ||
# disabled as it seems to be broken - goes into imported libraries and reports issues there | ||
- musttag | ||
|
||
issues: | ||
exclude: [ ] | ||
exclude-rules: [ ] | ||
exclude-use-default: false | ||
exclude-case-sensitive: false | ||
max-issues-per-linter: 10 | ||
max-same-issues: 3 | ||
new: false | ||
|
||
severity: | ||
default-severity: error | ||
case-sensitive: false |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// Package main implements the main entry point for the Talos VMware Tools Daemon. | ||
package main | ||
|
||
import ( | ||
|
@@ -8,13 +9,20 @@ import ( | |
"os/signal" | ||
"syscall" | ||
|
||
vmtoolsd "github.com/siderolabs/talos-vmtoolsd" | ||
"github.com/siderolabs/talos-vmtoolsd/internal/nanotoolbox" | ||
"github.com/siderolabs/talos-vmtoolsd/internal/talosapi" | ||
"github.com/siderolabs/talos-vmtoolsd/internal/tboxcmds" | ||
"github.com/sirupsen/logrus" | ||
vmguestmsg "github.com/vmware/vmw-guestinfo/message" | ||
"github.com/vmware/vmw-guestinfo/vmcheck" | ||
|
||
"github.com/siderolabs/talos-vmtoolsd/internal/nanotoolbox" | ||
"github.com/siderolabs/talos-vmtoolsd/internal/talosapi" | ||
"github.com/siderolabs/talos-vmtoolsd/internal/tboxcmds" | ||
"github.com/siderolabs/talos-vmtoolsd/internal/version" | ||
) | ||
|
||
// Debug flags. | ||
var ( | ||
talosTestQuery string | ||
useMachinedSocket bool | ||
) | ||
|
||
func main() { | ||
|
@@ -24,9 +32,6 @@ func main() { | |
DisableHTMLEscape: true, | ||
}) | ||
|
||
// Debug flags | ||
var talosTestQuery string | ||
var useMachinedSocket bool | ||
flag.StringVar(&talosTestQuery, "test-apid-query", "", "query apid") | ||
flag.BoolVar(&useMachinedSocket, "use-machined", false, "use machined unix socket") | ||
flag.Parse() | ||
|
@@ -45,7 +50,7 @@ func main() { | |
l.Infof("talos-vmtoolsd version %v\n"+ | ||
"Copyright 2020-2022 Oliver Kuckertz <[email protected]>\n"+ | ||
"This program is free software and available under the Apache 2.0 license.", | ||
vmtoolsd.Version) | ||
version.Version) | ||
|
||
// Simplify deployment to mixed vSphere and non-vSphere clusters by detecting ESXi and stopping | ||
// early for other platforms. Admins can avoid the overhead of this idle process by labeling | ||
|
@@ -58,14 +63,18 @@ func main() { | |
|
||
ctx, ctxCancel := context.WithCancel(context.Background()) | ||
|
||
var api *talosapi.LocalClient | ||
var err error | ||
var ( | ||
api *talosapi.LocalClient | ||
err error | ||
) | ||
|
||
if !useMachinedSocket { | ||
// Our spec file passes the secret path and K8s host IP via env vars. | ||
configPath := os.Getenv("TALOS_CONFIG_PATH") | ||
if len(configPath) == 0 { | ||
l.Fatal("error: TALOS_CONFIG_PATH is a required path to a Talos configuration file") | ||
} | ||
|
||
k8sHost := os.Getenv("TALOS_HOST") | ||
if len(k8sHost) == 0 { | ||
l.Fatal("error: TALOS_HOST is required to point to a node's internal IP") | ||
|
@@ -94,10 +103,11 @@ func main() { | |
if talosTestQuery != "" { | ||
if err := testQuery(api, talosTestQuery); err != nil { | ||
l.WithField("test_query", talosTestQuery).WithError(err).Fatal("test query failed") | ||
os.Exit(1) | ||
} else { | ||
os.Exit(0) | ||
|
||
os.Exit(1) //nolint:gocritic | ||
} | ||
|
||
os.Exit(0) | ||
} | ||
|
||
// Wires up VMware Toolbox commands to Talos apid. | ||
|
@@ -116,6 +126,7 @@ func main() { | |
// Graceful shutdown on SIGINT/SIGTERM | ||
sig := make(chan os.Signal, 1) | ||
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM) | ||
|
||
go func() { | ||
l.Debugf("signal: %s", <-sig) | ||
ctxCancel() | ||
|
@@ -127,22 +138,27 @@ func main() { | |
|
||
func testQuery(api *talosapi.LocalClient, query string) error { | ||
w := os.Stdout | ||
|
||
switch query { | ||
case "net-interfaces": | ||
for idx, intf := range api.NetInterfaces() { | ||
for _, addr := range intf.Addrs { | ||
_, _ = fmt.Fprintf(w, "%d: name=%s mac=%s addr=%s\n", idx, intf.Name, intf.MAC, addr) | ||
} | ||
} | ||
|
||
return nil | ||
case "hostname": | ||
_, _ = fmt.Fprintln(w, api.Hostname()) | ||
|
||
return nil | ||
case "os-version": | ||
_, _ = fmt.Fprintln(w, api.OSVersion()) | ||
|
||
return nil | ||
case "os-version-short": | ||
_, _ = fmt.Fprintln(w, api.OSVersionShort()) | ||
|
||
return nil | ||
default: | ||
return fmt.Errorf("unknown test query %q", query) | ||
|
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
Oops, something went wrong.