fix: Linter fixes for plugins/common/[a-z]* (#10189)
Co-authored-by: Pawel Zak <Pawel Zak>
This commit is contained in:
parent
27dea9bd8f
commit
3627961add
|
|
@ -27,8 +27,7 @@ func (x *XDGSCRAMClient) Begin(userName, password, authzID string) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *XDGSCRAMClient) Step(challenge string) (response string, err error) {
|
func (x *XDGSCRAMClient) Step(challenge string) (response string, err error) {
|
||||||
response, err = x.ClientConversation.Step(challenge)
|
return x.ClientConversation.Step(challenge)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *XDGSCRAMClient) Done() bool {
|
func (x *XDGSCRAMClient) Done() bool {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ var once sync.Once
|
||||||
type LogHook struct {
|
type LogHook struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Install a logging hook into the logrus standard logger, diverting all logs
|
// InstallHook installs a logging hook into the logrus standard logger, diverting all logs
|
||||||
// through the Telegraf logger at debug level. This is useful for libraries
|
// through the Telegraf logger at debug level. This is useful for libraries
|
||||||
// that directly log to the logrus system without providing an override method.
|
// that directly log to the logrus system without providing an override method.
|
||||||
func InstallHook() {
|
func InstallHook() {
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ type proxyFunc func(req *http.Request) (*url.URL, error)
|
||||||
|
|
||||||
func (p *HTTPProxy) Proxy() (proxyFunc, error) {
|
func (p *HTTPProxy) Proxy() (proxyFunc, error) {
|
||||||
if len(p.HTTPProxyURL) > 0 {
|
if len(p.HTTPProxyURL) > 0 {
|
||||||
url, err := url.Parse(p.HTTPProxyURL)
|
address, err := url.Parse(p.HTTPProxyURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error parsing proxy url %q: %w", p.HTTPProxyURL, err)
|
return nil, fmt.Errorf("error parsing proxy url %q: %w", p.HTTPProxyURL, err)
|
||||||
}
|
}
|
||||||
return http.ProxyURL(url), nil
|
return http.ProxyURL(address), nil
|
||||||
}
|
}
|
||||||
return http.ProxyFromEnvironment, nil
|
return http.ProxyFromEnvironment, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,19 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
tgConfig "github.com/influxdata/telegraf/config"
|
tgConfig "github.com/influxdata/telegraf/config"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
"github.com/influxdata/telegraf/plugins/processors"
|
"github.com/influxdata/telegraf/plugins/processors"
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLoadConfig(t *testing.T) {
|
func TestLoadConfig(t *testing.T) {
|
||||||
os.Setenv("SECRET_TOKEN", "xxxxxxxxxx")
|
err := os.Setenv("SECRET_TOKEN", "xxxxxxxxxx")
|
||||||
os.Setenv("SECRET_VALUE", `test"\test`)
|
require.NoError(t, err)
|
||||||
|
err = os.Setenv("SECRET_VALUE", `test"\test`)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
inputs.Add("test", func() telegraf.Input {
|
inputs.Add("test", func() telegraf.Input {
|
||||||
return &serviceInput{}
|
return &serviceInput{}
|
||||||
|
|
|
||||||
|
|
@ -84,13 +84,13 @@ func (s *Shim) Run(pollInterval time.Duration) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("RunProcessor error: %w", err)
|
return fmt.Errorf("RunProcessor error: %w", err)
|
||||||
}
|
}
|
||||||
} else if s.Output != nil {
|
} else if s.Output != nil { //nolint:revive // Not simplifying here to stay in the structure for better understanding the code
|
||||||
err := s.RunOutput()
|
err := s.RunOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("RunOutput error: %w", err)
|
return fmt.Errorf("RunOutput error: %w", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("Nothing to run")
|
return fmt.Errorf("nothing to run")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -102,7 +102,7 @@ func hasQuit(ctx context.Context) bool {
|
||||||
|
|
||||||
func (s *Shim) writeProcessedMetrics() error {
|
func (s *Shim) writeProcessedMetrics() error {
|
||||||
serializer := influx.NewSerializer()
|
serializer := influx.NewSerializer()
|
||||||
for {
|
for { //nolint:gosimple // for-select used on purpose
|
||||||
select {
|
select {
|
||||||
case m, open := <-s.metricCh:
|
case m, open := <-s.metricCh:
|
||||||
if !open {
|
if !open {
|
||||||
|
|
@ -113,7 +113,10 @@ func (s *Shim) writeProcessedMetrics() error {
|
||||||
return fmt.Errorf("failed to serialize metric: %s", err)
|
return fmt.Errorf("failed to serialize metric: %s", err)
|
||||||
}
|
}
|
||||||
// Write this to stdout
|
// Write this to stdout
|
||||||
fmt.Fprint(s.stdout, string(b))
|
_, err = fmt.Fprint(s.stdout, string(b))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to write metric: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,9 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/influxdata/telegraf"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestShimSetsUpLogger(t *testing.T) {
|
func TestShimSetsUpLogger(t *testing.T) {
|
||||||
|
|
@ -18,7 +19,8 @@ func TestShimSetsUpLogger(t *testing.T) {
|
||||||
|
|
||||||
runErroringInputPlugin(t, 40*time.Second, stdinReader, nil, stderrWriter)
|
runErroringInputPlugin(t, 40*time.Second, stdinReader, nil, stderrWriter)
|
||||||
|
|
||||||
stdinWriter.Write([]byte("\n"))
|
_, err := stdinWriter.Write([]byte("\n"))
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
// <-metricProcessed
|
// <-metricProcessed
|
||||||
|
|
||||||
|
|
@ -27,7 +29,8 @@ func TestShimSetsUpLogger(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Contains(t, out, "Error in plugin: intentional")
|
require.Contains(t, out, "Error in plugin: intentional")
|
||||||
|
|
||||||
stdinWriter.Close()
|
err = stdinWriter.Close()
|
||||||
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runErroringInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (metricProcessed chan bool, exited chan bool) {
|
func runErroringInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdout, stderr io.Writer) (metricProcessed chan bool, exited chan bool) {
|
||||||
|
|
@ -46,7 +49,8 @@ func runErroringInputPlugin(t *testing.T, interval time.Duration, stdin io.Reade
|
||||||
shim.stderr = stderr
|
shim.stderr = stderr
|
||||||
log.SetOutput(stderr)
|
log.SetOutput(stderr)
|
||||||
}
|
}
|
||||||
shim.AddInput(inp)
|
err := shim.AddInput(inp)
|
||||||
|
require.NoError(t, err)
|
||||||
go func() {
|
go func() {
|
||||||
err := shim.Run(interval)
|
err := shim.Run(interval)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,8 @@ func TestInputShimStdinSignalingWorks(t *testing.T) {
|
||||||
|
|
||||||
metricProcessed, exited := runInputPlugin(t, 40*time.Second, stdinReader, stdoutWriter, nil)
|
metricProcessed, exited := runInputPlugin(t, 40*time.Second, stdinReader, stdoutWriter, nil)
|
||||||
|
|
||||||
stdinWriter.Write([]byte("\n"))
|
_, err := stdinWriter.Write([]byte("\n"))
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
<-metricProcessed
|
<-metricProcessed
|
||||||
|
|
||||||
|
|
@ -43,7 +44,8 @@ func TestInputShimStdinSignalingWorks(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, "measurement,tag=tag field=1i 1234000005678\n", out)
|
require.Equal(t, "measurement,tag=tag field=1i 1234000005678\n", out)
|
||||||
|
|
||||||
stdinWriter.Close()
|
err = stdinWriter.Close()
|
||||||
|
require.NoError(t, err)
|
||||||
go func() {
|
go func() {
|
||||||
_, _ = io.ReadAll(r)
|
_, _ = io.ReadAll(r)
|
||||||
}()
|
}()
|
||||||
|
|
@ -68,7 +70,8 @@ func runInputPlugin(t *testing.T, interval time.Duration, stdin io.Reader, stdou
|
||||||
if stderr != nil {
|
if stderr != nil {
|
||||||
shim.stderr = stderr
|
shim.stderr = stderr
|
||||||
}
|
}
|
||||||
shim.AddInput(inp)
|
err := shim.AddInput(inp)
|
||||||
|
require.NoError(t, err)
|
||||||
go func() {
|
go func() {
|
||||||
err := shim.Run(interval)
|
err := shim.Run(interval)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ func (l *Logger) Info(args ...interface{}) {
|
||||||
// setLoggerOnPlugin injects the logger into the plugin,
|
// setLoggerOnPlugin injects the logger into the plugin,
|
||||||
// if it defines Log telegraf.Logger. This is sort of like SetLogger but using
|
// if it defines Log telegraf.Logger. This is sort of like SetLogger but using
|
||||||
// reflection instead of forcing the plugin author to define the function for it
|
// reflection instead of forcing the plugin author to define the function for it
|
||||||
func setLoggerOnPlugin(i interface{}, log telegraf.Logger) {
|
func setLoggerOnPlugin(i interface{}, logger telegraf.Logger) {
|
||||||
valI := reflect.ValueOf(i)
|
valI := reflect.ValueOf(i)
|
||||||
|
|
||||||
if valI.Type().Kind() != reflect.Ptr {
|
if valI.Type().Kind() != reflect.Ptr {
|
||||||
|
|
@ -78,10 +78,9 @@ func setLoggerOnPlugin(i interface{}, log telegraf.Logger) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
switch field.Type().String() {
|
if field.Type().String() == "telegraf.Logger" {
|
||||||
case "telegraf.Logger":
|
|
||||||
if field.CanSet() {
|
if field.CanSet() {
|
||||||
field.Set(reflect.ValueOf(log))
|
field.Set(reflect.ValueOf(logger))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,12 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
"github.com/influxdata/telegraf/plugins/parsers"
|
"github.com/influxdata/telegraf/plugins/parsers"
|
||||||
"github.com/influxdata/telegraf/plugins/serializers"
|
"github.com/influxdata/telegraf/plugins/serializers"
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestProcessorShim(t *testing.T) {
|
func TestProcessorShim(t *testing.T) {
|
||||||
|
|
@ -95,8 +96,8 @@ type testProcessor struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *testProcessor) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
func (p *testProcessor) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
||||||
for _, metric := range in {
|
for _, m := range in {
|
||||||
metric.AddTag(p.tagName, p.tagValue)
|
m.AddTag(p.tagName, p.tagValue)
|
||||||
}
|
}
|
||||||
return in
|
return in
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,9 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/metric"
|
|
||||||
"go.starlark.net/starlark"
|
"go.starlark.net/starlark"
|
||||||
|
|
||||||
|
"github.com/influxdata/telegraf/metric"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newMetric(_ *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
|
func newMetric(_ *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
|
||||||
|
|
@ -210,11 +211,11 @@ func dictUpdate(b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tupl
|
||||||
return nil, fmt.Errorf("dictionary update sequence element #%d is not iterable (%s)", i, pair.Type())
|
return nil, fmt.Errorf("dictionary update sequence element #%d is not iterable (%s)", i, pair.Type())
|
||||||
}
|
}
|
||||||
defer iter2.Done()
|
defer iter2.Done()
|
||||||
len := starlark.Len(pair)
|
length := starlark.Len(pair)
|
||||||
if len < 0 {
|
if length < 0 {
|
||||||
return nil, fmt.Errorf("dictionary update sequence element #%d has unknown length (%s)", i, pair.Type())
|
return nil, fmt.Errorf("dictionary update sequence element #%d has unknown length (%s)", i, pair.Type())
|
||||||
} else if len != 2 {
|
} else if length != 2 {
|
||||||
return nil, fmt.Errorf("dictionary update sequence element #%d has length %d, want 2", i, len)
|
return nil, fmt.Errorf("dictionary update sequence element #%d has length %d, want 2", i, length)
|
||||||
}
|
}
|
||||||
var k, v starlark.Value
|
var k, v starlark.Value
|
||||||
iter2.Next(&k)
|
iter2.Next(&k)
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,9 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
|
||||||
"go.starlark.net/starlark"
|
"go.starlark.net/starlark"
|
||||||
|
|
||||||
|
"github.com/influxdata/telegraf"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FieldDict is a starlark.Value for the metric fields. It is heavily based on the
|
// FieldDict is a starlark.Value for the metric fields. It is heavily based on the
|
||||||
|
|
@ -18,17 +19,17 @@ type FieldDict struct {
|
||||||
|
|
||||||
func (d FieldDict) String() string {
|
func (d FieldDict) String() string {
|
||||||
buf := new(strings.Builder)
|
buf := new(strings.Builder)
|
||||||
buf.WriteString("{")
|
buf.WriteString("{") //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
sep := ""
|
sep := ""
|
||||||
for _, item := range d.Items() {
|
for _, item := range d.Items() {
|
||||||
k, v := item[0], item[1]
|
k, v := item[0], item[1]
|
||||||
buf.WriteString(sep)
|
buf.WriteString(sep) //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
buf.WriteString(k.String())
|
buf.WriteString(k.String()) //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
buf.WriteString(": ")
|
buf.WriteString(": ") //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
buf.WriteString(v.String())
|
buf.WriteString(v.String()) //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
sep = ", "
|
sep = ", "
|
||||||
}
|
}
|
||||||
buf.WriteString("}")
|
buf.WriteString("}") //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,7 +182,7 @@ func (d FieldDict) Delete(k starlark.Value) (v starlark.Value, found bool, err e
|
||||||
return starlark.None, false, errors.New("key must be of type 'str'")
|
return starlark.None, false, errors.New("key must be of type 'str'")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Items implements the starlark.Mapping interface.
|
// Iterate implements the starlark.Iterator interface.
|
||||||
func (d FieldDict) Iterate() starlark.Iterator {
|
func (d FieldDict) Iterate() starlark.Iterator {
|
||||||
d.fieldIterCount++
|
d.fieldIterCount++
|
||||||
return &FieldIterator{Metric: d.Metric, fields: d.metric.FieldList()}
|
return &FieldIterator{Metric: d.Metric, fields: d.metric.FieldList()}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
|
||||||
"go.starlark.net/starlark"
|
"go.starlark.net/starlark"
|
||||||
|
|
||||||
|
"github.com/influxdata/telegraf"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Metric struct {
|
type Metric struct {
|
||||||
|
|
@ -36,15 +37,15 @@ func (m *Metric) Unwrap() telegraf.Metric {
|
||||||
// it behaves more like the repr function would in Python.
|
// it behaves more like the repr function would in Python.
|
||||||
func (m *Metric) String() string {
|
func (m *Metric) String() string {
|
||||||
buf := new(strings.Builder)
|
buf := new(strings.Builder)
|
||||||
buf.WriteString("Metric(")
|
buf.WriteString("Metric(") //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
buf.WriteString(m.Name().String())
|
buf.WriteString(m.Name().String()) //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
buf.WriteString(", tags=")
|
buf.WriteString(", tags=") //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
buf.WriteString(m.Tags().String())
|
buf.WriteString(m.Tags().String()) //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
buf.WriteString(", fields=")
|
buf.WriteString(", fields=") //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
buf.WriteString(m.Fields().String())
|
buf.WriteString(m.Fields().String()) //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
buf.WriteString(", time=")
|
buf.WriteString(", time=") //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
buf.WriteString(m.Time().String())
|
buf.WriteString(m.Time().String()) //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
buf.WriteString(")")
|
buf.WriteString(")") //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
|
||||||
"go.starlark.net/starlark"
|
"go.starlark.net/starlark"
|
||||||
|
|
||||||
|
"github.com/influxdata/telegraf"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TagDict is a starlark.Value for the metric tags. It is heavily based on the
|
// TagDict is a starlark.Value for the metric tags. It is heavily based on the
|
||||||
|
|
@ -17,17 +18,17 @@ type TagDict struct {
|
||||||
|
|
||||||
func (d TagDict) String() string {
|
func (d TagDict) String() string {
|
||||||
buf := new(strings.Builder)
|
buf := new(strings.Builder)
|
||||||
buf.WriteString("{")
|
buf.WriteString("{") //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
sep := ""
|
sep := ""
|
||||||
for _, item := range d.Items() {
|
for _, item := range d.Items() {
|
||||||
k, v := item[0], item[1]
|
k, v := item[0], item[1]
|
||||||
buf.WriteString(sep)
|
buf.WriteString(sep) //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
buf.WriteString(k.String())
|
buf.WriteString(k.String()) //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
buf.WriteString(": ")
|
buf.WriteString(": ") //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
buf.WriteString(v.String())
|
buf.WriteString(v.String()) //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
sep = ", "
|
sep = ", "
|
||||||
}
|
}
|
||||||
buf.WriteString("}")
|
buf.WriteString("}") //nolint:revive // from builder.go: "It returns the length of r and a nil error."
|
||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,7 +169,7 @@ func (d TagDict) Delete(k starlark.Value) (v starlark.Value, found bool, err err
|
||||||
return starlark.None, false, errors.New("key must be of type 'str'")
|
return starlark.None, false, errors.New("key must be of type 'str'")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Items implements the starlark.Mapping interface.
|
// Iterate implements the starlark.Iterator interface.
|
||||||
func (d TagDict) Iterate() starlark.Iterator {
|
func (d TagDict) Iterate() starlark.Iterator {
|
||||||
d.tagIterCount++
|
d.tagIterCount++
|
||||||
return &TagIterator{Metric: d.Metric, tags: d.metric.TagList()}
|
return &TagIterator{Metric: d.Metric, tags: d.metric.TagList()}
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/plugins/common/tls"
|
"github.com/influxdata/telegraf/plugins/common/tls"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var pki = testutil.NewPKI("../../../testutil/pki")
|
var pki = testutil.NewPKI("../../../testutil/pki")
|
||||||
|
|
@ -344,6 +345,8 @@ func TestConnect(t *testing.T) {
|
||||||
|
|
||||||
resp, err := client.Get(ts.URL)
|
resp, err := client.Get(ts.URL)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
defer resp.Body.Close()
|
||||||
require.Equal(t, 200, resp.StatusCode)
|
require.Equal(t, 200, resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@ func ParseCiphers(ciphers []string) ([]uint16, error) {
|
||||||
suites := []uint16{}
|
suites := []uint16{}
|
||||||
|
|
||||||
for _, cipher := range ciphers {
|
for _, cipher := range ciphers {
|
||||||
if v, ok := tlsCipherMap[cipher]; ok {
|
v, ok := tlsCipherMap[cipher]
|
||||||
suites = append(suites, v)
|
if !ok {
|
||||||
} else {
|
|
||||||
return nil, fmt.Errorf("unsupported cipher %q", cipher)
|
return nil, fmt.Errorf("unsupported cipher %q", cipher)
|
||||||
}
|
}
|
||||||
|
suites = append(suites, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
return suites, nil
|
return suites, nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue