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

Unified Diff: cipd/client/cipd/local/json_descs.go

Issue 2640703002: Change CIPD internal pkgs directory layout to use numeric indices. (Closed)
Patch Set: Address comments Created 3 years, 11 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
Index: cipd/client/cipd/local/json_descs.go
diff --git a/cipd/client/cipd/local/manifest.go b/cipd/client/cipd/local/json_descs.go
similarity index 83%
rename from cipd/client/cipd/local/manifest.go
rename to cipd/client/cipd/local/json_descs.go
index 86422df99acdff9d305ce5ebbc90fe441b63cbc8..f7139d4ebee24c6104093f0b7a3d95b6466790bb 100644
--- a/cipd/client/cipd/local/manifest.go
+++ b/cipd/client/cipd/local/json_descs.go
@@ -122,3 +122,34 @@ func writeManifest(m *Manifest, w io.Writer) error {
_, err = w.Write(data)
return err
}
+
+const (
+ // descriptionName is a name of the description file inside the package.
+ descriptionName = "description.json"
+)
+
+// Description defines the structure of the description.json file located at
+// .cipd/pkgs/<foo>/description.json.
+type Description struct {
+ Root string
Vadim Sh. 2017/01/19 01:26:01 `json:"root,omitempty"`
iannucci 2017/01/19 02:18:57 Done.
+ PackageName string
Vadim Sh. 2017/01/19 01:26:01 `json:"package_name"` (for consistency with other
iannucci 2017/01/19 02:18:57 Done.
+}
+
+// readDescription reads and decodes description JSON from io.Reader.
+func readDescription(r io.Reader) (desc *Description, err error) {
+ blob, err := ioutil.ReadAll(r)
+ if err == nil {
+ err = json.Unmarshal(blob, &desc)
+ }
+ return
+}
+
+// writeDescription encodes and writes description JSON to io.Writer.
+func writeDescription(d *Description, w io.Writer) error {
+ data, err := json.MarshalIndent(d, "", " ")
+ if err != nil {
+ return err
+ }
+ _, err = w.Write(data)
+ return err
+}

Powered by Google App Engine
This is Rietveld 408576698