Skip to content

Commit

Permalink
Merge pull request #1193 from vrothberg/bump-golangci
Browse files Browse the repository at this point in the history
bump to golangci-lint v1.50.0
  • Loading branch information
openshift-merge-robot authored Oct 17, 2022
2 parents 7a4bcca + 4a4d905 commit 98295c0
Show file tree
Hide file tree
Showing 77 changed files with 310 additions and 333 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
permissions: read-all

env:
LINT_VERSION: v1.45
LINT_VERSION: v1.50

jobs:
codespell:
Expand All @@ -31,7 +31,7 @@ jobs:
fetch-depth: 2
- uses: actions/setup-go@f6164bd8c8acb4a71fb2791a8b6c4024ff038dab # v3
with:
go-version: 1.18
go-version: 1.19
- name: install deps
run: |
sudo apt-get -qq update
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ vendor:
.PHONY: install.tools
install.tools: build/golangci-lint .install.md2man

build/golangci-lint: VERSION=v1.45.2
build/golangci-lint: VERSION=v1.50.0
build/golangci-lint:
curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/$(VERSION)/install.sh | sh -s -- -b ./build $(VERSION)

Expand Down
3 changes: 1 addition & 2 deletions libimage/corrupted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package libimage

import (
"context"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -50,7 +49,7 @@ func TestCorruptedLayers(t *testing.T) {
// image will still be listed in the container storage but attempting
// to use it will yield "layer not known" errors.
indexPath := filepath.Join(runtime.store.GraphRoot(), "vfs-layers/layers.json")
data, err := ioutil.ReadFile(indexPath)
data, err := os.ReadFile(indexPath)
require.NoError(t, err, "loading layers.json")
layers := []*storage.Layer{}
err = json.Unmarshal(data, &layers)
Expand Down
3 changes: 2 additions & 1 deletion libimage/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ func (r *Runtime) filterImages(ctx context.Context, images []*Image, options *Li

// compileImageFilters creates `filterFunc`s for the specified filters. The
// required format is `key=value` with the following supported keys:
// after, since, before, containers, dangling, id, label, readonly, reference, intermediate
//
// after, since, before, containers, dangling, id, label, readonly, reference, intermediate
func (r *Runtime) compileImageFilters(ctx context.Context, options *ListImagesOptions) (map[string][]filterFunc, error) {
logrus.Tracef("Parsing image filters %s", options.Filters)

Expand Down
3 changes: 1 addition & 2 deletions libimage/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package libimage

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

Expand All @@ -15,7 +14,7 @@ func TestLoad(t *testing.T) {
tmpdir := t.TempDir()
os.Setenv("TMPDIR", tmpdir)
defer func() {
dir, err := ioutil.ReadDir(tmpdir)
dir, err := os.ReadDir(tmpdir)
require.NoError(t, err)
require.Len(t, dir, 0)
os.Unsetenv("TMPDIR")
Expand Down
9 changes: 4 additions & 5 deletions libimage/manifests/manifests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package manifests
import (
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -47,7 +46,7 @@ func TestSaveLoad(t *testing.T) {
t.Skip("Test can only run as root")
}

dir, err := ioutil.TempDir("", "manifests")
dir, err := os.MkdirTemp("", "manifests")
assert.Nilf(t, err, "error creating temporary directory")
defer os.RemoveAll(dir)

Expand Down Expand Up @@ -165,7 +164,7 @@ func TestReference(t *testing.T) {
}
ctx := context.Background()

dir, err := ioutil.TempDir("", "manifests")
dir, err := os.MkdirTemp("", "manifests")
assert.Nilf(t, err, "error creating temporary directory")
defer os.RemoveAll(dir)

Expand Down Expand Up @@ -265,7 +264,7 @@ func TestPush(t *testing.T) {
}
ctx := context.Background()

dir, err := ioutil.TempDir("", "manifests")
dir, err := os.MkdirTemp("", "manifests")
assert.Nilf(t, err, "error creating temporary directory")
defer os.RemoveAll(dir)

Expand All @@ -285,7 +284,7 @@ func TestPush(t *testing.T) {
}
}()

dest, err := ioutil.TempDir("", "manifests")
dest, err := os.MkdirTemp("", "manifests")
assert.Nilf(t, err, "error creating temporary directory")
defer os.RemoveAll(dest)

Expand Down
6 changes: 3 additions & 3 deletions libimage/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ func toPlatformString(os, arch, variant string) string {

// Checks whether the image matches the specified platform.
// Returns
// * 1) a matching error that can be used for logging (or returning) what does not match
// * 2) a bool indicating whether architecture, os or variant were set (some callers need that to decide whether they need to throw an error)
// * 3) a fatal error that occurred prior to check for matches (e.g., storage errors etc.)
// - 1) a matching error that can be used for logging (or returning) what does not match
// - 2) a bool indicating whether architecture, os or variant were set (some callers need that to decide whether they need to throw an error)
// - 3) a fatal error that occurred prior to check for matches (e.g., storage errors etc.)
func (i *Image) matchesPlatform(ctx context.Context, os, arch, variant string) (error, bool, error) {
if err := i.isCorrupted(""); err != nil {
return err, false, nil
Expand Down
5 changes: 2 additions & 3 deletions libimage/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package libimage

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

Expand All @@ -24,7 +23,7 @@ func TestPush(t *testing.T) {
pushOptions := &PushOptions{}
pushOptions.Writer = os.Stdout

workdir, err := ioutil.TempDir("", "libimagepush")
workdir, err := os.MkdirTemp("", "libimagepush")
require.NoError(t, err)
defer os.RemoveAll(workdir)

Expand Down Expand Up @@ -86,7 +85,7 @@ func TestPushOtherPlatform(t *testing.T) {

pushOptions := &PushOptions{}
pushOptions.Writer = os.Stdout
tmp, err := ioutil.TempFile("", "")
tmp, err := os.CreateTemp("", "")
require.NoError(t, err)
tmp.Close()
defer os.Remove(tmp.Name())
Expand Down
3 changes: 1 addition & 2 deletions libimage/runtime_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package libimage

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

Expand All @@ -27,7 +26,7 @@ type testNewRuntimeOptions struct {
// is a clean-up function that should be called by users to make sure all
// temporary test data gets removed.
func testNewRuntime(t *testing.T, options ...testNewRuntimeOptions) (runtime *Runtime, cleanup func()) {
workdir, err := ioutil.TempDir("", "testStorageRuntime")
workdir, err := os.MkdirTemp("", "testStorageRuntime")
require.NoError(t, err)
storeOptions := &storage.StoreOptions{
RunRoot: workdir,
Expand Down
5 changes: 2 additions & 3 deletions libimage/save_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package libimage

import (
"context"
"io/ioutil"
"os"
"strings"
"testing"
Expand All @@ -28,7 +27,7 @@ func TestSave(t *testing.T) {
// reload the images for each test.
saveOptions := &SaveOptions{}
saveOptions.Writer = os.Stdout
imageCache, err := ioutil.TempFile("", "saveimagecache")
imageCache, err := os.CreateTemp("", "saveimagecache")
require.NoError(t, err)
imageCache.Close()
defer os.Remove(imageCache.Name())
Expand Down Expand Up @@ -72,7 +71,7 @@ func TestSave(t *testing.T) {
_, err = runtime.Load(ctx, imageCache.Name(), loadOptions)
require.NoError(t, err)

tmp, err := ioutil.TempDir("", "libimagesavetest")
tmp, err := os.MkdirTemp("", "libimagesavetest")
require.NoError(t, err)
defer os.RemoveAll(tmp)
if !test.isDir {
Expand Down
3 changes: 1 addition & 2 deletions libnetwork/cni/cni_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net"
"os"
"path/filepath"
Expand Down Expand Up @@ -329,7 +328,7 @@ func (n *cniNetwork) createCNIConfigListFromNetwork(network *types.Network, writ
cniPathName := ""
if writeToDisk {
cniPathName = filepath.Join(n.cniConfigDir, network.Name+".conflist")
err = ioutil.WriteFile(cniPathName, b, 0o644)
err = os.WriteFile(cniPathName, b, 0o644)
if err != nil {
return nil, "", err
}
Expand Down
17 changes: 8 additions & 9 deletions libnetwork/cni/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package cni_test

import (
"bytes"
"io/ioutil"
"net"
"os"
"path/filepath"
Expand All @@ -28,7 +27,7 @@ var _ = Describe("Config", func() {

BeforeEach(func() {
var err error
cniConfDir, err = ioutil.TempDir("", "podman_cni_test")
cniConfDir, err = os.MkdirTemp("", "podman_cni_test")
if err != nil {
Fail("Failed to create tmpdir")
}
Expand Down Expand Up @@ -1202,17 +1201,17 @@ var _ = Describe("Config", func() {

BeforeEach(func() {
dir := "testfiles/valid"
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
Fail("Failed to read test directory")
}
for _, file := range files {
filename := file.Name()
data, err := ioutil.ReadFile(filepath.Join(dir, filename))
data, err := os.ReadFile(filepath.Join(dir, filename))
if err != nil {
Fail("Failed to copy test files")
}
err = ioutil.WriteFile(filepath.Join(cniConfDir, filename), data, 0o700)
err = os.WriteFile(filepath.Join(cniConfDir, filename), data, 0o700)
if err != nil {
Fail("Failed to copy test files")
}
Expand Down Expand Up @@ -1557,17 +1556,17 @@ var _ = Describe("Config", func() {
Context("network load invalid existing ones", func() {
BeforeEach(func() {
dir := "testfiles/invalid"
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
Fail("Failed to read test directory")
}
for _, file := range files {
filename := file.Name()
data, err := ioutil.ReadFile(filepath.Join(dir, filename))
data, err := os.ReadFile(filepath.Join(dir, filename))
if err != nil {
Fail("Failed to copy test files")
}
err = ioutil.WriteFile(filepath.Join(cniConfDir, filename), data, 0o700)
err = os.WriteFile(filepath.Join(cniConfDir, filename), data, 0o700)
if err != nil {
Fail("Failed to copy test files")
}
Expand Down Expand Up @@ -1598,7 +1597,7 @@ func grepNotFile(path, match string) {
}

func grepFile(not bool, path, match string) {
data, err := ioutil.ReadFile(path)
data, err := os.ReadFile(path)
ExpectWithOffset(1, err).To(BeNil())
matcher := ContainSubstring(match)
if not {
Expand Down
12 changes: 6 additions & 6 deletions libnetwork/cni/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package cni_test

import (
"bytes"
"io/ioutil"
"io"
"net"
"os"
"path/filepath"
Expand Down Expand Up @@ -78,7 +78,7 @@ var _ = Describe("run CNI", func() {
}

var err error
cniConfDir, err = ioutil.TempDir("", "podman_cni_test")
cniConfDir, err = os.MkdirTemp("", "podman_cni_test")
if err != nil {
Fail("Failed to create tmpdir")
}
Expand Down Expand Up @@ -919,17 +919,17 @@ var _ = Describe("run CNI", func() {
Context("network setup test with networks from disk", func() {
BeforeEach(func() {
dir := "testfiles/valid"
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
Fail("Failed to read test directory")
}
for _, file := range files {
filename := file.Name()
data, err := ioutil.ReadFile(filepath.Join(dir, filename))
data, err := os.ReadFile(filepath.Join(dir, filename))
if err != nil {
Fail("Failed to copy test files")
}
err = ioutil.WriteFile(filepath.Join(cniConfDir, filename), data, 0o700)
err = os.WriteFile(filepath.Join(cniConfDir, filename), data, 0o700)
if err != nil {
Fail("Failed to copy test files")
}
Expand Down Expand Up @@ -1384,7 +1384,7 @@ func runNetListener(wg *sync.WaitGroup, protocol, ip string, port int, expectedD
Expect(err).To(BeNil())
err = conn.SetDeadline(time.Now().Add(1 * time.Second))
Expect(err).To(BeNil())
data, err := ioutil.ReadAll(conn)
data, err := io.ReadAll(conn)
Expect(err).To(BeNil())
Expect(string(data)).To(Equal(expectedData))
conn.Close()
Expand Down
Loading

0 comments on commit 98295c0

Please sign in to comment.