diff --git a/hack/gen-crd-spec/main.go b/hack/gen-crd-spec/main.go index 607f8ddd53..89f8cb59a9 100644 --- a/hack/gen-crd-spec/main.go +++ b/hack/gen-crd-spec/main.go @@ -3,7 +3,7 @@ package main import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "os" "os/exec" @@ -293,7 +293,7 @@ func loadK8SDefinitions() (spec.Definitions, error) { return nil, err } defer resp.Body.Close() - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) if err != nil { return nil, err } @@ -442,7 +442,7 @@ func generateKustomizeSchema(crds []*extensionsobj.CustomResourceDefinition, out if err != nil { return err } - return ioutil.WriteFile(outputPath, data, 0644) + return os.WriteFile(outputPath, data, 0644) } // Generate CRD spec for Rollout Resource @@ -480,7 +480,7 @@ func main() { if path == "" { panic(fmt.Sprintf("unknown kind: %s", crdKind)) } - err = ioutil.WriteFile(path, yamlBytes, 0644) + err = os.WriteFile(path, yamlBytes, 0644) checkErr(err) } } diff --git a/hack/gen-docs/main.go b/hack/gen-docs/main.go index b1201f2ba7..4e29e355be 100644 --- a/hack/gen-docs/main.go +++ b/hack/gen-docs/main.go @@ -4,16 +4,16 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "log" "os" "path/filepath" "sort" "strings" + "gopkg.in/yaml.v2" + "github.com/argoproj/notifications-engine/pkg/docs" "github.com/spf13/cobra" - "gopkg.in/yaml.v2" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/cmd" @@ -42,7 +42,7 @@ func generateNotificationsDocs() { func generatePluginsDocs() { tf, o := options.NewFakeArgoRolloutsOptions() - //Set static config dir so that gen docs does not change depending on what machine it is ran on + // Set static config dir so that gen docs does not change depending on what machine it is ran on configDir := "$HOME/.kube/cache" o.ConfigFlags.CacheDir = &configDir @@ -65,7 +65,7 @@ func generatePluginsDocs() { func updateMkDocsNav(parent string, child string, files []string) error { trimPrefixes(files, "docs/") sort.Strings(files) - data, err := ioutil.ReadFile("mkdocs.yml") + data, err := os.ReadFile("mkdocs.yml") if err != nil { return err } @@ -89,7 +89,7 @@ func updateMkDocsNav(parent string, child string, files []string) error { if err != nil { return err } - return ioutil.WriteFile("mkdocs.yml", newmkdocs, 0644) + return os.WriteFile("mkdocs.yml", newmkdocs, 0644) } func findNavItem(nav []interface{}, key string) (interface{}, int) { diff --git a/metricproviders/datadog/datadog.go b/metricproviders/datadog/datadog.go index 9461a61ed6..149be7e22d 100644 --- a/metricproviders/datadog/datadog.go +++ b/metricproviders/datadog/datadog.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "os" @@ -27,7 +27,7 @@ import ( var unixNow = func() int64 { return timeutil.Now().Unix() } const ( - //ProviderType indicates the provider is datadog + // ProviderType indicates the provider is datadog ProviderType = "Datadog" DatadogTokensSecretName = "datadog" DatadogApiKey = "api-key" @@ -131,7 +131,7 @@ func (p *Provider) Run(run *v1alpha1.AnalysisRun, metric v1alpha1.Metric) v1alph func (p *Provider) parseResponse(metric v1alpha1.Metric, response *http.Response) (string, v1alpha1.AnalysisPhase, error) { - bodyBytes, err := ioutil.ReadAll(response.Body) + bodyBytes, err := io.ReadAll(response.Body) if err != nil { return "", v1alpha1.AnalysisPhaseError, fmt.Errorf("Received no bytes in response: %v", err) diff --git a/metricproviders/graphite/api.go b/metricproviders/graphite/api.go index 23e2f4744b..b296295152 100644 --- a/metricproviders/graphite/api.go +++ b/metricproviders/graphite/api.go @@ -3,7 +3,7 @@ package graphite import ( "encoding/json" "fmt" - "io/ioutil" + "io" "math" "net/http" "net/url" @@ -53,7 +53,7 @@ func (api APIClient) Query(quer string) ([]dataPoint, error) { } defer r.Body.Close() - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { return []dataPoint{}, err } diff --git a/metricproviders/influxdb/influxdb_test.go b/metricproviders/influxdb/influxdb_test.go index d4f1512e54..028d66aed4 100644 --- a/metricproviders/influxdb/influxdb_test.go +++ b/metricproviders/influxdb/influxdb_test.go @@ -3,7 +3,7 @@ package influxdb import ( "errors" "fmt" - "io/ioutil" + "io" "strings" "testing" @@ -39,7 +39,7 @@ func TestRunSuccessfully(t *testing.T) { ,,0,2020-02-17T22:19:49.747562847Z,2020-02-18T22:19:49.747562847Z,2020-02-18T22:08:44.850214724Z,6.6,f,test,1,adsfasdf ` reader := strings.NewReader(csvTable) - result := influxdb2.NewQueryTableResult(ioutil.NopCloser(reader)) + result := influxdb2.NewQueryTableResult(io.NopCloser(reader)) mock := &mockAPI{response: result} p := NewInfluxdbProvider(mock, e) metric := v1alpha1.Metric{ @@ -71,7 +71,7 @@ func TestRunWithTimeseries(t *testing.T) { ,,0,2020-02-17T22:19:49.747562847Z,2020-02-18T22:19:49.747562847Z,2020-02-18T22:08:44.850214724Z,20,f,test,1,adsfasdf ` reader := strings.NewReader(csvTable) - result := influxdb2.NewQueryTableResult(ioutil.NopCloser(reader)) + result := influxdb2.NewQueryTableResult(io.NopCloser(reader)) mock := &mockAPI{response: result} p := NewInfluxdbProvider(mock, e) metric := v1alpha1.Metric{ @@ -102,7 +102,7 @@ func TestRunWithEmptyResult(t *testing.T) { ,result,table,_start,_stop,_time,_value,_field,_measurement,a,b ` reader := strings.NewReader(csvTable) - result := influxdb2.NewQueryTableResult(ioutil.NopCloser(reader)) + result := influxdb2.NewQueryTableResult(io.NopCloser(reader)) mock := &mockAPI{response: result} p := NewInfluxdbProvider(mock, *e) metric := v1alpha1.Metric{ diff --git a/metricproviders/kayenta/kayenta.go b/metricproviders/kayenta/kayenta.go index fbfbc42123..a6b93f40e6 100644 --- a/metricproviders/kayenta/kayenta.go +++ b/metricproviders/kayenta/kayenta.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "time" @@ -19,7 +19,7 @@ import ( ) const ( - //ProviderType indicates the provider is kayenta + // ProviderType indicates the provider is kayenta ProviderType = "Kayenta" scoreURLFormat = `%s/canary/%s` @@ -78,7 +78,7 @@ func getCanaryConfigId(metric v1alpha1.Metric, p *Provider) (string, error) { return "", err } - data, err := ioutil.ReadAll(response.Body) + data, err := io.ReadAll(response.Body) if err != nil { return "", err } @@ -142,7 +142,7 @@ func (p *Provider) Run(run *v1alpha1.AnalysisRun, metric v1alpha1.Metric) v1alph return metricutil.MarkMeasurementError(newMeasurement, err) } - data, err := ioutil.ReadAll(response.Body) + data, err := io.ReadAll(response.Body) if err != nil { return metricutil.MarkMeasurementError(newMeasurement, err) } @@ -180,7 +180,7 @@ func (p *Provider) Resume(run *v1alpha1.AnalysisRun, metric v1alpha1.Metric, mea return metricutil.MarkMeasurementError(measurement, err) } - data, err := ioutil.ReadAll(response.Body) + data, err := io.ReadAll(response.Body) if err != nil { return metricutil.MarkMeasurementError(measurement, err) } @@ -194,7 +194,7 @@ func (p *Provider) Resume(run *v1alpha1.AnalysisRun, metric v1alpha1.Metric, mea status, ok, err := unstructured.NestedBool(patch, "complete") if ok { - if !status { //resume later since it is incomplete + if !status { // resume later since it is incomplete resumeTime := metav1.NewTime(timeutil.Now().Add(resumeDelay)) measurement.ResumeAt = &resumeTime measurement.Phase = v1alpha1.AnalysisPhaseRunning diff --git a/metricproviders/kayenta/kayenta_test.go b/metricproviders/kayenta/kayenta_test.go index 6cb8fde82b..abfed0f7c1 100644 --- a/metricproviders/kayenta/kayenta_test.go +++ b/metricproviders/kayenta/kayenta_test.go @@ -3,7 +3,7 @@ package kayenta import ( "bytes" "encoding/json" - "io/ioutil" + "io" "net/http" "testing" @@ -153,7 +153,7 @@ func TestRunSuccessfully(t *testing.T) { c := NewTestClient(func(req *http.Request) *http.Response { if req.URL.String() == jobURL { assert.Equal(t, req.URL.String(), jobURL) - body, err := ioutil.ReadAll(req.Body) + body, err := io.ReadAll(req.Body) if err != nil { panic(err) } @@ -171,7 +171,7 @@ func TestRunSuccessfully(t *testing.T) { return &http.Response{ StatusCode: 200, // Send response to be tested - Body: ioutil.NopCloser(bytes.NewBufferString(` + Body: io.NopCloser(bytes.NewBufferString(` { "canaryExecutionId" : "01DS50WVHAWSTAQACJKB1VKDQB" } @@ -186,7 +186,7 @@ func TestRunSuccessfully(t *testing.T) { return &http.Response{ StatusCode: 200, // Send response to be tested - Body: ioutil.NopCloser(bytes.NewBufferString(configIdLookupResponse)), + Body: io.NopCloser(bytes.NewBufferString(configIdLookupResponse)), // Must be set to non-nil value or it panics Header: make(http.Header), } @@ -235,11 +235,11 @@ func TestRunBadJobResponse(t *testing.T) { return &http.Response{ StatusCode: 500, // Send response to be tested - // Body: ioutil.NopCloser(bytes.NewBufferString(` - //{ + // Body: io.NopCloser(bytes.NewBufferString(` + // { // "canaryExecutionId" : "01DS50WVHAWSTAQACJKB1VKDQB" - //} - //`)), + // } + // `)), // Must be set to non-nil value or it panics Header: make(http.Header), } @@ -250,7 +250,7 @@ func TestRunBadJobResponse(t *testing.T) { return &http.Response{ StatusCode: 200, // Send response to be tested - Body: ioutil.NopCloser(bytes.NewBufferString(configIdLookupResponse)), + Body: io.NopCloser(bytes.NewBufferString(configIdLookupResponse)), // Must be set to non-nil value or it panics Header: make(http.Header), } @@ -287,7 +287,7 @@ func TestRunBadLookupResponse(t *testing.T) { if req.URL.String() == jobURL { assert.Equal(t, req.URL.String(), jobURL) - body, _ := ioutil.ReadAll(req.Body) + body, _ := io.ReadAll(req.Body) assert.Equal(t, string(body), ` { "scopes": { @@ -302,11 +302,11 @@ func TestRunBadLookupResponse(t *testing.T) { return &http.Response{ StatusCode: 500, // Send response to be tested - // Body: ioutil.NopCloser(bytes.NewBufferString(` - //{ + // Body: io.NopCloser(bytes.NewBufferString(` + // { // "canaryExecutionId" : "01DS50WVHAWSTAQACJKB1VKDQB" - //} - //`)), + // } + // `)), // Must be set to non-nil value or it panics Header: make(http.Header), } @@ -317,7 +317,7 @@ func TestRunBadLookupResponse(t *testing.T) { return &http.Response{ StatusCode: 500, // Send response to be tested - //Body: ioutil.NopCloser(bytes.NewBufferString(configIdLookupResponse)), + // Body: io.NopCloser(bytes.NewBufferString(configIdLookupResponse)), // Must be set to non-nil value or it panics Header: make(http.Header), } @@ -352,7 +352,7 @@ func TestRunInvalidLookupResponse(t *testing.T) { if req.URL.String() == jobURL { assert.Equal(t, req.URL.String(), jobURL) - body, _ := ioutil.ReadAll(req.Body) + body, _ := io.ReadAll(req.Body) assert.Equal(t, string(body), ` { "scopes": { @@ -367,11 +367,11 @@ func TestRunInvalidLookupResponse(t *testing.T) { return &http.Response{ StatusCode: 500, // Send response to be tested - // Body: ioutil.NopCloser(bytes.NewBufferString(` - //{ + // Body: io.NopCloser(bytes.NewBufferString(` + // { // "canaryExecutionId" : "01DS50WVHAWSTAQACJKB1VKDQB" - //} - //`)), + // } + // `)), // Must be set to non-nil value or it panics Header: make(http.Header), } @@ -382,7 +382,7 @@ func TestRunInvalidLookupResponse(t *testing.T) { return &http.Response{ StatusCode: 200, // Send response to be tested - Body: ioutil.NopCloser(bytes.NewBufferString(`{"this is bad": "yee"}`)), + Body: io.NopCloser(bytes.NewBufferString(`{"this is bad": "yee"}`)), // Must be set to non-nil value or it panics Header: make(http.Header), } @@ -419,7 +419,7 @@ func TestRunEmptyExecutionId(t *testing.T) { return &http.Response{ StatusCode: 200, // Send response to be tested - Body: ioutil.NopCloser(bytes.NewBufferString(` + Body: io.NopCloser(bytes.NewBufferString(` { "canaryExecutionId" : "" } @@ -434,7 +434,7 @@ func TestRunEmptyExecutionId(t *testing.T) { return &http.Response{ StatusCode: 200, // Send response to be tested - Body: ioutil.NopCloser(bytes.NewBufferString(configIdLookupResponse)), + Body: io.NopCloser(bytes.NewBufferString(configIdLookupResponse)), // Must be set to non-nil value or it panics Header: make(http.Header), } @@ -471,8 +471,8 @@ func TestResumeSuccessfully(t *testing.T) { return &http.Response{ StatusCode: 200, - //result.judgeResult.score.score - Body: ioutil.NopCloser(bytes.NewBufferString(` + // result.judgeResult.score.score + Body: io.NopCloser(bytes.NewBufferString(` { "complete" : true, "result" : { @@ -540,8 +540,8 @@ func TestResumeMissingScore(t *testing.T) { return &http.Response{ StatusCode: 200, - //result.judgeResult.score.score - Body: ioutil.NopCloser(bytes.NewBufferString(` + // result.judgeResult.score.score + Body: io.NopCloser(bytes.NewBufferString(` { "complete" : true, "result" : { @@ -578,8 +578,8 @@ func TestResumeFailure(t *testing.T) { return &http.Response{ StatusCode: 200, - //result.judgeResult.score.score - Body: ioutil.NopCloser(bytes.NewBufferString(` + // result.judgeResult.score.score + Body: io.NopCloser(bytes.NewBufferString(` { "complete" : true, "result" : { @@ -617,8 +617,8 @@ func TestResumeInconclusive(t *testing.T) { return &http.Response{ StatusCode: 200, - //result.judgeResult.score.score - Body: ioutil.NopCloser(bytes.NewBufferString(` + // result.judgeResult.score.score + Body: io.NopCloser(bytes.NewBufferString(` { "complete" : true, "result" : { @@ -656,8 +656,8 @@ func TestResumeIncompleteStatus(t *testing.T) { return &http.Response{ StatusCode: 200, - //result.judgeResult.score.score - Body: ioutil.NopCloser(bytes.NewBufferString(` + // result.judgeResult.score.score + Body: io.NopCloser(bytes.NewBufferString(` { "complete" : false, "result" : { @@ -696,8 +696,8 @@ func TestResumeMissingCompleteStatus(t *testing.T) { return &http.Response{ StatusCode: 200, - //result.judgeResult.score.score - Body: ioutil.NopCloser(bytes.NewBufferString(` + // result.judgeResult.score.score + Body: io.NopCloser(bytes.NewBufferString(` { "result" : { "judgeResult": { diff --git a/metricproviders/webmetric/webmetric.go b/metricproviders/webmetric/webmetric.go index dce1865e5a..e32531f92a 100644 --- a/metricproviders/webmetric/webmetric.go +++ b/metricproviders/webmetric/webmetric.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "reflect" "strings" @@ -122,7 +121,7 @@ func (p *Provider) Run(run *v1alpha1.AnalysisRun, metric v1alpha1.Metric) v1alph func (p *Provider) parseResponse(metric v1alpha1.Metric, response *http.Response) (string, v1alpha1.AnalysisPhase, error) { var data interface{} - bodyBytes, err := ioutil.ReadAll(response.Body) + bodyBytes, err := io.ReadAll(response.Body) if err != nil { return "", v1alpha1.AnalysisPhaseError, fmt.Errorf("Received no bytes in response: %v", err) } diff --git a/pkg/kubectl-argo-rollouts/cmd/create/create.go b/pkg/kubectl-argo-rollouts/cmd/create/create.go index 2a22a7130e..f00f4ebd86 100644 --- a/pkg/kubectl-argo-rollouts/cmd/create/create.go +++ b/pkg/kubectl-argo-rollouts/cmd/create/create.go @@ -6,7 +6,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "os" "strings" "unicode" @@ -153,7 +153,7 @@ func (c *CreateOptions) getNamespace(un unstructured.Unstructured) string { func (c *CreateOptions) createResource(path string) (runtime.Object, error) { ctx := context.TODO() - fileBytes, err := ioutil.ReadFile(path) + fileBytes, err := os.ReadFile(path) if err != nil { return nil, err } @@ -332,7 +332,7 @@ func (c *CreateAnalysisRunOptions) getAnalysisTemplate() (*unstructured.Unstruct if c.From != "" { return c.DynamicClient.Resource(v1alpha1.AnalysisTemplateGVR).Namespace(c.Namespace()).Get(ctx, c.From, metav1.GetOptions{}) } else { - fileBytes, err := ioutil.ReadFile(c.FromFile) + fileBytes, err := os.ReadFile(c.FromFile) if err != nil { return nil, err } @@ -350,7 +350,7 @@ func (c *CreateAnalysisRunOptions) getClusterAnalysisTemplate() (*unstructured.U if c.From != "" { return c.DynamicClient.Resource(v1alpha1.ClusterAnalysisTemplateGVR).Get(ctx, c.From, metav1.GetOptions{}) } else { - fileBytes, err := ioutil.ReadFile(c.FromFile) + fileBytes, err := os.ReadFile(c.FromFile) if err != nil { return nil, err } diff --git a/pkg/kubectl-argo-rollouts/cmd/create/create_test.go b/pkg/kubectl-argo-rollouts/cmd/create/create_test.go index 38c98e98df..b4cf5bb16e 100644 --- a/pkg/kubectl-argo-rollouts/cmd/create/create_test.go +++ b/pkg/kubectl-argo-rollouts/cmd/create/create_test.go @@ -2,7 +2,7 @@ package create import ( "bytes" - "io/ioutil" + "os" "testing" "github.com/stretchr/testify/assert" @@ -207,7 +207,7 @@ func TestCreateJSON(t *testing.T) { func TestCreateAnalysisRunFromTemplateInCluster(t *testing.T) { var template unstructured.Unstructured - fileBytes, err := ioutil.ReadFile("testdata/analysis-template.yaml") + fileBytes, err := os.ReadFile("testdata/analysis-template.yaml") assert.NoError(t, err) err = unmarshal(fileBytes, &template) assert.NoError(t, err) @@ -245,7 +245,7 @@ func TestCreateAnalysisRunFromTemplateNotFoundInCluster(t *testing.T) { func TestCreateAnalysisRunFromClusterTemplateInCluster(t *testing.T) { var template unstructured.Unstructured - fileBytes, err := ioutil.ReadFile("testdata/cluster-analysis-template.yaml") + fileBytes, err := os.ReadFile("testdata/cluster-analysis-template.yaml") assert.NoError(t, err) err = unmarshal(fileBytes, &template) assert.NoError(t, err) diff --git a/pkg/kubectl-argo-rollouts/cmd/lint/lint.go b/pkg/kubectl-argo-rollouts/cmd/lint/lint.go index c7cb091a0a..d31c5d3547 100644 --- a/pkg/kubectl-argo-rollouts/cmd/lint/lint.go +++ b/pkg/kubectl-argo-rollouts/cmd/lint/lint.go @@ -4,7 +4,7 @@ import ( "bytes" "fmt" "io" - "io/ioutil" + "os" "github.com/argoproj/argo-rollouts/pkg/apis/rollouts" "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1" @@ -70,7 +70,7 @@ func unmarshal(fileBytes []byte, obj interface{}) error { } func (l *LintOptions) lintResource(path string) error { - fileBytes, err := ioutil.ReadFile(path) + fileBytes, err := os.ReadFile(path) if err != nil { return err } diff --git a/pkg/kubectl-argo-rollouts/info/testdata/testdata.go b/pkg/kubectl-argo-rollouts/info/testdata/testdata.go index 8ac7e5622f..a0f5911998 100644 --- a/pkg/kubectl-argo-rollouts/info/testdata/testdata.go +++ b/pkg/kubectl-argo-rollouts/info/testdata/testdata.go @@ -1,7 +1,7 @@ package testdata import ( - "io/ioutil" + "os" "path" "runtime" "time" @@ -80,7 +80,7 @@ func NewAbortedRollout() *RolloutObjects { } func discoverObjects(path string) *RolloutObjects { - files, err := ioutil.ReadDir(path) + files, err := os.ReadDir(path) if err != nil { panic(err) } @@ -89,7 +89,7 @@ func discoverObjects(path string) *RolloutObjects { var objs RolloutObjects for _, file := range files { - yamlBytes, err := ioutil.ReadFile(path + "/" + file.Name()) + yamlBytes, err := os.ReadFile(path + "/" + file.Name()) if err != nil { panic(err) } diff --git a/test/fixtures/common.go b/test/fixtures/common.go index ed03d7efcc..c40715f7bc 100644 --- a/test/fixtures/common.go +++ b/test/fixtures/common.go @@ -5,7 +5,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "os" "os/exec" "strings" @@ -207,7 +206,7 @@ func (c *Common) MarkPodsReady(revision string, quantity int) int { } time.Sleep(500 * time.Millisecond) } - //c.log.Infof("Conditions: %v", pod.Status.Conditions) + // c.log.Infof("Conditions: %v", pod.Status.Conditions) marked += 1 } } @@ -446,7 +445,7 @@ func (c *Common) yamlBytes(text string) []byte { var err error if strings.HasPrefix(text, "@") { file := strings.TrimPrefix(text, "@") - yamlBytes, err = ioutil.ReadFile(file) + yamlBytes, err = os.ReadFile(file) c.CheckError(err) } else { yamlBytes = []byte(text) diff --git a/test/util/util.go b/test/util/util.go index a783107ebf..9868da6bff 100644 --- a/test/util/util.go +++ b/test/util/util.go @@ -1,7 +1,7 @@ package util import ( - "io/ioutil" + "os" "github.com/ghodss/yaml" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -27,7 +27,7 @@ func ObjectFromYAML(yamlStr string) *unstructured.Unstructured { // ObjectFromPath returns a runtime.Object from the given path. Path is a relative path from source root func ObjectFromPath(path string) *unstructured.Unstructured { path = "../../" + path - body, err := ioutil.ReadFile(path) + body, err := os.ReadFile(path) if err != nil { panic(err) } diff --git a/utils/defaults/defaults.go b/utils/defaults/defaults.go index 800cae608c..8c1c171219 100644 --- a/utils/defaults/defaults.go +++ b/utils/defaults/defaults.go @@ -1,7 +1,6 @@ package defaults import ( - "io/ioutil" "os" "strconv" "strings" @@ -256,7 +255,7 @@ func Namespace() string { return ns } // Fall back to the namespace associated with the service account token, if available - if data, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil { + if data, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil { if ns := strings.TrimSpace(string(data)); len(ns) > 0 { return ns }