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

Unified Diff: go/src/infra/tools/cipd/local/manifest.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/local/local.infra_testing ('k') | go/src/infra/tools/cipd/local/manifest_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/manifest.go
diff --git a/go/src/infra/tools/cipd/local/manifest.go b/go/src/infra/tools/cipd/local/manifest.go
new file mode 100644
index 0000000000000000000000000000000000000000..120c62766236df7f32b3ce3433ed411b7c649b8e
--- /dev/null
+++ b/go/src/infra/tools/cipd/local/manifest.go
@@ -0,0 +1,48 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package local
+
+import (
+ "encoding/json"
+ "io"
+ "io/ioutil"
+)
+
+// Name of the directory inside an installation root reserved for cipd stuff.
+const SiteServiceDir = ".cipd"
+
+// Name of the directory inside the package reserved for cipd stuff.
+const packageServiceDir = ".cipdpkg"
+
+// Name of the manifest file inside the package.
+const manifestName = packageServiceDir + "/manifest.json"
+
+// Format version to write to the manifest file.
+const manifestFormatVersion = "1"
+
+// Manifest defines structure of manifest.json file.
+type Manifest struct {
+ FormatVersion string `json:"format_version"`
+ PackageName string `json:"package_name"`
+}
+
+// readManifest reads and decodes manifest JSON from io.Reader.
+func readManifest(r io.Reader) (manifest Manifest, err error) {
+ blob, err := ioutil.ReadAll(r)
+ if err == nil {
+ err = json.Unmarshal(blob, &manifest)
+ }
+ return
+}
+
+// writeManifest encodes and writes manifest JSON to io.Writer.
+func writeManifest(m *Manifest, w io.Writer) error {
+ data, err := json.MarshalIndent(m, "", " ")
+ if err != nil {
+ return err
+ }
+ _, err = w.Write(data)
+ return err
+}
« no previous file with comments | « go/src/infra/tools/cipd/local/local.infra_testing ('k') | go/src/infra/tools/cipd/local/manifest_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698