| 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
|
| +}
|
|
|