Skip to content

Commit

Permalink
Clean up all lint issues found by make check.
Browse files Browse the repository at this point in the history
  • Loading branch information
bendory authored and tekton-robot committed Aug 22, 2022
1 parent 476a1be commit c1bb76a
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 40 deletions.
5 changes: 2 additions & 3 deletions cmd/docs/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -15,7 +15,6 @@ package main

import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -86,7 +85,7 @@ func loadLongDescription(cmd *cobra.Command, path ...string) error {
continue
}

content, err := ioutil.ReadFile(fullpath)
content, err := os.ReadFile(fullpath)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/docs/md_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions pkg/bundle/keychain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package bundle
import (
"encoding/base64"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
Expand All @@ -18,7 +17,7 @@ import (
var testRegistry, _ = name.NewRegistry("test.io", name.WeakValidation)

func setupConfigDir(t *testing.T) string {
tmpdir, err := ioutil.TempDir("", "keychain")
tmpdir, err := os.MkdirTemp(os.TempDir(), "keychain")
if err != nil {
t.Fatalf("creating temp dir: %v", err)
}
Expand All @@ -40,7 +39,7 @@ func setUpConfigFile(t *testing.T, content string) string {
t.Fatalf("unable to mkdir %q: %v", authFileDir, err)
}

if err := ioutil.WriteFile(authFile, []byte(content), 0600); err != nil {
if err := os.WriteFile(authFile, []byte(content), 0600); err != nil {
t.Fatalf("write %q: %v", authFile, err)
}
return tmpdir
Expand Down
6 changes: 3 additions & 3 deletions pkg/bundle/remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package bundle
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"net/http/httptest"
"net/url"
"os"
Expand All @@ -18,7 +18,7 @@ import (
)

func TestWriteAndRead(t *testing.T) {
tempDir, err := ioutil.TempDir(os.TempDir(), "write-and-read-test")
tempDir, err := os.MkdirTemp(os.TempDir(), "write-and-read-test")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -82,7 +82,7 @@ func TestWriteAndRead(t *testing.T) {
}

reader, _ := layers[0].Uncompressed()
remoteContents, err := ioutil.ReadAll(reader)
remoteContents, err := io.ReadAll(reader)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/bundle/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions pkg/cmd/bundle/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -15,7 +15,8 @@ package bundle

import (
"fmt"
"io/ioutil"
"io"
"os"

"github.com/google/go-containerregistry/pkg/name"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -92,15 +93,15 @@ func (p *pushOptions) parseArgsAndFlags(args []string) error {
for _, path := range p.bundleContentPaths {
if path == "-" {
// If this flag's value is '-', assume the user has piped input into stdin.
stdinContents, err := ioutil.ReadAll(p.stream.In)
stdinContents, err := io.ReadAll(p.stream.In)
if err != nil || len(stdinContents) == 0 {
return fmt.Errorf("failed to read bundle contents from stdin: %w", err)
}
p.bundleContents = append(p.bundleContents, string(stdinContents))
continue
}

contents, err := ioutil.ReadFile(path)
contents, err := os.ReadFile(path)
if err != nil {
return fmt.Errorf("failed to find and read file %s: %w", path, err)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/cmd/bundle/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"net/http/httptest"
"net/url"
"os"
Expand Down Expand Up @@ -85,7 +84,7 @@ func TestPushCommand(t *testing.T) {

ref := fmt.Sprintf("%s/test-img-namespace/%s:1.0", u.Host, tc.name)

testDir, err := ioutil.TempDir(os.TempDir(), tc.name+"-")
testDir, err := os.MkdirTemp(os.TempDir(), tc.name+"-")
if err != nil {
t.Fatal(err)
}
Expand All @@ -99,7 +98,7 @@ func TestPushCommand(t *testing.T) {
}

filename := path.Join(testDir, name)
if err := ioutil.WriteFile(filename, []byte(contents), os.ModePerm); err != nil {
if err := os.WriteFile(filename, []byte(contents), os.ModePerm); err != nil {
t.Fatalf("failed to write file %s: %s", filename, err)
}
paths = append(paths, filename)
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package cmd

import (
"fmt"
"io/ioutil"
"os"
"strings"
"testing"

Expand Down Expand Up @@ -69,9 +69,9 @@ func TestPluginList(t *testing.T) {
nd := fs.NewDir(t, "TestPluginList")
defer nd.Remove()
// nolint: gosec
err := ioutil.WriteFile(nd.Join("tkn-exec"), []byte("exec"), 0o700)
err := os.WriteFile(nd.Join("tkn-exec"), []byte("exec"), 0o700)
assert.NilError(t, err)
err = ioutil.WriteFile(nd.Join("tkn-nonexec"), []byte("nonexec"), 0o600)
err = os.WriteFile(nd.Join("tkn-nonexec"), []byte("nonexec"), 0o600)
assert.NilError(t, err)
t.Setenv("PATH", nd.Path()+":/non/existing/path")
t.Setenv("TKN_PLUGINS_DIR", "/non/existing/path")
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package version
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"strings"
Expand Down Expand Up @@ -221,7 +221,7 @@ func (cli *Client) getRelease(url string) (ghversion GHVersion, err error) {
return ghversion, fmt.Errorf("invalid http status %d, error: %s", res.StatusCode, res.Status)
}

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return ghversion, errors.Wrap(err, "failed to read the latest version response body")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package file
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strings"
)

Expand All @@ -44,7 +44,7 @@ func LoadFileContent(httpClient http.Client, target string, validate TypeValidat
if strings.HasPrefix(target, "http") {
content, err = getRemoteContent(httpClient, target)
} else {
content, err = ioutil.ReadFile(target)
content, err = os.ReadFile(target)
}

if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/file/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package file

import (
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
"testing"

Expand All @@ -29,7 +29,7 @@ import (

func TestLoadLocalFile(t *testing.T) {
localTarget := "./testdata/task.yaml"
localContent, err := ioutil.ReadFile(localTarget)
localContent, err := os.ReadFile(localTarget)
if err != nil {
t.Errorf("file path %s does not exist", localTarget)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/formatted/color_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions pkg/plugins/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package plugins

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -60,7 +59,7 @@ func GetAllTknPluginFromPaths() []string {
// and add them to the completion command
for _, path := range paths {
// list all files in path
files, err := ioutil.ReadDir(path)
files, err := os.ReadDir(path)
if err != nil {
continue
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/plugins/plugins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package plugins

import (
"fmt"
"io/ioutil"
"os"
"testing"

"gotest.tools/v3/assert"
Expand All @@ -13,7 +13,7 @@ func TestFindPlugin(t *testing.T) {
nd := fs.NewDir(t, "TestFindPlugins")
defer nd.Remove()
// nolint: gosec
err := ioutil.WriteFile(nd.Join("tkn-test"), []byte("test"), 0o700)
err := os.WriteFile(nd.Join("tkn-test"), []byte("test"), 0o700)
assert.NilError(t, err)
t.Setenv(pluginDirEnv, nd.Path())
path, err := FindPlugin("test")
Expand All @@ -25,7 +25,7 @@ func TestFindPluginInPath(t *testing.T) {
nd := fs.NewDir(t, "TestFindPluginsInPath")
defer nd.Remove()
// nolint: gosec
err := ioutil.WriteFile(nd.Join("tkn-testp"), []byte("testp"), 0o700)
err := os.WriteFile(nd.Join("tkn-testp"), []byte("testp"), 0o700)
assert.NilError(t, err)
t.Setenv("PATH", nd.Path())
path, err := FindPlugin("testp")
Expand All @@ -37,7 +37,7 @@ func TestGetAllTknPluginFromPathPlugindir(t *testing.T) {
nd := fs.NewDir(t, "TestGetAllTknPluginFromPluginPath")
defer nd.Remove()
// nolint: gosec
err := ioutil.WriteFile(nd.Join("tkn-fromplugindir"), []byte("test"), 0o700)
err := os.WriteFile(nd.Join("tkn-fromplugindir"), []byte("test"), 0o700)
assert.NilError(t, err)

t.Setenv("PATH", "")
Expand All @@ -54,13 +54,13 @@ func TestGetAllTknPluginFromPaths(t *testing.T) {
nd := fs.NewDir(t, "TestGetAllTknPluginFromPaths1")
defer nd.Remove()
// nolint: gosec
err := ioutil.WriteFile(nd.Join("tkn-test"), []byte("testp"), 0o700)
err := os.WriteFile(nd.Join("tkn-test"), []byte("testp"), 0o700)
assert.NilError(t, err)

nd2 := fs.NewDir(t, "TestGetAllTknPluginFromPaths2")
defer nd2.Remove()
// nolint: gosec
err = ioutil.WriteFile(nd.Join("tkn-test"), []byte("testp"), 0o700)
err = os.WriteFile(nd.Join("tkn-test"), []byte("testp"), 0o700)
assert.NilError(t, err)

t.Setenv("PATH", fmt.Sprintf("%s:%s", nd.Path(), nd2.Path()))
Expand Down
3 changes: 1 addition & 2 deletions pkg/pods/fake/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package fake
import (
"fmt"
"io"
"io/ioutil"
"strings"

"github.com/tektoncd/cli/pkg/pods/stream"
Expand All @@ -41,7 +40,7 @@ func (ps *PodStream) Stream() (io.ReadCloser, error) {
for _, c := range fl.Containers {
if c.Name == ps.opts.Container {
log := strings.Join(c.Logs, "\n")
return ioutil.NopCloser(strings.NewReader(log)), nil
return io.NopCloser(strings.NewReader(log)), nil
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/framework/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package framework
import (
"context"
"fmt"
"io/ioutil"
"io"
"strings"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -49,7 +49,7 @@ func getContainerLogsFromPod(c kubernetes.Interface, pod, namespace string) (str
if err != nil {
return "", err
}
bs, err := ioutil.ReadAll(rc)
bs, err := io.ReadAll(rc)
if err != nil {
return "", err
}
Expand Down

0 comments on commit c1bb76a

Please sign in to comment.