chore: remove deprecated io/ioutils (#11678)
This commit is contained in:
parent
5f22bd17db
commit
8e23402305
|
|
@ -2,7 +2,6 @@ package snmp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -57,12 +56,18 @@ func LoadMibsFromPath(paths []string, log telegraf.Logger, loader MibLoader) err
|
||||||
}
|
}
|
||||||
for _, path := range folders {
|
for _, path := range folders {
|
||||||
loader.appendPath(path)
|
loader.appendPath(path)
|
||||||
modules, err := ioutil.ReadDir(path)
|
modules, err := os.ReadDir(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("Can't read directory %v", modules)
|
log.Warnf("Can't read directory %v", modules)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, info := range modules {
|
for _, entry := range modules {
|
||||||
|
info, err := entry.Info()
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Couldn't get info for %v: %v", entry.Name(), err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if info.Mode()&os.ModeSymlink != 0 {
|
if info.Mode()&os.ModeSymlink != 0 {
|
||||||
symlink := filepath.Join(path, info.Name())
|
symlink := filepath.Join(path, info.Name())
|
||||||
target, err := filepath.EvalSymlinks(symlink)
|
target, err := filepath.EvalSymlinks(symlink)
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ package consul_agent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ func TestConsulStats(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.RequestURI == "/v1/agent/metrics" {
|
if r.RequestURI == "/v1/agent/metrics" {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
responseKeyMetrics, _ := ioutil.ReadFile("testdata/response_key_metrics.json")
|
responseKeyMetrics, _ := os.ReadFile("testdata/response_key_metrics.json")
|
||||||
_, err := fmt.Fprintln(w, string(responseKeyMetrics))
|
_, err := fmt.Fprintln(w, string(responseKeyMetrics))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -196,7 +195,7 @@ func makeRequestBodyReader(contentEncoding, body string) (io.Reader, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
data, err := ioutil.ReadAll(rc)
|
data, err := io.ReadAll(rc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -123,7 +123,7 @@ func (h *Hugepages) gatherRootStats(acc telegraf.Accumulator) error {
|
||||||
|
|
||||||
// gatherStatsPerNode collects hugepages statistics per NUMA node
|
// gatherStatsPerNode collects hugepages statistics per NUMA node
|
||||||
func (h *Hugepages) gatherStatsPerNode(acc telegraf.Accumulator) error {
|
func (h *Hugepages) gatherStatsPerNode(acc telegraf.Accumulator) error {
|
||||||
nodeDirs, err := ioutil.ReadDir(h.numaNodePath)
|
nodeDirs, err := os.ReadDir(h.numaNodePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -154,7 +154,7 @@ func (h *Hugepages) gatherStatsPerNode(acc telegraf.Accumulator) error {
|
||||||
|
|
||||||
func (h *Hugepages) gatherFromHugepagePath(acc telegraf.Accumulator, measurement, path string, fileFilter map[string]string, defaultTags map[string]string) error {
|
func (h *Hugepages) gatherFromHugepagePath(acc telegraf.Accumulator, measurement, path string, fileFilter map[string]string, defaultTags map[string]string) error {
|
||||||
// read metrics from: hugepages/hugepages-*/*
|
// read metrics from: hugepages/hugepages-*/*
|
||||||
hugepagesDirs, err := ioutil.ReadDir(path)
|
hugepagesDirs, err := os.ReadDir(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("reading root dir failed: %v", err)
|
return fmt.Errorf("reading root dir failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -171,7 +171,7 @@ func (h *Hugepages) gatherFromHugepagePath(acc telegraf.Accumulator, measurement
|
||||||
}
|
}
|
||||||
|
|
||||||
metricsPath := filepath.Join(path, hugepagesDir.Name())
|
metricsPath := filepath.Join(path, hugepagesDir.Name())
|
||||||
metricFiles, err := ioutil.ReadDir(metricsPath)
|
metricFiles, err := os.ReadDir(metricsPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("reading metric dir failed: %v", err)
|
return fmt.Errorf("reading metric dir failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -179,12 +179,12 @@ func (h *Hugepages) gatherFromHugepagePath(acc telegraf.Accumulator, measurement
|
||||||
metrics := make(map[string]interface{})
|
metrics := make(map[string]interface{})
|
||||||
for _, metricFile := range metricFiles {
|
for _, metricFile := range metricFiles {
|
||||||
metricName, ok := fileFilter[metricFile.Name()]
|
metricName, ok := fileFilter[metricFile.Name()]
|
||||||
if mode := metricFile.Mode(); !mode.IsRegular() || !ok {
|
if mode := metricFile.Type(); !mode.IsRegular() || !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
metricFullPath := filepath.Join(metricsPath, metricFile.Name())
|
metricFullPath := filepath.Join(metricsPath, metricFile.Name())
|
||||||
metricBytes, err := ioutil.ReadFile(metricFullPath)
|
metricBytes, err := os.ReadFile(metricFullPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -214,7 +214,7 @@ func (h *Hugepages) gatherFromHugepagePath(acc telegraf.Accumulator, measurement
|
||||||
|
|
||||||
// gatherStatsFromMeminfo collects hugepages statistics from meminfo file
|
// gatherStatsFromMeminfo collects hugepages statistics from meminfo file
|
||||||
func (h *Hugepages) gatherStatsFromMeminfo(acc telegraf.Accumulator) error {
|
func (h *Hugepages) gatherStatsFromMeminfo(acc telegraf.Accumulator) error {
|
||||||
meminfo, err := ioutil.ReadFile(h.meminfoPath)
|
meminfo, err := os.ReadFile(h.meminfoPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ package intel_pmu
|
||||||
import (
|
import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"math"
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -36,7 +35,7 @@ type fileInfoProvider interface {
|
||||||
type fileHelper struct{}
|
type fileHelper struct{}
|
||||||
|
|
||||||
func (fileHelper) readFile(path string) ([]byte, error) {
|
func (fileHelper) readFile(path string) ([]byte, error) {
|
||||||
return ioutil.ReadFile(path)
|
return os.ReadFile(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fileHelper) lstat(path string) (os.FileInfo, error) {
|
func (fileHelper) lstat(path string) (os.FileInfo, error) {
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ package nomad
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ func TestNomadStats(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.RequestURI == "/v1/metrics" {
|
if r.RequestURI == "/v1/metrics" {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
responseKeyMetrics, _ := ioutil.ReadFile("testdata/response_key_metrics.json")
|
responseKeyMetrics, _ := os.ReadFile("testdata/response_key_metrics.json")
|
||||||
_, err := fmt.Fprintln(w, string(responseKeyMetrics))
|
_, err := fmt.Fprintln(w, string(responseKeyMetrics))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ package varnish
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|
@ -548,8 +548,9 @@ func TestVersions(t *testing.T) {
|
||||||
{jsonFile: "varnish6.6.json", activeReloadPrefix: "boot", size: 358},
|
{jsonFile: "varnish6.6.json", activeReloadPrefix: "boot", size: 358},
|
||||||
{jsonFile: "varnish4_4.json", activeReloadPrefix: "boot", size: 295},
|
{jsonFile: "varnish4_4.json", activeReloadPrefix: "boot", size: 295},
|
||||||
} {
|
} {
|
||||||
output, _ := ioutil.ReadFile("test_data/" + c.jsonFile)
|
output, err := os.ReadFile("test_data/" + c.jsonFile)
|
||||||
err := server.processMetricsV2(c.activeReloadPrefix, acc, bytes.NewBuffer(output))
|
require.NoError(t, err)
|
||||||
|
err = server.processMetricsV2(c.activeReloadPrefix, acc, bytes.NewBuffer(output))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, c.size, len(acc.Metrics))
|
require.Equal(t, c.size, len(acc.Metrics))
|
||||||
for _, m := range acc.Metrics {
|
for _, m := range acc.Metrics {
|
||||||
|
|
@ -619,12 +620,14 @@ func TestJsonTypes(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVarnishAdmJson(t *testing.T) {
|
func TestVarnishAdmJson(t *testing.T) {
|
||||||
admJSON, _ := ioutil.ReadFile("test_data/" + "varnishadm-200.json")
|
admJSON, err := os.ReadFile("test_data/" + "varnishadm-200.json")
|
||||||
|
require.NoError(t, err)
|
||||||
activeVcl, err := getActiveVCLJson(bytes.NewBuffer(admJSON))
|
activeVcl, err := getActiveVCLJson(bytes.NewBuffer(admJSON))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, activeVcl, "boot-123")
|
require.Equal(t, activeVcl, "boot-123")
|
||||||
|
|
||||||
admJSON, _ = ioutil.ReadFile("test_data/" + "varnishadm-reload.json")
|
admJSON, err = os.ReadFile("test_data/" + "varnishadm-reload.json")
|
||||||
|
require.NoError(t, err)
|
||||||
activeVcl, err = getActiveVCLJson(bytes.NewBuffer(admJSON))
|
activeVcl, err = getActiveVCLJson(bytes.NewBuffer(admJSON))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, activeVcl, "reload_20210723_091821_2056185")
|
require.Equal(t, activeVcl, "reload_20210723_091821_2056185")
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ package vault
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -73,8 +73,9 @@ func TestVaultStats(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.RequestURI == "/v1/sys/metrics" {
|
if r.RequestURI == "/v1/sys/metrics" {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
responseKeyMetrics, _ := ioutil.ReadFile("testdata/response_key_metrics.json")
|
responseKeyMetrics, err := os.ReadFile("testdata/response_key_metrics.json")
|
||||||
_, err := fmt.Fprintln(w, string(responseKeyMetrics))
|
require.NoError(t, err)
|
||||||
|
_, err = fmt.Fprintln(w, string(responseKeyMetrics))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ package filestack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ func (fs *FilestackWebhook) eventHandler(w http.ResponseWriter, r *http.Request)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ package mandrill
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -41,7 +41,7 @@ func (md *MandrillWebhook) eventHandler(w http.ResponseWriter, r *http.Request)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package rollbar
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ func (rb *RollbarWebhook) eventHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := ioutil.ReadAll(r.Body)
|
data, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
@ -348,7 +348,7 @@ func (xio *XtremIO) call(endpoint string) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
data, err := ioutil.ReadAll(resp.Body)
|
data, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ package xtremio
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -11,6 +9,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
@ -84,13 +84,13 @@ func TestFixedValue(t *testing.T) {
|
||||||
_, err := fmt.Fprintln(w, "authentication succeeded")
|
_, err := fmt.Fprintln(w, "authentication succeeded")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
} else if r.URL.Path == "/api/json/v3/types/bbus" {
|
} else if r.URL.Path == "/api/json/v3/types/bbus" {
|
||||||
sampleGetBBUsResponse, err := ioutil.ReadFile(filepath.Join(testdataDir, "sample_get_bbu_response.json"))
|
sampleGetBBUsResponse, err := os.ReadFile(filepath.Join(testdataDir, "sample_get_bbu_response.json"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_, err = fmt.Fprintln(w, string(sampleGetBBUsResponse))
|
_, err = fmt.Fprintln(w, string(sampleGetBBUsResponse))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
} else if r.URL.Path == "/api/json/v3/types/bbus/987654321abcdef" {
|
} else if r.URL.Path == "/api/json/v3/types/bbus/987654321abcdef" {
|
||||||
sampleBBUResponseOne, err := ioutil.ReadFile(filepath.Join(testdataDir, "sample_bbu_response.json"))
|
sampleBBUResponseOne, err := os.ReadFile(filepath.Join(testdataDir, "sample_bbu_response.json"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_, err = fmt.Fprintln(w, string(sampleBBUResponseOne))
|
_, err = fmt.Fprintln(w, string(sampleBBUResponseOne))
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package groundwork
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -29,7 +29,7 @@ func TestWriteWithDefaults(t *testing.T) {
|
||||||
|
|
||||||
// Simulate Groundwork server that should receive custom metrics
|
// Simulate Groundwork server that should receive custom metrics
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Decode body to use in assertions below
|
// Decode body to use in assertions below
|
||||||
|
|
@ -81,7 +81,7 @@ func TestWriteWithFields(t *testing.T) {
|
||||||
|
|
||||||
// Simulate Groundwork server that should receive custom metrics
|
// Simulate Groundwork server that should receive custom metrics
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Decode body to use in assertions below
|
// Decode body to use in assertions below
|
||||||
|
|
@ -142,7 +142,7 @@ func TestWriteWithTags(t *testing.T) {
|
||||||
|
|
||||||
// Simulate Groundwork server that should receive custom metrics
|
// Simulate Groundwork server that should receive custom metrics
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Decode body to use in assertions below
|
// Decode body to use in assertions below
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
|
||||||
"log" //nolint:revive
|
"log" //nolint:revive
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
@ -40,7 +40,7 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to marshal json: %v", err)
|
log.Fatalf("Failed to marshal json: %v", err)
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile("cmd/telegraf/versioninfo.json", file, 0644); err != nil {
|
if err := os.WriteFile("cmd/telegraf/versioninfo.json", file, 0644); err != nil {
|
||||||
log.Fatalf("Failed to write versioninfo.json: %v", err)
|
log.Fatalf("Failed to write versioninfo.json: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue