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

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

Issue 2640703002: Change CIPD internal pkgs directory layout to use numeric indices. (Closed)
Patch Set: Add tests for numSet, fix bugs found 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 82%
rename from cipd/client/cipd/local/manifest.go
rename to cipd/client/cipd/local/json_descs.go
index 86422df99acdff9d305ce5ebbc90fe441b63cbc8..3950923b5cd46fea7528e392a5b10a9343fbc590 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 `json:"root,omitempty"`
+ PackageName string `json:"package_name,omitempty"`
+}
+
+// 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