chore(deps): Bump golangci-lint from v1.63.4 to v1.64.5 (#16512)
This commit is contained in:
parent
601467fd51
commit
1041d331ae
|
|
@ -106,7 +106,7 @@ jobs:
|
||||||
- run: 'make check-deps'
|
- run: 'make check-deps'
|
||||||
- run:
|
- run:
|
||||||
name: "Install golangci-lint"
|
name: "Install golangci-lint"
|
||||||
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.63.4
|
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5
|
||||||
- run:
|
- run:
|
||||||
name: "golangci-lint/Linux"
|
name: "golangci-lint/Linux"
|
||||||
# There are only 4 vCPUs available for this executor, so use only 4 instead of the default number
|
# There are only 4 vCPUs available for this executor, so use only 4 instead of the default number
|
||||||
|
|
@ -120,7 +120,7 @@ jobs:
|
||||||
- check-changed-files-or-halt
|
- check-changed-files-or-halt
|
||||||
- run:
|
- run:
|
||||||
name: "Install golangci-lint"
|
name: "Install golangci-lint"
|
||||||
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.63.4
|
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5
|
||||||
- run:
|
- run:
|
||||||
name: "golangci-lint/macOS"
|
name: "golangci-lint/macOS"
|
||||||
# There are only 4 vCPUs available for this executor, so use only 4 instead of the default number
|
# There are only 4 vCPUs available for this executor, so use only 4 instead of the default number
|
||||||
|
|
@ -134,7 +134,7 @@ jobs:
|
||||||
- check-changed-files-or-halt
|
- check-changed-files-or-halt
|
||||||
- run:
|
- run:
|
||||||
name: "Install golangci-lint"
|
name: "Install golangci-lint"
|
||||||
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.63.4
|
command: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5
|
||||||
- run:
|
- run:
|
||||||
name: "golangci-lint/Windows"
|
name: "golangci-lint/Windows"
|
||||||
# There are only 4 vCPUs available for this executor, so use only 4 instead of the default number
|
# There are only 4 vCPUs available for this executor, so use only 4 instead of the default number
|
||||||
|
|
|
||||||
|
|
@ -31,13 +31,13 @@ linters:
|
||||||
- revive
|
- revive
|
||||||
- sqlclosecheck
|
- sqlclosecheck
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- tenv
|
|
||||||
- testifylint
|
- testifylint
|
||||||
- tparallel
|
- tparallel
|
||||||
- typecheck
|
- typecheck
|
||||||
- unconvert
|
- unconvert
|
||||||
- unparam
|
- unparam
|
||||||
- unused
|
- unused
|
||||||
|
- usetesting
|
||||||
|
|
||||||
linters-settings:
|
linters-settings:
|
||||||
depguard:
|
depguard:
|
||||||
|
|
@ -322,11 +322,6 @@ linters-settings:
|
||||||
- name: var-declaration
|
- name: var-declaration
|
||||||
- name: var-naming
|
- name: var-naming
|
||||||
- name: waitgroup-by-value
|
- name: waitgroup-by-value
|
||||||
tenv:
|
|
||||||
# The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.
|
|
||||||
# Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked.
|
|
||||||
# Default: false
|
|
||||||
all: true
|
|
||||||
testifylint:
|
testifylint:
|
||||||
# Disable all checkers (https://github.com/Antonboom/testifylint#checkers).
|
# Disable all checkers (https://github.com/Antonboom/testifylint#checkers).
|
||||||
# Default: false
|
# Default: false
|
||||||
|
|
@ -356,6 +351,14 @@ linters-settings:
|
||||||
- suite-subtest-run
|
- suite-subtest-run
|
||||||
- suite-thelper
|
- suite-thelper
|
||||||
- useless-assert
|
- useless-assert
|
||||||
|
usetesting:
|
||||||
|
# Enable/disable `os.CreateTemp("", ...)` detections.
|
||||||
|
# Default: true
|
||||||
|
os-create-temp: false
|
||||||
|
# Enable/disable `os.MkdirTemp()` detections.
|
||||||
|
# Default: true
|
||||||
|
os-mkdir-temp: false
|
||||||
|
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
# List of regexps of issue texts to exclude.
|
# List of regexps of issue texts to exclude.
|
||||||
|
|
|
||||||
2
Makefile
2
Makefile
|
|
@ -180,7 +180,7 @@ vet:
|
||||||
.PHONY: lint-install
|
.PHONY: lint-install
|
||||||
lint-install:
|
lint-install:
|
||||||
@echo "Installing golangci-lint"
|
@echo "Installing golangci-lint"
|
||||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.63.4
|
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5
|
||||||
|
|
||||||
@echo "Installing markdownlint"
|
@echo "Installing markdownlint"
|
||||||
npm install -g markdownlint-cli
|
npm install -g markdownlint-cli
|
||||||
|
|
|
||||||
|
|
@ -740,8 +740,7 @@ func (a *Agent) runAggregators(
|
||||||
log.Printf("D! [agent] Aggregator channel closed")
|
log.Printf("D! [agent] Aggregator channel closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateWindow(start time.Time, roundInterval bool, period time.Duration) (time.Time, time.Time) {
|
func updateWindow(start time.Time, roundInterval bool, period time.Duration) (since, until time.Time) {
|
||||||
var until time.Time
|
|
||||||
if roundInterval {
|
if roundInterval {
|
||||||
until = internal.AlignTime(start, period)
|
until = internal.AlignTime(start, period)
|
||||||
if until.Equal(start) {
|
if until.Equal(start) {
|
||||||
|
|
@ -751,7 +750,7 @@ func updateWindow(start time.Time, roundInterval bool, period time.Duration) (ti
|
||||||
until = start.Add(period)
|
until = start.Add(period)
|
||||||
}
|
}
|
||||||
|
|
||||||
since := until.Add(-period)
|
since = until.Add(-period)
|
||||||
|
|
||||||
return since, until
|
return since, until
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@ func TestShimSetsUpLogger(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runErroringInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (chan bool, chan bool) {
|
func runErroringInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (processed, exited chan bool) {
|
||||||
metricProcessed := make(chan bool, 1)
|
processed = make(chan bool, 1)
|
||||||
exited := make(chan bool, 1)
|
exited = make(chan bool, 1)
|
||||||
inp := &erroringInput{}
|
inp := &erroringInput{}
|
||||||
|
|
||||||
shim := New()
|
shim := New()
|
||||||
|
|
@ -47,15 +47,15 @@ func runErroringInputPlugin(t *testing.T, interval time.Duration, stdin io.Reade
|
||||||
shim.stderr = stderr
|
shim.stderr = stderr
|
||||||
logger.RedirectLogging(stderr)
|
logger.RedirectLogging(stderr)
|
||||||
}
|
}
|
||||||
err := shim.AddInput(inp)
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, shim.AddInput(inp))
|
||||||
go func() {
|
go func(e chan bool) {
|
||||||
if err := shim.Run(interval); err != nil {
|
if err := shim.Run(interval); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
exited <- true
|
e <- true
|
||||||
}()
|
}(exited)
|
||||||
return metricProcessed, exited
|
return processed, exited
|
||||||
}
|
}
|
||||||
|
|
||||||
type erroringInput struct {
|
type erroringInput struct {
|
||||||
|
|
|
||||||
|
|
@ -55,11 +55,11 @@ func TestInputShimStdinSignalingWorks(t *testing.T) {
|
||||||
<-exited
|
<-exited
|
||||||
}
|
}
|
||||||
|
|
||||||
func runInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (chan bool, chan bool) {
|
func runInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (processed, exited chan bool) {
|
||||||
metricProcessed := make(chan bool, 1)
|
processed = make(chan bool, 1)
|
||||||
exited := make(chan bool, 1)
|
exited = make(chan bool, 1)
|
||||||
inp := &testInput{
|
inp := &testInput{
|
||||||
metricProcessed: metricProcessed,
|
metricProcessed: processed,
|
||||||
}
|
}
|
||||||
|
|
||||||
shim := New()
|
shim := New()
|
||||||
|
|
@ -74,13 +74,13 @@ func runInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdou
|
||||||
}
|
}
|
||||||
err := shim.AddInput(inp)
|
err := shim.AddInput(inp)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
go func() {
|
go func(e chan bool) {
|
||||||
if err := shim.Run(interval); err != nil {
|
if err := shim.Run(interval); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
exited <- true
|
e <- true
|
||||||
}()
|
}(exited)
|
||||||
return metricProcessed, exited
|
return processed, exited
|
||||||
}
|
}
|
||||||
|
|
||||||
type testInput struct {
|
type testInput struct {
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ func TestApcupsdGather(t *testing.T) {
|
||||||
// The following functionality is straight from apcupsd tests.
|
// The following functionality is straight from apcupsd tests.
|
||||||
|
|
||||||
// kvBytes is a helper to generate length and key/value byte buffers.
|
// kvBytes is a helper to generate length and key/value byte buffers.
|
||||||
func kvBytes(kv string) ([]byte, []byte) {
|
func kvBytes(kv string) (keyValLen, keyVal []byte) {
|
||||||
lenb := make([]byte, 2)
|
lenb := make([]byte, 2)
|
||||||
binary.BigEndian.PutUint16(lenb, uint16(len(kv)))
|
binary.BigEndian.PutUint16(lenb, uint16(len(kv)))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,6 @@ func (b *Beanstalkd) gatherTubeStats(connection *textproto.Conn, tube string, ac
|
||||||
}
|
}
|
||||||
|
|
||||||
func runQuery(connection *textproto.Conn, cmd string, result interface{}) error {
|
func runQuery(connection *textproto.Conn, cmd string, result interface{}) error {
|
||||||
//nolint:govet // Keep dynamic command as the passed string is constant
|
|
||||||
requestID, err := connection.Cmd(cmd)
|
requestID, err := connection.Cmd(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ func newRunnerMock(out, errout []byte, err error) runner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r runnerMock) run(_ string, _ []string, _ time.Duration) ([]byte, []byte, error) {
|
func (r runnerMock) run(string, []string, time.Duration) (out, errout []byte, err error) {
|
||||||
return r.out, r.errout, r.err
|
return r.out, r.errout, r.err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ func (c commandRunner) run(
|
||||||
command string,
|
command string,
|
||||||
environments []string,
|
environments []string,
|
||||||
timeout time.Duration,
|
timeout time.Duration,
|
||||||
) ([]byte, []byte, error) {
|
) (out, errout []byte, err error) {
|
||||||
splitCmd, err := shellquote.Split(command)
|
splitCmd, err := shellquote.Split(command)
|
||||||
if err != nil || len(splitCmd) == 0 {
|
if err != nil || len(splitCmd) == 0 {
|
||||||
return nil, nil, fmt.Errorf("exec: unable to parse command: %w", err)
|
return nil, nil, fmt.Errorf("exec: unable to parse command: %w", err)
|
||||||
|
|
@ -33,19 +33,19 @@ func (c commandRunner) run(
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
out bytes.Buffer
|
outbuf bytes.Buffer
|
||||||
stderr bytes.Buffer
|
stderr bytes.Buffer
|
||||||
)
|
)
|
||||||
cmd.Stdout = &out
|
cmd.Stdout = &outbuf
|
||||||
cmd.Stderr = &stderr
|
cmd.Stderr = &stderr
|
||||||
|
|
||||||
runErr := internal.RunTimeout(cmd, timeout)
|
runErr := internal.RunTimeout(cmd, timeout)
|
||||||
|
|
||||||
out = removeWindowsCarriageReturns(out)
|
outbuf = removeWindowsCarriageReturns(outbuf)
|
||||||
if stderr.Len() > 0 && !c.debug {
|
if stderr.Len() > 0 && !c.debug {
|
||||||
stderr = removeWindowsCarriageReturns(stderr)
|
stderr = removeWindowsCarriageReturns(stderr)
|
||||||
stderr = truncate(stderr)
|
stderr = truncate(stderr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return out.Bytes(), stderr.Bytes(), runErr
|
return outbuf.Bytes(), stderr.Bytes(), runErr
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ func (c commandRunner) run(
|
||||||
command string,
|
command string,
|
||||||
environments []string,
|
environments []string,
|
||||||
timeout time.Duration,
|
timeout time.Duration,
|
||||||
) ([]byte, []byte, error) {
|
) (out, errout []byte, err error) {
|
||||||
splitCmd, err := shellquote.Split(command)
|
splitCmd, err := shellquote.Split(command)
|
||||||
if err != nil || len(splitCmd) == 0 {
|
if err != nil || len(splitCmd) == 0 {
|
||||||
return nil, nil, fmt.Errorf("exec: unable to parse command: %w", err)
|
return nil, nil, fmt.Errorf("exec: unable to parse command: %w", err)
|
||||||
|
|
@ -35,19 +35,19 @@ func (c commandRunner) run(
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
out bytes.Buffer
|
outbuf bytes.Buffer
|
||||||
stderr bytes.Buffer
|
stderr bytes.Buffer
|
||||||
)
|
)
|
||||||
cmd.Stdout = &out
|
cmd.Stdout = &outbuf
|
||||||
cmd.Stderr = &stderr
|
cmd.Stderr = &stderr
|
||||||
|
|
||||||
runErr := internal.RunTimeout(cmd, timeout)
|
runErr := internal.RunTimeout(cmd, timeout)
|
||||||
|
|
||||||
out = removeWindowsCarriageReturns(out)
|
outbuf = removeWindowsCarriageReturns(outbuf)
|
||||||
if stderr.Len() > 0 && !c.debug {
|
if stderr.Len() > 0 && !c.debug {
|
||||||
stderr = removeWindowsCarriageReturns(stderr)
|
stderr = removeWindowsCarriageReturns(stderr)
|
||||||
stderr = truncate(stderr)
|
stderr = truncate(stderr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return out.Bytes(), stderr.Bytes(), runErr
|
return outbuf.Bytes(), stderr.Bytes(), runErr
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,11 @@ func TestShimStdinSignalingWorks(t *testing.T) {
|
||||||
<-exited
|
<-exited
|
||||||
}
|
}
|
||||||
|
|
||||||
func runInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (chan bool, chan bool) {
|
func runInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (processed, exited chan bool) {
|
||||||
metricProcessed := make(chan bool)
|
processed = make(chan bool)
|
||||||
exited := make(chan bool)
|
exited = make(chan bool)
|
||||||
inp := &testInput{
|
inp := &testInput{
|
||||||
metricProcessed: metricProcessed,
|
metricProcessed: processed,
|
||||||
}
|
}
|
||||||
|
|
||||||
shim := New()
|
shim := New()
|
||||||
|
|
@ -72,13 +72,13 @@ func runInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdou
|
||||||
}
|
}
|
||||||
|
|
||||||
require.NoError(t, shim.AddInput(inp))
|
require.NoError(t, shim.AddInput(inp))
|
||||||
go func() {
|
go func(e chan bool) {
|
||||||
if err := shim.Run(interval); err != nil {
|
if err := shim.Run(interval); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
exited <- true
|
e <- true
|
||||||
}()
|
}(exited)
|
||||||
return metricProcessed, exited
|
return processed, exited
|
||||||
}
|
}
|
||||||
|
|
||||||
type testInput struct {
|
type testInput struct {
|
||||||
|
|
|
||||||
|
|
@ -175,9 +175,8 @@ func (m *Ipmi) parse(acc telegraf.Accumulator, server, sensor string) error {
|
||||||
case "sdr":
|
case "sdr":
|
||||||
if m.MetricVersion == 2 {
|
if m.MetricVersion == 2 {
|
||||||
return m.parseV2(acc, hostname, out, timestamp)
|
return m.parseV2(acc, hostname, out, timestamp)
|
||||||
} else {
|
|
||||||
return m.parseV1(acc, hostname, out, timestamp)
|
|
||||||
}
|
}
|
||||||
|
return m.parseV1(acc, hostname, out, timestamp)
|
||||||
case "chassis_power_status":
|
case "chassis_power_status":
|
||||||
return parseChassisPowerStatus(acc, hostname, out, timestamp)
|
return parseChassisPowerStatus(acc, hostname, out, timestamp)
|
||||||
case "dcmi_power_reading":
|
case "dcmi_power_reading":
|
||||||
|
|
|
||||||
|
|
@ -1534,13 +1534,12 @@ func TestUnknownContentType(t *testing.T) {
|
||||||
require.Error(t, acc.FirstError())
|
require.Error(t, acc.FirstError())
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareAddr(t *testing.T, ts *httptest.Server) (*url.URL, string, string) {
|
func prepareAddr(t *testing.T, ts *httptest.Server) (addr *url.URL, host, port string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
addr, err := url.Parse(ts.URL + "/api")
|
addr, err := url.Parse(ts.URL + "/api")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
host, port, err := net.SplitHostPort(addr.Host)
|
host, port, err = net.SplitHostPort(addr.Host)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
host = addr.Host
|
host = addr.Host
|
||||||
if addr.Scheme == "http" {
|
if addr.Scheme == "http" {
|
||||||
|
|
|
||||||
|
|
@ -476,7 +476,7 @@ func (m *Smart) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Smart) scanAllDevices(ignoreExcludes bool) ([]string, []string, error) {
|
func (m *Smart) scanAllDevices(ignoreExcludes bool) (nvme, nonNvme []string, err error) {
|
||||||
// this will return all devices (including NVMe devices) for smartctl version >= 7.0
|
// this will return all devices (including NVMe devices) for smartctl version >= 7.0
|
||||||
// for older versions this will return non NVMe devices
|
// for older versions this will return non NVMe devices
|
||||||
devices, err := m.scanDevices(ignoreExcludes, "--scan")
|
devices, err := m.scanDevices(ignoreExcludes, "--scan")
|
||||||
|
|
|
||||||
|
|
@ -192,8 +192,7 @@ func (s *Stackdriver) initializeStackdriverClient(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the start and end time for the next collection.
|
// Returns the start and end time for the next collection.
|
||||||
func (s *Stackdriver) updateWindow(prevEnd time.Time) (time.Time, time.Time) {
|
func (s *Stackdriver) updateWindow(prevEnd time.Time) (start, end time.Time) {
|
||||||
var start time.Time
|
|
||||||
if time.Duration(s.Window) != 0 {
|
if time.Duration(s.Window) != 0 {
|
||||||
start = time.Now().Add(-time.Duration(s.Delay)).Add(-time.Duration(s.Window))
|
start = time.Now().Add(-time.Duration(s.Delay)).Add(-time.Duration(s.Window))
|
||||||
} else if prevEnd.IsZero() {
|
} else if prevEnd.IsZero() {
|
||||||
|
|
@ -201,7 +200,8 @@ func (s *Stackdriver) updateWindow(prevEnd time.Time) (time.Time, time.Time) {
|
||||||
} else {
|
} else {
|
||||||
start = prevEnd
|
start = prevEnd
|
||||||
}
|
}
|
||||||
end := time.Now().Add(-time.Duration(s.Delay))
|
end = time.Now().Add(-time.Duration(s.Delay))
|
||||||
|
|
||||||
return start, end
|
return start, end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,16 +153,14 @@ func (t *Tail) getSeekInfo(file string) (*tail.SeekInfo, error) {
|
||||||
if offset, ok := t.offsets[file]; ok {
|
if offset, ok := t.offsets[file]; ok {
|
||||||
t.Log.Debugf("Using offset %d for %q", offset, file)
|
t.Log.Debugf("Using offset %d for %q", offset, file)
|
||||||
return &tail.SeekInfo{Whence: 0, Offset: offset}, nil
|
return &tail.SeekInfo{Whence: 0, Offset: offset}, nil
|
||||||
} else {
|
|
||||||
return &tail.SeekInfo{Whence: 2, Offset: 0}, nil
|
|
||||||
}
|
}
|
||||||
|
return &tail.SeekInfo{Whence: 2, Offset: 0}, nil
|
||||||
case "save-or-beginning":
|
case "save-or-beginning":
|
||||||
if offset, ok := t.offsets[file]; ok {
|
if offset, ok := t.offsets[file]; ok {
|
||||||
t.Log.Debugf("Using offset %d for %q", offset, file)
|
t.Log.Debugf("Using offset %d for %q", offset, file)
|
||||||
return &tail.SeekInfo{Whence: 0, Offset: offset}, nil
|
return &tail.SeekInfo{Whence: 0, Offset: offset}, nil
|
||||||
} else {
|
|
||||||
return &tail.SeekInfo{Whence: 0, Offset: 0}, nil
|
|
||||||
}
|
}
|
||||||
|
return &tail.SeekInfo{Whence: 0, Offset: 0}, nil
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("invalid 'initial_read_offset' setting")
|
return nil, errors.New("invalid 'initial_read_offset' setting")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ func (s *Varnish) Gather(acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare varnish cli tools arguments
|
// Prepare varnish cli tools arguments
|
||||||
func (s *Varnish) prepareCmdArgs() ([]string, []string) {
|
func (s *Varnish) prepareCmdArgs() (adm, stats []string) {
|
||||||
// default varnishadm arguments
|
// default varnishadm arguments
|
||||||
admArgs := []string{"vcl.list", "-j"}
|
admArgs := []string{"vcl.list", "-j"}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,11 +77,11 @@ func (awh *Webhook) newEvent(data []byte, et, ed string) (event, error) {
|
||||||
case "artifact":
|
case "artifact":
|
||||||
if et == "deployed" || et == "deleted" {
|
if et == "deployed" || et == "deleted" {
|
||||||
return generateEvent(data, &artifactDeploymentOrDeletedEvent{})
|
return generateEvent(data, &artifactDeploymentOrDeletedEvent{})
|
||||||
} else if et == "moved" || et == "copied" {
|
|
||||||
return generateEvent(data, &artifactMovedOrCopiedEvent{})
|
|
||||||
} else {
|
|
||||||
return nil, &newEventError{"Not a recognized event type"}
|
|
||||||
}
|
}
|
||||||
|
if et == "moved" || et == "copied" {
|
||||||
|
return generateEvent(data, &artifactMovedOrCopiedEvent{})
|
||||||
|
}
|
||||||
|
return nil, &newEventError{"Not a recognized event type"}
|
||||||
case "artifact_property":
|
case "artifact_property":
|
||||||
return generateEvent(data, &artifactPropertiesEvent{})
|
return generateEvent(data, &artifactPropertiesEvent{})
|
||||||
case "docker":
|
case "docker":
|
||||||
|
|
|
||||||
|
|
@ -83,13 +83,13 @@ func getTags(pools []poolInfo) map[string]string {
|
||||||
return map[string]string{"pools": poolNames}
|
return map[string]string{"pools": poolNames}
|
||||||
}
|
}
|
||||||
|
|
||||||
func gather(lines []string, fileLines int) ([]string, []string, error) {
|
func gather(lines []string, fileLines int) (keys, values []string, err error) {
|
||||||
if len(lines) < fileLines {
|
if len(lines) < fileLines {
|
||||||
return nil, nil, errors.New("expected lines in kstat does not match")
|
return nil, nil, errors.New("expected lines in kstat does not match")
|
||||||
}
|
}
|
||||||
|
|
||||||
keys := strings.Fields(lines[1])
|
keys = strings.Fields(lines[1])
|
||||||
values := strings.Fields(lines[2])
|
values = strings.Fields(lines[2])
|
||||||
if len(keys) != len(values) {
|
if len(keys) != len(values) {
|
||||||
return nil, nil, fmt.Errorf("key and value count don't match Keys:%v Values:%v", keys, values)
|
return nil, nil, fmt.Errorf("key and value count don't match Keys:%v Values:%v", keys, values)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -133,9 +133,9 @@ func NewBinaryAnnotations(annotations []BinaryAnnotation, endpoint Endpoint) []t
|
||||||
return formatted
|
return formatted
|
||||||
}
|
}
|
||||||
|
|
||||||
func minMax(span Span) (time.Time, time.Time) {
|
func minMax(span Span) (low, high time.Time) {
|
||||||
low := now().UTC()
|
low = now().UTC()
|
||||||
high := time.Time{}.UTC()
|
high = time.Time{}.UTC()
|
||||||
for _, annotation := range span.Annotations() {
|
for _, annotation := range span.Annotations() {
|
||||||
ts := annotation.Timestamp()
|
ts := annotation.Timestamp()
|
||||||
if !ts.IsZero() && ts.Before(low) {
|
if !ts.IsZero() && ts.Before(low) {
|
||||||
|
|
|
||||||
|
|
@ -462,7 +462,7 @@ func getStackdriverIntervalEndpoints(
|
||||||
m telegraf.Metric,
|
m telegraf.Metric,
|
||||||
f *telegraf.Field,
|
f *telegraf.Field,
|
||||||
cc *counterCache,
|
cc *counterCache,
|
||||||
) (*timestamppb.Timestamp, *timestamppb.Timestamp) {
|
) (start, end *timestamppb.Timestamp) {
|
||||||
endTime := timestamppb.New(m.Time())
|
endTime := timestamppb.New(m.Time())
|
||||||
var startTime *timestamppb.Timestamp
|
var startTime *timestamppb.Timestamp
|
||||||
if kind == metricpb.MetricDescriptor_CUMULATIVE {
|
if kind == metricpb.MetricDescriptor_CUMULATIVE {
|
||||||
|
|
|
||||||
|
|
@ -334,7 +334,6 @@ func (p *Parser) expandArray(result metricNode, timestamp time.Time) ([]telegraf
|
||||||
}
|
}
|
||||||
|
|
||||||
if result.IsArray() {
|
if result.IsArray() {
|
||||||
var err error
|
|
||||||
if result.IncludeCollection == nil && (len(p.objectConfig.FieldPaths) > 0 || len(p.objectConfig.TagPaths) > 0) {
|
if result.IncludeCollection == nil && (len(p.objectConfig.FieldPaths) > 0 || len(p.objectConfig.TagPaths) > 0) {
|
||||||
result.IncludeCollection = p.existsInpathResults(result.Index)
|
result.IncludeCollection = p.existsInpathResults(result.Index)
|
||||||
}
|
}
|
||||||
|
|
@ -380,9 +379,6 @@ func (p *Parser) expandArray(result metricNode, timestamp time.Time) ([]telegraf
|
||||||
results = append(results, r...)
|
results = append(results, r...)
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if p.objectConfig.TimestampKey != "" && result.SetName == p.objectConfig.TimestampKey {
|
if p.objectConfig.TimestampKey != "" && result.SetName == p.objectConfig.TimestampKey {
|
||||||
if p.objectConfig.TimestampFormat == "" {
|
if p.objectConfig.TimestampFormat == "" {
|
||||||
|
|
@ -714,11 +710,11 @@ func convertType(input gjson.Result, desiredType, name string) (interface{}, err
|
||||||
case "bool":
|
case "bool":
|
||||||
if inputType == 0 {
|
if inputType == 0 {
|
||||||
return false, nil
|
return false, nil
|
||||||
} else if inputType == 1 {
|
|
||||||
return true, nil
|
|
||||||
} else {
|
|
||||||
return nil, fmt.Errorf("unable to convert field %q to type bool", name)
|
|
||||||
}
|
}
|
||||||
|
if inputType == 1 {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unable to convert field %q to type bool", name)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unknown format '%T' for field %q", inputType, name)
|
return nil, fmt.Errorf("unknown format '%T' for field %q", inputType, name)
|
||||||
|
|
|
||||||
|
|
@ -182,12 +182,12 @@ func (p *Converter) convertTags(metric telegraf.Metric) {
|
||||||
metric.AddField(key, v)
|
metric.AddField(key, v)
|
||||||
}
|
}
|
||||||
case p.tagConversions.Timestamp != nil && p.tagConversions.Timestamp.Match(key):
|
case p.tagConversions.Timestamp != nil && p.tagConversions.Timestamp.Match(key):
|
||||||
if time, err := internal.ParseTimestamp(p.Tags.TimestampFormat, value, nil); err != nil {
|
time, err := internal.ParseTimestamp(p.Tags.TimestampFormat, value, nil)
|
||||||
|
if err != nil {
|
||||||
p.Log.Errorf("Converting to timestamp [%T] failed: %v", value, err)
|
p.Log.Errorf("Converting to timestamp [%T] failed: %v", value, err)
|
||||||
continue
|
continue
|
||||||
} else {
|
|
||||||
metric.SetTime(time)
|
|
||||||
}
|
}
|
||||||
|
metric.SetTime(time)
|
||||||
default:
|
default:
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ func (k *KDFConfig) NewKey(keylen int) (key, iv config.Secret, err error) {
|
||||||
return config.Secret{}, config.Secret{}, fmt.Errorf("unknown key-derivation function %q", k.Algorithm)
|
return config.Secret{}, config.Secret{}, fmt.Errorf("unknown key-derivation function %q", k.Algorithm)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *KDFConfig) generatePBKDF2HMAC(hf hashFunc, keylen int) (config.Secret, config.Secret, error) {
|
func (k *KDFConfig) generatePBKDF2HMAC(hf hashFunc, keylen int) (key, iv config.Secret, err error) {
|
||||||
if k.Iterations == 0 {
|
if k.Iterations == 0 {
|
||||||
return config.Secret{}, config.Secret{}, errors.New("'iteration value not set")
|
return config.Secret{}, config.Secret{}, errors.New("'iteration value not set")
|
||||||
}
|
}
|
||||||
|
|
@ -48,6 +48,6 @@ func (k *KDFConfig) generatePBKDF2HMAC(hf hashFunc, keylen int) (config.Secret,
|
||||||
defer salt.Destroy()
|
defer salt.Destroy()
|
||||||
|
|
||||||
rawkey := pbkdf2.Key(passwd.Bytes(), salt.Bytes(), k.Iterations, keylen, hf)
|
rawkey := pbkdf2.Key(passwd.Bytes(), salt.Bytes(), k.Iterations, keylen, hf)
|
||||||
key := config.NewSecret([]byte(hex.EncodeToString(rawkey)))
|
key = config.NewSecret([]byte(hex.EncodeToString(rawkey)))
|
||||||
return key, config.Secret{}, nil
|
return key, config.Secret{}, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue