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

Side by Side Diff: cipd/client/cli/main.go

Issue 2951393002: [errors] de-specialize Transient in favor of Tags. (Closed)
Patch Set: more refactor Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The LUCI Authors. All rights reserved. 1 // Copyright 2014 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package cli 5 package cli
6 6
7 import ( 7 import (
8 "crypto/sha1" 8 "crypto/sha1"
9 "encoding/hex" 9 "encoding/hex"
10 "encoding/json" 10 "encoding/json"
11 "flag" 11 "flag"
12 "fmt" 12 "fmt"
13 "io" 13 "io"
14 "io/ioutil" 14 "io/ioutil"
15 "net/http" 15 "net/http"
16 "os" 16 "os"
17 "path/filepath" 17 "path/filepath"
18 "strings" 18 "strings"
19 "sync" 19 "sync"
20 "time" 20 "time"
21 21
22 "github.com/kardianos/osext" 22 "github.com/kardianos/osext"
23 "github.com/maruel/subcommands" 23 "github.com/maruel/subcommands"
24 "golang.org/x/net/context" 24 "golang.org/x/net/context"
25 25
26 "github.com/luci/luci-go/common/auth" 26 "github.com/luci/luci-go/common/auth"
27 "github.com/luci/luci-go/common/cli" 27 "github.com/luci/luci-go/common/cli"
28 "github.com/luci/luci-go/common/errors"
29 "github.com/luci/luci-go/common/logging" 28 "github.com/luci/luci-go/common/logging"
30 "github.com/luci/luci-go/common/logging/gologger" 29 "github.com/luci/luci-go/common/logging/gologger"
30 "github.com/luci/luci-go/common/retry/transient"
31 31
32 "github.com/luci/luci-go/client/authcli" 32 "github.com/luci/luci-go/client/authcli"
33 33
34 "github.com/luci/luci-go/cipd/client/cipd" 34 "github.com/luci/luci-go/cipd/client/cipd"
35 "github.com/luci/luci-go/cipd/client/cipd/common" 35 "github.com/luci/luci-go/cipd/client/cipd/common"
36 "github.com/luci/luci-go/cipd/client/cipd/ensure" 36 "github.com/luci/luci-go/cipd/client/cipd/ensure"
37 "github.com/luci/luci-go/cipd/client/cipd/local" 37 "github.com/luci/luci-go/cipd/client/cipd/local"
38 "github.com/luci/luci-go/cipd/version" 38 "github.com/luci/luci-go/cipd/version"
39 ) 39 )
40 40
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 } 836 }
837 837
838 func (c *checkUpdatesRun) Run(a subcommands.Application, args []string, env subc ommands.Env) int { 838 func (c *checkUpdatesRun) Run(a subcommands.Application, args []string, env subc ommands.Env) int {
839 if !c.checkArgs(args, 0, 0) { 839 if !c.checkArgs(args, 0, 0) {
840 return 1 840 return 1
841 } 841 }
842 ctx := cli.GetContext(a, c, env) 842 ctx := cli.GetContext(a, c, env)
843 _, actions, err := ensurePackages(ctx, c.rootDir, c.ensureFile, true, c. clientOptions) 843 _, actions, err := ensurePackages(ctx, c.rootDir, c.ensureFile, true, c. clientOptions)
844 if err != nil { 844 if err != nil {
845 ret := c.done(actions, err) 845 ret := c.done(actions, err)
846 » » if errors.IsTransient(err) { 846 » » if transient.Tag.In(err) {
847 return ret // fail as usual 847 return ret // fail as usual
848 } 848 }
849 return 0 // on fatal errors ask puppet to run 'ensure' for real 849 return 0 // on fatal errors ask puppet to run 'ensure' for real
850 } 850 }
851 c.done(actions, nil) 851 c.done(actions, nil)
852 if len(actions) == 0 { 852 if len(actions) == 0 {
853 return 5 // some arbitrary non-zero number, unlikely to show up on errors 853 return 5 // some arbitrary non-zero number, unlikely to show up on errors
854 } 854 }
855 return 0 855 return 0
856 } 856 }
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2214 // subcommand invocations look more natural. 2214 // subcommand invocations look more natural.
2215 // 2215 //
2216 // Compare: 2216 // Compare:
2217 // * Default: cipd set-ref -ref=abc -version=def package/name 2217 // * Default: cipd set-ref -ref=abc -version=def package/name
2218 // * Improved: cipd set-ref package/name -ref=abc -version=def 2218 // * Improved: cipd set-ref package/name -ref=abc -version=def
2219 // 2219 //
2220 // Much better. 2220 // Much better.
2221 func Main(params Parameters, args []string) int { 2221 func Main(params Parameters, args []string) int {
2222 return subcommands.Run(GetApplication(params), fixFlagsPosition(args)) 2222 return subcommands.Run(GetApplication(params), fixFlagsPosition(args))
2223 } 2223 }
OLDNEW
« no previous file with comments | « cipd/client/cipd/client.go ('k') | common/auth/auth.go » ('j') | common/errors/tags.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698