Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump dependencies and fix some lint #499

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: "1.21"
- run: make format
- name: Indicate formatting issues
run: git diff HEAD --exit-code --color
2 changes: 1 addition & 1 deletion .github/workflows/licenses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.18"
go-version: "1.21"
- uses: actions/setup-node@v3.6.0
with:
node-version: "18"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.17"
go-version: "1.21"
- run: make test
- name: WriteGoList
run: go list -json -deps ./... > go.list
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ licenses: .bin/licenses node_modules # checks open-source licenses
curl https://raw.githubusercontent.com/ory/ci/master/licenses/install | sh

.bin/ory: Makefile
curl https://raw.githubusercontent.com/ory/meta/master/install.sh | bash -s -- -b .bin ory v0.1.48
curl https://raw.githubusercontent.com/ory/meta/master/install.sh | bash -s -- -b .bin ory v0.3.2
touch .bin/ory

node_modules: package-lock.json
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ jobs:
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: "1.18"
go-version: "1.21"

- name: Test with Docker
run: go test -v ./...
Expand Down
2 changes: 1 addition & 1 deletion docker/README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ See the documentation for more details.

All development commands can be seen in the [Makefile](Makefile).

Commited code must pass:
Committed code must pass:

- [golint](https://github.com/golang/lint) (with some exceptions, see the
Makefile).
Expand Down
3 changes: 1 addition & 2 deletions docker/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"strings"
Expand Down Expand Up @@ -180,7 +179,7 @@ func (c *Client) AuthCheck(conf *AuthConfiguration) (AuthStatus, error) {
return authStatus, err
}
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
data, err := io.ReadAll(resp.Body)
if err != nil {
return authStatus, err
}
Expand Down
26 changes: 9 additions & 17 deletions docker/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/http/httputil"
Expand Down Expand Up @@ -247,19 +246,19 @@ func NewVersionedTLSClient(endpoint string, cert, key, ca, apiVersionString stri
var keyPEMBlock []byte
var caPEMCert []byte
if _, err := os.Stat(cert); !os.IsNotExist(err) {
certPEMBlock, err = ioutil.ReadFile(cert)
certPEMBlock, err = os.ReadFile(cert)
if err != nil {
return nil, err
}
}
if _, err := os.Stat(key); !os.IsNotExist(err) {
keyPEMBlock, err = ioutil.ReadFile(key)
keyPEMBlock, err = os.ReadFile(key)
if err != nil {
return nil, err
}
}
if _, err := os.Stat(ca); !os.IsNotExist(err) {
caPEMCert, err = ioutil.ReadFile(ca)
caPEMCert, err = os.ReadFile(ca)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -399,7 +398,7 @@ func (c *Client) Endpoint() string {
//
// See https://goo.gl/wYfgY1 for more details.
func (c *Client) Ping() error {
return c.PingWithContext(nil)
return c.PingWithContext(context.Background())
}

// PingWithContext pings the docker server
Expand Down Expand Up @@ -555,10 +554,10 @@ func (c *Client) stream(method, path string, streamOptions streamOptions) error
protocol := c.endpointURL.Scheme
address := c.endpointURL.Path
if streamOptions.stdout == nil {
streamOptions.stdout = ioutil.Discard
streamOptions.stdout = io.Discard
}
if streamOptions.stderr == nil {
streamOptions.stderr = ioutil.Discard
streamOptions.stderr = io.Discard
}

// make a sub-context so that our active cancellation does not affect parent
Expand Down Expand Up @@ -792,10 +791,10 @@ func (c *Client) hijack(method, path string, hijackOptions hijackOptions) (Close
// will "hang" until the container terminates, even though you're not reading
// stdout/stderr
if hijackOptions.stdout == nil {
hijackOptions.stdout = ioutil.Discard
hijackOptions.stdout = io.Discard
}
if hijackOptions.stderr == nil {
hijackOptions.stderr = ioutil.Discard
hijackOptions.stderr = io.Discard
}

go func() {
Expand Down Expand Up @@ -884,13 +883,6 @@ func (c *Client) getFakeNativeURL(path string) string {
return fmt.Sprintf("%s%s", urlStr, path)
}

type jsonMessage struct {
Status string `json:"status,omitempty"`
Progress string `json:"progress,omitempty"`
Error string `json:"error,omitempty"`
Stream string `json:"stream,omitempty"`
}

func queryString(opts interface{}) string {
if opts == nil {
return ""
Expand Down Expand Up @@ -974,7 +966,7 @@ func newError(resp *http.Response) *Error {
Message string `json:"message"`
}
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
data, err := io.ReadAll(resp.Body)
if err != nil {
return &Error{Status: resp.StatusCode, Message: fmt.Sprintf("cannot read body, err: %v", err)}
}
Expand Down
3 changes: 0 additions & 3 deletions docker/client_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ func (c *Client) initializeNativeClient(trFunc func() *http.Transport) {

tr := trFunc()

tr.Dial = func(network, addr string) (net.Conn, error) {
return c.Dialer.Dial(unixProtocol, sockPath)
}
tr.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
return c.Dialer.Dial(unixProtocol, sockPath)
}
Expand Down
3 changes: 1 addition & 2 deletions docker/pkg/archive/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -1236,7 +1235,7 @@ func cmdStream(cmd *exec.Cmd, input io.Reader) (io.ReadCloser, error) {
// of that file as an archive. The archive can only be read once - as soon as reading completes,
// the file will be deleted.
func NewTempArchive(src io.Reader, dir string) (*TempArchive, error) {
f, err := ioutil.TempFile(dir, "")
f, err := os.CreateTemp(dir, "")
if err != nil {
return nil, err
}
Expand Down
7 changes: 3 additions & 4 deletions docker/pkg/archive/changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -347,12 +346,12 @@ func ChangesDirs(newDir, oldDir string) ([]Change, error) {
oldRoot, newRoot *FileInfo
)
if oldDir == "" {
emptyDir, err := ioutil.TempDir("", "empty")
emptyDir, err := os.CreateTemp("", "empty")
if err != nil {
return nil, err
}
defer os.Remove(emptyDir)
oldDir = emptyDir
defer os.Remove(emptyDir.Name())
oldDir = emptyDir.Name()
}
oldRoot, newRoot, err := collectFileInfoForChanges(oldDir, newDir)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions docker/pkg/archive/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"archive/tar"
"errors"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -264,7 +263,7 @@ func PrepareArchiveCopy(srcContent io.Reader, srcInfo, dstInfo CopyInfo) (dstDir
// The destination exists as a directory. No alteration
// to srcContent is needed as its contents can be
// simply extracted to the destination directory.
return dstInfo.Path, ioutil.NopCloser(srcContent), nil
return dstInfo.Path, io.NopCloser(srcContent), nil
case dstInfo.Exists && srcInfo.IsDir:
// The destination exists as some type of file and the source
// content is a directory. This is an error condition since
Expand Down
3 changes: 1 addition & 2 deletions docker/pkg/archive/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"archive/tar"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -103,7 +102,7 @@ func UnpackLayer(dest string, layer io.Reader, options *TarOptions) (size int64,
basename := filepath.Base(hdr.Name)
aufsHardlinks[basename] = hdr
if aufsTempdir == "" {
if aufsTempdir, err = ioutil.TempDir("", "dockerplnk"); err != nil {
if aufsTempdir, err = os.MkdirTemp("", "dockerplnk"); err != nil {
return 0, err
}
defer os.RemoveAll(aufsTempdir)
Expand Down
7 changes: 3 additions & 4 deletions docker/pkg/archive/example_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"path"

Expand Down Expand Up @@ -43,7 +42,7 @@ func main() {

if len(*flNewDir) == 0 {
var err error
newDir, err = ioutil.TempDir("", "docker-test-newDir")
newDir, err = os.MkdirTemp("", "docker-test-newDir")
if err != nil {
log.Fatal(err)
}
Expand All @@ -56,7 +55,7 @@ func main() {
}

if len(*flOldDir) == 0 {
oldDir, err := ioutil.TempDir("", "docker-test-oldDir")
oldDir, err := os.MkdirTemp("", "docker-test-oldDir")
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -87,7 +86,7 @@ func prepareUntarSourceDirectory(numberOfFiles int, targetPath string, makeLinks
fileData := []byte("fooo")
for n := 0; n < numberOfFiles; n++ {
fileName := fmt.Sprintf("file-%d", n)
if err := ioutil.WriteFile(path.Join(targetPath, fileName), fileData, 0700); err != nil {
if err := os.WriteFile(path.Join(targetPath, fileName), fileData, 0700); err != nil {
return 0, err
}
if makeLinks {
Expand Down
3 changes: 1 addition & 2 deletions docker/pkg/fileutils/fileutils_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package fileutils // import "github.com/ory/dockertest/v3/docker/pkg/fileutils"

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

"github.com/sirupsen/logrus"
Expand All @@ -17,7 +16,7 @@ import (
// GetTotalUsedFds Returns the number of used File Descriptors by
// reading it via /proc filesystem.
func GetTotalUsedFds() int {
if fds, err := ioutil.ReadDir(fmt.Sprintf("/proc/%d/fd", os.Getpid())); err != nil {
if fds, err := os.ReadDir(fmt.Sprintf("/proc/%d/fd", os.Getpid())); err != nil {
logrus.Errorf("Error opening /proc/%d/fd: %s", os.Getpid(), err)
} else {
return len(fds)
Expand Down
5 changes: 2 additions & 3 deletions docker/pkg/ioutils/fswriters.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package ioutils // import "github.com/ory/dockertest/v3/docker/pkg/ioutils"

import (
"io"
"io/ioutil"
"os"
"path/filepath"
)
Expand All @@ -14,7 +13,7 @@ import (
// temporary file and closing it atomically changes the temporary file to
// destination path. Writing and closing concurrently is not allowed.
func NewAtomicFileWriter(filename string, perm os.FileMode) (io.WriteCloser, error) {
f, err := ioutil.TempFile(filepath.Dir(filename), ".tmp-"+filepath.Base(filename))
f, err := os.CreateTemp(filepath.Dir(filename), ".tmp-"+filepath.Base(filename))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -97,7 +96,7 @@ type AtomicWriteSet struct {
// commit. If no temporary directory is given the system
// default is used.
func NewAtomicWriteSet(tmpDir string) (*AtomicWriteSet, error) {
td, err := ioutil.TempDir(tmpDir, "write-set-")
td, err := os.MkdirTemp(tmpDir, "write-set-")
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions docker/pkg/ioutils/temp_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

package ioutils // import "github.com/ory/dockertest/v3/docker/pkg/ioutils"

import "io/ioutil"
import "os"

// TempDir on Unix systems is equivalent to ioutil.TempDir.
func TempDir(dir, prefix string) (string, error) {
return ioutil.TempDir(dir, prefix)
return os.MkdirTemp(dir, prefix)
}
2 changes: 1 addition & 1 deletion docker/pkg/jsonmessage/jsonmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (jm *JSONMessage) Display(out io.Writer, termInfo termInfo) error {
if termInfo != nil && jm.Stream == "" && jm.Progress != nil {
clearLine(out, termInfo)
endl = "\r"
fmt.Fprintf(out, endl)
fmt.Fprint(out, endl)
} else if jm.Progress != nil && jm.Progress.String() != "" { //disable progressbar in non-terminal
return nil
}
Expand Down
3 changes: 1 addition & 2 deletions docker/pkg/system/filesys.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package system // import "github.com/ory/dockertest/v3/docker/pkg/system"

import (
"io/ioutil"
"os"
"path/filepath"
)
Expand Down Expand Up @@ -67,5 +66,5 @@ func OpenFileSequential(name string, flag int, perm os.FileMode) (*os.File, erro
// to find the pathname of the file. It is the caller's responsibility
// to remove the file when no longer needed.
func TempFileSequential(dir, prefix string) (f *os.File, err error) {
return ioutil.TempFile(dir, prefix)
return os.CreateTemp(dir, prefix)
}
Loading
Loading