Skip to content

Commit

Permalink
chore: fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Demonsthere committed Jul 4, 2024
2 parents 2ab81bd + 1b46b29 commit bf711a5
Show file tree
Hide file tree
Showing 39 changed files with 279 additions and 297 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/closed_references.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
runs-on: ubuntu-latest
name: Find closed references
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.0.2
with:
node-version: "14"
- uses: ory/closed-reference-notifier@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/conventional_commits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- id: config
uses: ory/ci/conventional_commit_config@master
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22
- run: make format
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Synchronize Issue Labels
uses: ory/label-sync-action@v0
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/licenses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.18"
- uses: actions/setup-node@v3.6.0
go-version: "1.21"
- uses: actions/setup-node@v4.0.2
with:
node-version: "18"
- run: make licenses
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
if: github.repository_owner == 'ory'
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v4
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- run: make test
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
23 changes: 9 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ To install dockertest, run
go get -u github.com/ory/dockertest/v3
```

or

```
dep ensure -add github.com/ory/dockertest@v3.x.y
```

### Using Dockertest

```go
Expand Down Expand Up @@ -100,14 +94,15 @@ func TestMain(m *testing.M) {
log.Fatalf("Could not connect to database: %s", err)
}

code := m.Run()
// as of go1.15 testing.M returns the exit code of m.Run(), so it is safe to use defer here
defer func() {
if err := pool.Purge(resource); err != nil {
log.Fatalf("Could not purge resource: %s", err)
}

// You can't defer this because os.Exit doesn't care for defer
if err := pool.Purge(resource); err != nil {
log.Fatalf("Could not purge resource: %s", err)
}
}()

os.Exit(code)
m.Run()
}

func TestSomething(t *testing.T) {
Expand Down Expand Up @@ -228,9 +223,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
11 changes: 1 addition & 10 deletions 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 All @@ -111,15 +111,6 @@ Running `make test` will check all of these. If your editor does not
automatically call `gofmt -s`, `make fmt` will format all go files in this
repository.

## Vendoring

go-dockerclient uses [dep](https://github.com/golang/dep/) for vendoring. If
you're using dep, you should be able to pick go-dockerclient releases and get
the proper dependencies.

With other vendoring tools, users might need to specify go-dockerclient's
dependencies manually.

## Using with Docker 1.9 and Go 1.4

There's a tag for using go-dockerclient with Docker 1.9 (which requires
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
26 changes: 24 additions & 2 deletions docker/opts/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ import (
"fmt"
"net"
"net/url"
"os"
"strconv"
"strings"
)

const (
dockerSocket = "/var/run/docker.sock"
podmanSocket = "/podman/podman.sock"
)

var (
// DefaultHTTPPort Default HTTP Port used if only the protocol is provided to -H flag e.g. dockerd -H tcp://
// These are the IANA registered port numbers for use with Docker
Expand All @@ -19,8 +25,7 @@ var (
// DefaultTLSHTTPPort Default HTTP Port used when TLS enabled
DefaultTLSHTTPPort = 2376 // Default TLS encrypted HTTP Port
// DefaultUnixSocket Path for the unix socket.
// Docker daemon by default always listens on the default unix socket
DefaultUnixSocket = "/var/run/docker.sock"
DefaultUnixSocket = getDefaultSocket()
// DefaultTCPHost constant defines the default host string used by docker on Windows
DefaultTCPHost = fmt.Sprintf("tcp://%s:%d", DefaultHTTPHost, DefaultHTTPPort)
// DefaultTLSHost constant defines the default host string used by docker for TLS sockets
Expand Down Expand Up @@ -166,3 +171,20 @@ func ValidateExtraHost(val string) (string, error) {
}
return val, nil
}

func getDefaultSocket() string {
_, err := os.Stat(dockerSocket)
if err == nil {
return dockerSocket
}
// see https://docs.podman.io/en/latest/markdown/podman-system-service.1.html#description
locations := []string{os.Getenv("XDG_RUNTIME_DIR"), "/run"} // rootless, rootful
for _, location := range locations {
_, err = os.Stat(location + podmanSocket)
if err == nil {
return location + podmanSocket
}
}

return dockerSocket
}
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
Loading

0 comments on commit bf711a5

Please sign in to comment.