| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /* | 5 /* |
| 6 Package cipd implements client side of Chrome Infra Package Deployer. | 6 Package cipd implements client side of Chrome Infra Package Deployer. |
| 7 | 7 |
| 8 TODO: write more. | 8 TODO: write more. |
| 9 | 9 |
| 10 Binary package file format (in free form representation): | 10 Binary package file format (in free form representation): |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // processed" responses. | 160 // processed" responses. |
| 161 AttachTagsWhenReady(pin common.Pin, tags []string) error | 161 AttachTagsWhenReady(pin common.Pin, tags []string) error |
| 162 | 162 |
| 163 // FetchInstance downloads package instance file from the repository. | 163 // FetchInstance downloads package instance file from the repository. |
| 164 FetchInstance(pin common.Pin, output io.WriteSeeker) error | 164 FetchInstance(pin common.Pin, output io.WriteSeeker) error |
| 165 | 165 |
| 166 // FetchAndDeployInstance fetches the package instance and deploys it in
to | 166 // FetchAndDeployInstance fetches the package instance and deploys it in
to |
| 167 // the site root. It doesn't check whether the instance is already deplo
yed. | 167 // the site root. It doesn't check whether the instance is already deplo
yed. |
| 168 FetchAndDeployInstance(pin common.Pin) error | 168 FetchAndDeployInstance(pin common.Pin) error |
| 169 | 169 |
| 170 // ListPackages returns a list of strings of package names. |
| 171 ListPackages(prefix string) ([]string, error) |
| 172 |
| 170 // ProcessEnsureFile parses text file that describes what should be inst
alled | 173 // ProcessEnsureFile parses text file that describes what should be inst
alled |
| 171 // by EnsurePackages function. It is a text file where each line has a f
orm: | 174 // by EnsurePackages function. It is a text file where each line has a f
orm: |
| 172 // <package name> <desired version>. Whitespaces are ignored. Lines that
start | 175 // <package name> <desired version>. Whitespaces are ignored. Lines that
start |
| 173 // with '#' are ignored. Version can be specified as instance ID, tag or
ref. | 176 // with '#' are ignored. Version can be specified as instance ID, tag or
ref. |
| 174 // Will resolve tags and refs to concrete instance IDs by calling the ba
ckend. | 177 // Will resolve tags and refs to concrete instance IDs by calling the ba
ckend. |
| 175 ProcessEnsureFile(r io.Reader) ([]common.Pin, error) | 178 ProcessEnsureFile(r io.Reader) ([]common.Pin, error) |
| 176 | 179 |
| 177 // EnsurePackages is high-level interface for installation, removal and
update | 180 // EnsurePackages is high-level interface for installation, removal and
update |
| 178 // of packages inside the installation site root. Given a description of | 181 // of packages inside the installation site root. Given a description of |
| 179 // what packages (and versions) should be installed it will do all neces
sary | 182 // what packages (and versions) should be installed it will do all neces
sary |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 274 } |
| 272 | 275 |
| 273 func (client *clientImpl) FetchACL(packagePath string) ([]PackageACL, error) { | 276 func (client *clientImpl) FetchACL(packagePath string) ([]PackageACL, error) { |
| 274 return client.remote.fetchACL(packagePath) | 277 return client.remote.fetchACL(packagePath) |
| 275 } | 278 } |
| 276 | 279 |
| 277 func (client *clientImpl) ModifyACL(packagePath string, changes []PackageACLChan
ge) error { | 280 func (client *clientImpl) ModifyACL(packagePath string, changes []PackageACLChan
ge) error { |
| 278 return client.remote.modifyACL(packagePath, changes) | 281 return client.remote.modifyACL(packagePath, changes) |
| 279 } | 282 } |
| 280 | 283 |
| 284 func (client *clientImpl) ListPackages(prefix string) ([]string, error) { |
| 285 return client.remote.listPackages(prefix) |
| 286 } |
| 287 |
| 281 func (client *clientImpl) UploadToCAS(sha1 string, data io.ReadSeeker, session *
UploadSession) error { | 288 func (client *clientImpl) UploadToCAS(sha1 string, data io.ReadSeeker, session *
UploadSession) error { |
| 282 // Open new upload session if an existing is not provided. | 289 // Open new upload session if an existing is not provided. |
| 283 var err error | 290 var err error |
| 284 if session == nil { | 291 if session == nil { |
| 285 client.Logger.Infof("cipd: uploading %s: initiating", sha1) | 292 client.Logger.Infof("cipd: uploading %s: initiating", sha1) |
| 286 session, err = client.remote.initiateUpload(sha1) | 293 session, err = client.remote.initiateUpload(sha1) |
| 287 if err != nil { | 294 if err != nil { |
| 288 client.Logger.Warningf("cipd: can't upload %s - %s", sha
1, err) | 295 client.Logger.Warningf("cipd: can't upload %s - %s", sha
1, err) |
| 289 return err | 296 return err |
| 290 } | 297 } |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 modifyACL(packagePath string, changes []PackageACLChange) error | 596 modifyACL(packagePath string, changes []PackageACLChange) error |
| 590 | 597 |
| 591 resolveVersion(packageName, version string) (common.Pin, error) | 598 resolveVersion(packageName, version string) (common.Pin, error) |
| 592 | 599 |
| 593 initiateUpload(sha1 string) (*UploadSession, error) | 600 initiateUpload(sha1 string) (*UploadSession, error) |
| 594 finalizeUpload(sessionID string) (bool, error) | 601 finalizeUpload(sessionID string) (bool, error) |
| 595 registerInstance(pin common.Pin) (*registerInstanceResponse, error) | 602 registerInstance(pin common.Pin) (*registerInstanceResponse, error) |
| 596 | 603 |
| 597 attachTags(pin common.Pin, tags []string) error | 604 attachTags(pin common.Pin, tags []string) error |
| 598 fetchInstance(pin common.Pin) (*fetchInstanceResponse, error) | 605 fetchInstance(pin common.Pin) (*fetchInstanceResponse, error) |
| 606 |
| 607 listPackages(prefix string) ([]string, error) |
| 599 } | 608 } |
| 600 | 609 |
| 601 type storage interface { | 610 type storage interface { |
| 602 upload(url string, data io.ReadSeeker) error | 611 upload(url string, data io.ReadSeeker) error |
| 603 download(url string, output io.WriteSeeker) error | 612 download(url string, output io.WriteSeeker) error |
| 604 } | 613 } |
| 605 | 614 |
| 606 type registerInstanceResponse struct { | 615 type registerInstanceResponse struct { |
| 607 uploadSession *UploadSession | 616 uploadSession *UploadSession |
| 608 alreadyRegistered bool | 617 alreadyRegistered bool |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 } | 654 } |
| 646 | 655 |
| 647 // buildInstanceIDMap builds mapping {package name -> instance ID}. | 656 // buildInstanceIDMap builds mapping {package name -> instance ID}. |
| 648 func buildInstanceIDMap(pins []common.Pin) map[string]string { | 657 func buildInstanceIDMap(pins []common.Pin) map[string]string { |
| 649 out := map[string]string{} | 658 out := map[string]string{} |
| 650 for _, p := range pins { | 659 for _, p := range pins { |
| 651 out[p.PackageName] = p.InstanceID | 660 out[p.PackageName] = p.InstanceID |
| 652 } | 661 } |
| 653 return out | 662 return out |
| 654 } | 663 } |
| OLD | NEW |