Chromium Code Reviews| 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 |
| +} |