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

Unified Diff: go/src/infra/tools/cipd/apps/cipd/main.go

Issue 1145423002: cipd: Client can resolve tags to instance IDs. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: cipd-resolve-version Created 5 years, 7 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
« no previous file with comments | « no previous file | go/src/infra/tools/cipd/client.go » ('j') | go/src/infra/tools/cipd/client.go » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/tools/cipd/apps/cipd/main.go
diff --git a/go/src/infra/tools/cipd/apps/cipd/main.go b/go/src/infra/tools/cipd/apps/cipd/main.go
index 35c5636ecc5d17a54e9fa40f72c62ebed572c884..b02e814af8f3ec14100323ada32ded7e8c8e74ef 100644
--- a/go/src/infra/tools/cipd/apps/cipd/main.go
+++ b/go/src/infra/tools/cipd/apps/cipd/main.go
@@ -707,7 +707,7 @@ var cmdFetch = &subcommands.Command{
CommandRun: func() subcommands.CommandRun {
c := &fetchRun{}
c.Flags.StringVar(&c.packageName, "name", "<name>", "package name")
- c.Flags.StringVar(&c.instanceID, "instance-id", "<instance id>", "package instance ID to fetch")
+ c.Flags.StringVar(&c.version, "version", "<version>", "package version to fetch")
c.Flags.StringVar(&c.outputPath, "out", "<path>", "path to a file to write fetch to")
c.ServiceOptions.registerFlags(&c.Flags)
return c
@@ -719,7 +719,7 @@ type fetchRun struct {
ServiceOptions
packageName string
- instanceID string
+ version string
outputPath string
}
@@ -727,8 +727,7 @@ func (c *fetchRun) Run(a subcommands.Application, args []string) int {
if !checkCommandLine(args, c.GetFlags(), 0) {
return 1
}
- pin := common.Pin{PackageName: c.packageName, InstanceID: c.instanceID}
- err := fetchInstanceFile(pin, c.outputPath, c.ServiceOptions)
+ err := fetchInstanceFile(c.packageName, c.version, c.outputPath, c.ServiceOptions)
if err != nil {
reportError("Error while fetching the package: %s", err)
return 1
@@ -736,7 +735,16 @@ func (c *fetchRun) Run(a subcommands.Application, args []string) int {
return 0
}
-func fetchInstanceFile(pin common.Pin, instanceFile string, serviceOpts ServiceOptions) error {
+func fetchInstanceFile(packageName, version, instanceFile string, serviceOpts ServiceOptions) error {
+ client, err := serviceOpts.makeCipdClient()
+ if err != nil {
+ return err
+ }
+ pin, err := client.ResolveVersion(packageName, version)
+ if err != nil {
+ return err
+ }
+
out, err := os.OpenFile(instanceFile, os.O_CREATE|os.O_WRONLY, 0666)
if err != nil {
return err
@@ -749,10 +757,6 @@ func fetchInstanceFile(pin common.Pin, instanceFile string, serviceOpts ServiceO
}
}()
- client, err := serviceOpts.makeCipdClient()
- if err != nil {
- return err
- }
err = client.FetchInstance(pin, out)
if err != nil {
return err
« no previous file with comments | « no previous file | go/src/infra/tools/cipd/client.go » ('j') | go/src/infra/tools/cipd/client.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698