forked from docker-archive-public/docker.go-docker
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
Latest commit
213 lines (179 loc) · 5.56 KB
/
Copy patherrors.go
File metadata and controls
213 lines (179 loc) · 5.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
package docker // import "docker.io/go-docker"
import (
"fmt"
"net/http"
"docker.io/go-docker/api/types/versions"
"github.com/pkg/errors"
)
// errConnectionFailed implements an error returned when connection failed.
typeerrConnectionFailedstruct {
hoststring
}
// Error returns a string representation of an errConnectionFailed
func (errerrConnectionFailed) Error() string {
iferr.host=="" {
return"Cannot connect to the Docker daemon. Is the docker daemon running on this host?"
}
returnfmt.Sprintf("Cannot connect to the Docker daemon at %s. Is the docker daemon running?", err.host)
}
// IsErrConnectionFailed returns true if the error is caused by connection failed.
funcIsErrConnectionFailed(errerror) bool {
_, ok:=errors.Cause(err).(errConnectionFailed)
returnok
}
// ErrorConnectionFailed returns an error with host in the error message when connection to docker daemon failed.
funcErrorConnectionFailed(hoststring) error {
returnerrConnectionFailed{host: host}
}
typenotFoundinterface {
error
NotFound() bool// Is the error a NotFound error
}
// IsErrNotFound returns true if the error is a NotFound error, which is returned
// by the API when some object is not found.
funcIsErrNotFound(errerror) bool {
te, ok:=err.(notFound)
returnok&&te.NotFound()
}
typeobjectNotFoundErrorstruct {
objectstring
idstring
}
func (eobjectNotFoundError) NotFound() bool {
returntrue
}
func (eobjectNotFoundError) Error() string {
returnfmt.Sprintf("Error: No such %s: %s", e.object, e.id)
}
funcwrapResponseError(errerror, respserverResponse, object, idstring) error {
switch {
caseerr==nil:
returnnil
caseresp.statusCode==http.StatusNotFound:
returnobjectNotFoundError{object: object, id: id}
caseresp.statusCode==http.StatusNotImplemented:
returnnotImplementedError{message: err.Error()}
default:
returnerr
}
}
// IsErrImageNotFound returns true if the error is caused
// when an image is not found in the docker host.
//
// Deprecated: Use IsErrNotFound
funcIsErrImageNotFound(errerror) bool {
returnIsErrNotFound(err)
}
// IsErrContainerNotFound returns true if the error is caused
// when a container is not found in the docker host.
//
// Deprecated: Use IsErrNotFound
funcIsErrContainerNotFound(errerror) bool {
returnIsErrNotFound(err)
}
// IsErrNetworkNotFound returns true if the error is caused
// when a network is not found in the docker host.
//
// Deprecated: Use IsErrNotFound
funcIsErrNetworkNotFound(errerror) bool {
returnIsErrNotFound(err)
}
// IsErrVolumeNotFound returns true if the error is caused
// when a volume is not found in the docker host.
//
// Deprecated: Use IsErrNotFound
funcIsErrVolumeNotFound(errerror) bool {
returnIsErrNotFound(err)
}
// unauthorizedError represents an authorization error in a remote registry.
typeunauthorizedErrorstruct {
causeerror
}
// Error returns a string representation of an unauthorizedError
func (uunauthorizedError) Error() string {
returnu.cause.Error()
}
// IsErrUnauthorized returns true if the error is caused
// when a remote registry authentication fails
funcIsErrUnauthorized(errerror) bool {
_, ok:=err.(unauthorizedError)
returnok
}
// IsErrNodeNotFound returns true if the error is caused
// when a node is not found.
//
// Deprecated: Use IsErrNotFound
funcIsErrNodeNotFound(errerror) bool {
returnIsErrNotFound(err)
}
// IsErrServiceNotFound returns true if the error is caused
// when a service is not found.
//
// Deprecated: Use IsErrNotFound
funcIsErrServiceNotFound(errerror) bool {
returnIsErrNotFound(err)
}
// IsErrTaskNotFound returns true if the error is caused
// when a task is not found.
//
// Deprecated: Use IsErrNotFound
funcIsErrTaskNotFound(errerror) bool {
returnIsErrNotFound(err)
}
typepluginPermissionDeniedstruct {
namestring
}
func (epluginPermissionDenied) Error() string {
return"Permission denied while installing plugin "+e.name
}
// IsErrPluginPermissionDenied returns true if the error is caused
// when a user denies a plugin's permissions
funcIsErrPluginPermissionDenied(errerror) bool {
_, ok:=err.(pluginPermissionDenied)
returnok
}
typenotImplementedErrorstruct {
messagestring
}
func (enotImplementedError) Error() string {
returne.message
}
func (enotImplementedError) NotImplemented() bool {
returntrue
}
// IsErrNotImplemented returns true if the error is a NotImplemented error.
// This is returned by the API when a requested feature has not been
// implemented.
funcIsErrNotImplemented(errerror) bool {
te, ok:=err.(notImplementedError)
returnok&&te.NotImplemented()
}
// NewVersionError returns an error if the APIVersion required
// if less than the current supported version
func (cli*Client) NewVersionError(APIrequired, featurestring) error {
ifcli.version!=""&&versions.LessThan(cli.version, APIrequired) {
returnfmt.Errorf("%q requires API version %s, but the Docker daemon API version is %s", feature, APIrequired, cli.version)
}
returnnil
}
// IsErrSecretNotFound returns true if the error is caused
// when a secret is not found.
//
// Deprecated: Use IsErrNotFound
funcIsErrSecretNotFound(errerror) bool {
returnIsErrNotFound(err)
}
// IsErrConfigNotFound returns true if the error is caused
// when a config is not found.
//
// Deprecated: Use IsErrNotFound
funcIsErrConfigNotFound(errerror) bool {
returnIsErrNotFound(err)
}
// IsErrPluginNotFound returns true if the error is caused
// when a plugin is not found in the docker host.
//
// Deprecated: Use IsErrNotFound
funcIsErrPluginNotFound(errerror) bool {
returnIsErrNotFound(err)
}