-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testutil: copy slim version of the docker client into testutil
Copies a slim version of the docker client with only the necessary methods so we can break our dependency on the client in moby. This client is only used in an integration test so it's not really needed and we don't really actively need updates or to be on the most recent API version since we just do an unversioned ping and then call the hijack method. This was created by copying the package into `testutil` and then deleting unused sections of code. Signed-off-by: Jonathan A. Sternberg <[email protected]>
- Loading branch information
1 parent
3637d1b
commit 35d84a6
Showing
215 changed files
with
289 additions
and
26,094 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...b.com/docker/docker/client/client_unix.go → util/testutil/dockerd/client/client_unix.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...om/docker/docker/client/client_windows.go → ...testutil/dockerd/client/client_windows.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//nolint:forbidigo | ||
package client | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
// errConnectionFailed implements an error returned when connection failed. | ||
// | ||
//nolint:errname | ||
type errConnectionFailed struct { | ||
error | ||
} | ||
|
||
// Error returns a string representation of an errConnectionFailed | ||
func (e errConnectionFailed) Error() string { | ||
return e.error.Error() | ||
} | ||
|
||
func (e errConnectionFailed) Unwrap() error { | ||
return e.error | ||
} | ||
|
||
// IsErrConnectionFailed returns true if the error is caused by connection failed. | ||
func IsErrConnectionFailed(err error) bool { | ||
return errors.As(err, &errConnectionFailed{}) | ||
} | ||
|
||
// ErrorConnectionFailed returns an error with host in the error message when connection to docker daemon failed. | ||
func ErrorConnectionFailed(host string) error { | ||
var err error | ||
if host == "" { | ||
err = fmt.Errorf("Cannot connect to the Docker daemon. Is the docker daemon running on this host?") | ||
} else { | ||
err = fmt.Errorf("Cannot connect to the Docker daemon at %s. Is the docker daemon running?", host) | ||
} | ||
return errConnectionFailed{error: err} | ||
} |
Oops, something went wrong.