Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Issue 1129043003: cipd: Refactor client to make it more readable. (Closed)

Created:
5 years, 7 months ago by Vadim Sh.
Modified:
5 years, 7 months ago
Reviewers:
nodir
CC:
chromium-reviews
Base URL:
https://chromium.googlesource.com/infra/infra.git@master
Target Ref:
refs/heads/master
Project:
infra
Visibility:
Public.

Description

cipd: Refactor client to make it more readable. Changes are: * Move functions that operate with files on disk to cipd/local subpackage. * Move small set of functions used by both cipd/local and cipd packages to cipd/common subpackage. * Introduce Client class that provides high level methods to work with packages (fetching, uploading, installing, etc). It replaces standalone functions that used to take a lot of arguments each. Now most of arguments are kept as Client state. As a consequence get rid of <opertaion>Options structs where makes sense. * Introduce Pin{} struct: a pair (package name, instance ID). It replaces several existing structs (PackageState, PackageInfo) and consistently used everywhere where package name & instance ID are used together. It was named "Pin" because: a) short word; b) doesn't collide with existing notions (such as ref or instance ID); c) implies concrete fixed version. * Extract Google Storage interaction in 'storageImpl' class. * Get rid of global vars mocked in tests (e.g. "clock" global var). Explicitly keep them in Client. Tests do not touch global environment now. * Consistently use single mockClient(...) method to mock HTTP calls (call expectations style). Also use Convey context object ("c C") to be able to properly raise assertions from non-main goroutines. * Always create http.Client lazily. Always use anonymous http.Client when talking to Google Storage (we use signed URLs, no need for authentication). No changes to functionality. R=nodir@chromium.org BUG= Committed: https://chromium.googlesource.com/infra/infra/+/0f5582b1836e7ef9348fa1e01cbfd6cc61836af5

Patch Set 1 #

Patch Set 2 : call AttachTagsWhenReady explicitly #

Patch Set 3 : be more careful with network error handling #

Total comments: 51

Patch Set 4 : #

Total comments: 19

Patch Set 5 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+2348 lines, -5869 lines) Patch
D go/src/infra/tools/cipd/acl.go View 1 chunk +0 lines, -106 lines 0 comments Download
M go/src/infra/tools/cipd/apps/cipd/main.go View 1 2 3 4 26 chunks +77 lines, -100 lines 0 comments Download
D go/src/infra/tools/cipd/builder.go View 1 chunk +0 lines, -174 lines 0 comments Download
D go/src/infra/tools/cipd/builder_test.go View 1 chunk +0 lines, -232 lines 0 comments Download
A go/src/infra/tools/cipd/client.go View 1 2 3 1 chunk +629 lines, -0 lines 0 comments Download
A go/src/infra/tools/cipd/client_test.go View 1 1 chunk +594 lines, -0 lines 0 comments Download
D go/src/infra/tools/cipd/clock.go View 1 chunk +0 lines, -20 lines 0 comments Download
D go/src/infra/tools/cipd/clock_test.go View 1 chunk +0 lines, -26 lines 0 comments Download
D go/src/infra/tools/cipd/common.go View 1 chunk +0 lines, -118 lines 0 comments Download
A + go/src/infra/tools/cipd/common/common.go View 4 chunks +23 lines, -61 lines 0 comments Download
A + go/src/infra/tools/cipd/common/common.infra_testing View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
A + go/src/infra/tools/cipd/common/common_test.go View 2 chunks +19 lines, -34 lines 0 comments Download
D go/src/infra/tools/cipd/common_test.go View 1 chunk +0 lines, -87 lines 0 comments Download
D go/src/infra/tools/cipd/deployer.go View 1 chunk +0 lines, -471 lines 0 comments Download
D go/src/infra/tools/cipd/deployer_test.go View 1 chunk +0 lines, -469 lines 0 comments Download
D go/src/infra/tools/cipd/doc.go View 1 chunk +0 lines, -40 lines 0 comments Download
D go/src/infra/tools/cipd/ensure.go View 1 chunk +0 lines, -231 lines 0 comments Download
D go/src/infra/tools/cipd/ensure_test.go View 1 chunk +0 lines, -193 lines 0 comments Download
D go/src/infra/tools/cipd/fetcher.go View 1 chunk +0 lines, -217 lines 0 comments Download
D go/src/infra/tools/cipd/fetcher_test.go View 1 chunk +0 lines, -160 lines 0 comments Download
D go/src/infra/tools/cipd/files.go View 1 chunk +0 lines, -415 lines 0 comments Download
D go/src/infra/tools/cipd/files_test.go View 1 chunk +0 lines, -474 lines 0 comments Download
A + go/src/infra/tools/cipd/local/builder.go View 5 chunks +12 lines, -4 lines 0 comments Download
A + go/src/infra/tools/cipd/local/builder_test.go View 5 chunks +8 lines, -54 lines 0 comments Download
A + go/src/infra/tools/cipd/local/deployer.go View 1 2 3 4 14 chunks +66 lines, -75 lines 0 comments Download
A + go/src/infra/tools/cipd/local/deployer_test.go View 11 chunks +42 lines, -56 lines 0 comments Download
A + go/src/infra/tools/cipd/local/files.go View 1 chunk +1 line, -1 line 0 comments Download
A + go/src/infra/tools/cipd/local/files_test.go View 1 chunk +1 line, -1 line 0 comments Download
A + go/src/infra/tools/cipd/local/local.infra_testing View 1 chunk +1 line, -1 line 0 comments Download
A go/src/infra/tools/cipd/local/manifest.go View 1 2 3 4 1 chunk +48 lines, -0 lines 0 comments Download
A go/src/infra/tools/cipd/local/manifest_test.go View 1 chunk +45 lines, -0 lines 0 comments Download
A + go/src/infra/tools/cipd/local/pkgdef.go View 5 chunks +6 lines, -4 lines 0 comments Download
A + go/src/infra/tools/cipd/local/pkgdef_test.go View 1 chunk +1 line, -1 line 0 comments Download
A + go/src/infra/tools/cipd/local/reader.go View 3 chunks +12 lines, -7 lines 0 comments Download
A + go/src/infra/tools/cipd/local/reader_test.go View 4 chunks +8 lines, -7 lines 0 comments Download
A go/src/infra/tools/cipd/local/testing.go View 1 chunk +58 lines, -0 lines 0 comments Download
D go/src/infra/tools/cipd/pkgdef.go View 1 chunk +0 lines, -261 lines 0 comments Download
D go/src/infra/tools/cipd/pkgdef_test.go View 1 chunk +0 lines, -260 lines 0 comments Download
D go/src/infra/tools/cipd/reader.go View 1 chunk +0 lines, -269 lines 0 comments Download
D go/src/infra/tools/cipd/reader_test.go View 1 chunk +0 lines, -193 lines 0 comments Download
M go/src/infra/tools/cipd/remote.go View 1 2 3 4 16 chunks +95 lines, -126 lines 0 comments Download
M go/src/infra/tools/cipd/remote_test.go View 13 chunks +210 lines, -282 lines 0 comments Download
A go/src/infra/tools/cipd/storage.go View 1 2 3 4 1 chunk +278 lines, -0 lines 0 comments Download
A go/src/infra/tools/cipd/storage_test.go View 1 chunk +113 lines, -0 lines 0 comments Download
D go/src/infra/tools/cipd/uploader.go View 1 chunk +0 lines, -362 lines 0 comments Download
D go/src/infra/tools/cipd/uploader_test.go View 1 chunk +0 lines, -276 lines 0 comments Download

Messages

Total messages: 13 (2 generated)
Vadim Sh.
Brace yourself, "34 files changed, 2264 insertions(+), 2432 deletions(-)" is coming :( Once I've realized ...
5 years, 7 months ago (2015-05-09 21:38:30 UTC) #1
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1129043003/20001
5 years, 7 months ago (2015-05-09 21:59:44 UTC) #3
nodir
reviewed client.go https://codereview.chromium.org/1129043003/diff/40001/go/src/infra/tools/cipd/client.go File go/src/infra/tools/cipd/client.go (right): https://codereview.chromium.org/1129043003/diff/40001/go/src/infra/tools/cipd/client.go#newcode99 go/src/infra/tools/cipd/client.go:99: ErrBackendInaccessible = errors.New("Request to the backend failed ...
5 years, 7 months ago (2015-05-12 19:09:21 UTC) #4
Vadim Sh.
https://codereview.chromium.org/1129043003/diff/40001/go/src/infra/tools/cipd/client.go File go/src/infra/tools/cipd/client.go (right): https://codereview.chromium.org/1129043003/diff/40001/go/src/infra/tools/cipd/client.go#newcode99 go/src/infra/tools/cipd/client.go:99: ErrBackendInaccessible = errors.New("Request to the backend failed after multiple ...
5 years, 7 months ago (2015-05-12 23:25:04 UTC) #5
nodir
https://codereview.chromium.org/1129043003/diff/40001/go/src/infra/tools/cipd/client.go File go/src/infra/tools/cipd/client.go (right): https://codereview.chromium.org/1129043003/diff/40001/go/src/infra/tools/cipd/client.go#newcode125 go/src/infra/tools/cipd/client.go:125: // authClient is lazily created http.Client to use to ...
5 years, 7 months ago (2015-05-12 23:35:54 UTC) #6
Vadim Sh.
https://codereview.chromium.org/1129043003/diff/40001/go/src/infra/tools/cipd/client.go File go/src/infra/tools/cipd/client.go (right): https://codereview.chromium.org/1129043003/diff/40001/go/src/infra/tools/cipd/client.go#newcode138 go/src/infra/tools/cipd/client.go:138: Role string On 2015/05/12 23:35:53, nodir wrote: > On ...
5 years, 7 months ago (2015-05-12 23:48:46 UTC) #7
nodir
https://codereview.chromium.org/1129043003/diff/40001/go/src/infra/tools/cipd/client.go File go/src/infra/tools/cipd/client.go (right): https://codereview.chromium.org/1129043003/diff/40001/go/src/infra/tools/cipd/client.go#newcode138 go/src/infra/tools/cipd/client.go:138: Role string On 2015/05/12 23:48:45, Vadim Sh. wrote: > ...
5 years, 7 months ago (2015-05-13 01:25:29 UTC) #8
Vadim Sh.
https://codereview.chromium.org/1129043003/diff/40001/go/src/infra/tools/cipd/client.go File go/src/infra/tools/cipd/client.go (right): https://codereview.chromium.org/1129043003/diff/40001/go/src/infra/tools/cipd/client.go#newcode138 go/src/infra/tools/cipd/client.go:138: Role string On 2015/05/13 01:25:28, nodir wrote: > On ...
5 years, 7 months ago (2015-05-13 03:08:07 UTC) #9
nodir
lgtm https://codereview.chromium.org/1129043003/diff/60001/go/src/infra/tools/cipd/remote.go File go/src/infra/tools/cipd/remote.go (right): https://codereview.chromium.org/1129043003/diff/60001/go/src/infra/tools/cipd/remote.go#newcode56 go/src/infra/tools/cipd/remote.go:56: // etc. For now all errors that end ...
5 years, 7 months ago (2015-05-13 15:54:25 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1129043003/80001
5 years, 7 months ago (2015-05-13 21:58:39 UTC) #12
commit-bot: I haz the power
5 years, 7 months ago (2015-05-13 22:02:39 UTC) #13
Message was sent while issue was closed.
Committed patchset #5 (id:80001) as
https://chromium.googlesource.com/infra/infra/+/0f5582b1836e7ef9348fa1e01cbfd...

Powered by Google App Engine
This is Rietveld 408576698