Skip to content

Commit

Permalink
Merge branch 'v3' into pme/defer
Browse files Browse the repository at this point in the history
  • Loading branch information
alnr authored Jun 13, 2024
2 parents b17b9d2 + 2ec2ae5 commit 4972d31
Show file tree
Hide file tree
Showing 32 changed files with 205 additions and 282 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/closed_references.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
name: Find closed references
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v2-beta
with:
node-version: "14"
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,10 +8,10 @@ jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- 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/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
4 changes: 2 additions & 2 deletions .github/workflows/licenses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- 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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- 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
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ checklist to contribute an example:
not get mixed up.
1. Add a descriptive prefix to commits. This ensures a uniform commit history
and helps structure the changelog. Please refer to this
[list of prefixes for Dockertest](https://github.com/ory/dockertest/blob/master/.github/semantic.yml)
for an overview.
[Convential Commits configuration](https://github.com/ory/dockertest/blob/master/.github/workflows/conventional_commits.yml)
for the list of accepted prefixes. You can read more about the Conventional Commit specification [at their site](https://www.conventionalcommits.org/en/v1.0.0/).
1. Create a `README.md` that explains how to use the example. (Use
[the README template](https://github.com/ory/examples/blob/master/_common/README)).
[the README template](https://github.com/ory/examples/blob/master/_common/README.md)).
1. Open a pull request and maintainers will review and merge your example.

## Contribute code
Expand All @@ -174,8 +174,8 @@ request, go through this checklist:
1. Run `make format`
1. Add a descriptive prefix to commits. This ensures a uniform commit history
and helps structure the changelog. Please refer to this
[list of prefixes for Dockertest](https://github.com/ory/dockertest/blob/master/.github/semantic.yml)
for an overview.
[Convential Commits configuration](https://github.com/ory/dockertest/blob/master/.github/workflows/conventional_commits.yml)
for the list of accepted prefixes. You can read more about the Conventional Commit specification [at their site](https://www.conventionalcommits.org/en/v1.0.0/).

If a pull request is not ready to be reviewed yet
[it should be marked as a "Draft"](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request).
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 @@ -229,9 +229,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
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 @@ -1237,7 +1236,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 @@ -348,12 +347,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 @@ -265,7 +264,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 @@ -104,7 +103,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 @@ -44,7 +43,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 @@ -57,7 +56,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 @@ -88,7 +87,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
Loading

0 comments on commit 4972d31

Please sign in to comment.