Skip to content

Commit 20c52d2

Browse files
thaJeztahBest2Two
authored andcommitted
internal/registryclient: simplify notFoundError
- remove constructor - fix mixed pointer/non-pointer receivers - just embed the error we want to produce Signed-off-by: Sebastiaan van Stijn <[email protected]> vendor: moby/api v1.53.0-rc.2, moby/client v0.2.2-rc.2 Signed-off-by: Sebastiaan van Stijn <[email protected]> Return error when service update triggers rollback When a service update fails and triggers a rollback, the command now exits with code 1 instead of 0, allowing deployment tools to detect failures. Fixes #6752 Signed-off-by: = <[email protected]>
1 parent ec02b95 commit 20c52d2

File tree

21 files changed

+209
-37
lines changed

21 files changed

+209
-37
lines changed

cli/command/service/progress/progress.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ func ServiceProgress(ctx context.Context, apiClient client.APIClient, serviceID
138138
if message != nil {
139139
_ = progressOut.WriteProgress(*message)
140140
}
141+
// Return error with non-zero exit if update was rolled back
142+
if rollback {
143+
return fmt.Errorf("update rolled back: %s", res.Service.UpdateStatus.Message)
144+
}
141145
return nil
142146
}
143147

internal/registryclient/fetcher.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func (c *client) iterateEndpoints(ctx context.Context, namedRef reference.Named,
271271
return nil
272272
}
273273
}
274-
return newNotFoundError(namedRef.String())
274+
return notFoundError{errors.New("no such manifest: " + namedRef.String())}
275275
}
276276

277277
// allEndpoints returns a list of endpoints ordered by priority (v2, http).
@@ -290,17 +290,6 @@ func allEndpoints(ctx context.Context, namedRef reference.Named, insecure bool)
290290
return endpoints, err
291291
}
292292

293-
func newNotFoundError(ref string) *notFoundError {
294-
return &notFoundError{err: errors.New("no such manifest: " + ref)}
295-
}
296-
297-
type notFoundError struct {
298-
err error
299-
}
300-
301-
func (n *notFoundError) Error() string {
302-
return n.err.Error()
303-
}
293+
type notFoundError struct{ error }
304294

305-
// NotFound satisfies interface github.com/docker/docker/errdefs.ErrNotFound
306295
func (notFoundError) NotFound() {}

vendor.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ require (
2828
github.com/google/uuid v1.6.0
2929
github.com/mattn/go-runewidth v0.0.19
3030
github.com/moby/go-archive v0.2.0
31-
github.com/moby/moby/api v1.53.0-rc.1
32-
github.com/moby/moby/client v0.2.2-rc.1
31+
github.com/moby/moby/api v1.53.0-rc.2
32+
github.com/moby/moby/client v0.2.2-rc.2
3333
github.com/moby/patternmatcher v0.6.0
3434
github.com/moby/swarmkit/v2 v2.1.1
3535
github.com/moby/sys/atomicwriter v0.1.0

vendor.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3N
113113
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
114114
github.com/moby/go-archive v0.2.0 h1:zg5QDUM2mi0JIM9fdQZWC7U8+2ZfixfTYoHL7rWUcP8=
115115
github.com/moby/go-archive v0.2.0/go.mod h1:mNeivT14o8xU+5q1YnNrkQVpK+dnNe/K6fHqnTg4qPU=
116-
github.com/moby/moby/api v1.53.0-rc.1 h1:M5SUwRbTrNy+plCTiV6gn4ZiN/Csynk0imIsUmOgHGI=
117-
github.com/moby/moby/api v1.53.0-rc.1/go.mod h1:8mb+ReTlisw4pS6BRzCMts5M49W5M7bKt1cJy/YbAqc=
118-
github.com/moby/moby/client v0.2.2-rc.1 h1:Ah2bPvdR3ZzHK+AvZeyLMyHHfEHifYlAyuWY33dLIno=
119-
github.com/moby/moby/client v0.2.2-rc.1/go.mod h1:tbJAygdiC6iCbKkVez27Jjm9y8vdvs8y9mizjiQrNRI=
116+
github.com/moby/moby/api v1.53.0-rc.2 h1:Ajc2MnWJRC2AAqhIGNaqvwaA2mMYKyuso5PjxPP2KM4=
117+
github.com/moby/moby/api v1.53.0-rc.2/go.mod h1:8mb+ReTlisw4pS6BRzCMts5M49W5M7bKt1cJy/YbAqc=
118+
github.com/moby/moby/client v0.2.2-rc.2 h1:j8cmCofnlLCimDzFUYsrrACJZWsRiq0ZqGrbbVX2fFs=
119+
github.com/moby/moby/client v0.2.2-rc.2/go.mod h1:LxIGylF1oOCPvokq90dMSUy44ODFFLkt2vRgDE1RKck=
120120
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
121121
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
122122
github.com/moby/swarmkit/v2 v2.1.1 h1:yvTJ8MMCc3f0qTA44J6R59EZ5yZawdYopkpuLk4+ICU=

vendor/github.com/moby/moby/api/types/image/build_identity.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/moby/api/types/image/identity.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/moby/api/types/image/image_inspect.go

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/moby/api/types/image/pull_identity.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/moby/api/types/image/signature_identity.go

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/moby/api/types/image/signature_timestamp.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)