Fix lint errors with new build tools (#11679)

* Fix lint errors with new build tools

* Move copyright so it doesn't get marked as a heading

I beleive Istio removed copyrights so we could do a bigger clense
later.
This commit is contained in:
Eric Van Norman 2022-08-03 16:09:23 -05:00 committed by GitHub
parent 33125be32a
commit d146b3bfce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 23 additions and 28 deletions

View File

@ -1,14 +1,14 @@
// Copyright 2020 Istio Authors
//
// Package istioio includes the framework for doc testing. This package will
// first scan through all the docs to collect their information, and then
// setup istio as appropriate to run each test.
//
// Copyright 2020 Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@ -19,7 +19,6 @@ package istioio
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
@ -123,7 +122,7 @@ func checkFile(path string) (*TestCase, error) {
testCase := &TestCase{path: shortPath}
// read the script file
script, err := ioutil.ReadFile(path)
script, err := os.ReadFile(path)
if err != nil {
return testCase, err
}

View File

@ -17,7 +17,6 @@ package istioio
import (
"bufio"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path"
@ -45,16 +44,15 @@ var _ Step = Script{}
//
// To simplify common tasks, the following environment variables are set when the script is executed:
//
// - TEST_OUTPUT_DIR:
// Set to the working directory of the current test. By default, scripts are run from this
// directory. This variable is useful for cases where the execution `WorkDir` has been set,
// but the script needs to access files in the test working directory.
// - TEST_DEBUG_FILE:
// Set to the file where debugging output will be written.
// - KUBECONFIG:
// Set to the value from the test framework. This is necessary to make kubectl commands execute
// with the configuration specified on the command line.
//
// - TEST_OUTPUT_DIR:
// Set to the working directory of the current test. By default, scripts are run from this
// directory. This variable is useful for cases where the execution `WorkDir` has been set,
// but the script needs to access files in the test working directory.
// - TEST_DEBUG_FILE:
// Set to the file where debugging output will be written.
// - KUBECONFIG:
// Set to the value from the test framework. This is necessary to make kubectl commands execute
// with the configuration specified on the command line.
type Script struct {
// Input for the parser.
Input Input
@ -89,7 +87,7 @@ func (s Script) run(ctx framework.TestContext) {
// Copy the command to workDir.
_, fileName := filepath.Split(s.Name())
if err := ioutil.WriteFile(path.Join(ctx.WorkDir(), fileName), []byte(command), 0o644); err != nil {
if err := os.WriteFile(path.Join(ctx.WorkDir(), fileName), []byte(command), 0o644); err != nil {
ctx.Fatalf("failed copying command %s to workDir: %v", s.Name(), err)
}

View File

@ -16,7 +16,6 @@ package istioio
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
@ -54,7 +53,7 @@ func (s SnapshotValidator) run(ctx framework.TestContext) {
return
}
inBeforeBytes, err := ioutil.ReadFile(inBeforeFile)
inBeforeBytes, err := os.ReadFile(inBeforeFile)
if err != nil {
ctx.Fatalf("failed reading before snapshot: %v", err)
}
@ -62,7 +61,7 @@ func (s SnapshotValidator) run(ctx framework.TestContext) {
// Copy the before file to the current working directory to aid debugging.
inBeforeFileCopy := filepath.Join(ctx.WorkDir(), filepath.Base(inBeforeFile))
if err := ioutil.WriteFile(inBeforeFileCopy, inBeforeBytes, os.ModePerm); err != nil {
if err := os.WriteFile(inBeforeFileCopy, inBeforeBytes, os.ModePerm); err != nil {
ctx.Fatalf("failed copying before snapshot: %v", err)
}
@ -92,8 +91,8 @@ func (s SnapshotValidator) run(ctx framework.TestContext) {
return nil, true, err
}
if err := ioutil.WriteFile(diffFile, []byte(diffText), os.ModePerm); err != nil {
// Fatal error, shouldn't happen
if err := os.WriteFile(diffFile, []byte(diffText), os.ModePerm); err != nil {
// Fatal os.shouldn't happen
return nil, true, err
}

View File

@ -15,7 +15,6 @@
package istioio
import (
"io/ioutil"
"os"
"path/filepath"
@ -59,7 +58,7 @@ func (s *Snapshotter) run(ctx framework.TestContext) {
}
outputFile := filepath.Join(ctx.WorkDir(), s.StepName+".json")
if err := ioutil.WriteFile(outputFile, []byte(snapshotJSON), os.ModePerm); err != nil {
if err := os.WriteFile(outputFile, []byte(snapshotJSON), os.ModePerm); err != nil {
ctx.Fatal("failed writing snapshot file: %v", err)
}

View File

@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,