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

Unified Diff: go/src/infra/tools/cipd/local/builder.go

Issue 1129043003: cipd: Refactor client to make it more readable. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « go/src/infra/tools/cipd/files_test.go ('k') | go/src/infra/tools/cipd/local/builder_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/tools/cipd/local/builder.go
diff --git a/go/src/infra/tools/cipd/builder.go b/go/src/infra/tools/cipd/local/builder.go
similarity index 92%
rename from go/src/infra/tools/cipd/builder.go
rename to go/src/infra/tools/cipd/local/builder.go
index f2ce0f0d07c9a95fcd9e29183416736d0381c3ee..186eab5937f92d40aebedaadd3957f416856ad27 100644
--- a/go/src/infra/tools/cipd/builder.go
+++ b/go/src/infra/tools/cipd/local/builder.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package cipd
+package local
import (
"archive/zip"
@@ -13,6 +13,9 @@ import (
"os"
"strings"
"time"
+
+ "infra/libs/logging"
+ "infra/tools/cipd/common"
)
// BuildInstanceOptions defines options for BuildInstance function.
@@ -23,6 +26,8 @@ type BuildInstanceOptions struct {
Output io.Writer
// Package name, e.g. 'infra/tools/cipd'.
PackageName string
+ // Log defines logger to use.
+ Log logging.Logger
}
// BuildInstance builds a new package instance for package named opts.PackageName
@@ -30,7 +35,10 @@ type BuildInstanceOptions struct {
// to opts.Output. Some output may be written even if BuildInstance eventually
// returns an error.
func BuildInstance(opts BuildInstanceOptions) error {
- err := ValidatePackageName(opts.PackageName)
+ if opts.Log == nil {
+ opts.Log = logging.DefaultLogger
+ }
+ err := common.ValidatePackageName(opts.PackageName)
if err != nil {
return err
}
@@ -60,12 +68,12 @@ func BuildInstance(opts BuildInstanceOptions) error {
}
// Write the final zip file.
- return zipInputFiles(files, opts.Output)
+ return zipInputFiles(files, opts.Output, opts.Log)
}
// zipInputFiles deterministically builds a zip archive out of input files and
// writes it to the writer. Files are written in the order given.
-func zipInputFiles(files []File, w io.Writer) error {
+func zipInputFiles(files []File, w io.Writer, log logging.Logger) error {
writer := zip.NewWriter(w)
defer writer.Close()
« no previous file with comments | « go/src/infra/tools/cipd/files_test.go ('k') | go/src/infra/tools/cipd/local/builder_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698