| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 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 main | 5 package main |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "errors" | 8 "errors" |
| 9 "flag" | 9 "flag" |
| 10 "fmt" | 10 "fmt" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 func (c *commonServerFlags) createAuthClient() (*http.Client, error) { | 64 func (c *commonServerFlags) createAuthClient() (*http.Client, error) { |
| 65 // Don't enforce authentication by using OptionalLogin mode. This is nee
ded | 65 // Don't enforce authentication by using OptionalLogin mode. This is nee
ded |
| 66 // for IP whitelisted bots: they have NO credentials to send. | 66 // for IP whitelisted bots: they have NO credentials to send. |
| 67 ctx := gologger.StdConfig.Use(context.Background()) | 67 ctx := gologger.StdConfig.Use(context.Background()) |
| 68 return auth.NewAuthenticator(ctx, auth.OptionalLogin, c.parsedAuthOpts).
Client() | 68 return auth.NewAuthenticator(ctx, auth.OptionalLogin, c.parsedAuthOpts).
Client() |
| 69 } | 69 } |
| 70 | 70 |
| 71 type isolateFlags struct { | 71 type isolateFlags struct { |
| 72 // TODO(tandrii): move ArchiveOptions from isolate pkg to here. | 72 // TODO(tandrii): move ArchiveOptions from isolate pkg to here. |
| 73 isolate.ArchiveOptions | 73 isolate.ArchiveOptions |
| 74 EventlogEndpoint string | |
| 75 } | 74 } |
| 76 | 75 |
| 77 func (c *isolateFlags) Init(f *flag.FlagSet) { | 76 func (c *isolateFlags) Init(f *flag.FlagSet) { |
| 78 c.ArchiveOptions.Init() | 77 c.ArchiveOptions.Init() |
| 79 f.StringVar(&c.Isolate, "isolate", "", ".isolate file to load the depend
ency data from") | 78 f.StringVar(&c.Isolate, "isolate", "", ".isolate file to load the depend
ency data from") |
| 80 f.StringVar(&c.Isolate, "i", "", "Alias for --isolate") | 79 f.StringVar(&c.Isolate, "i", "", "Alias for --isolate") |
| 81 f.StringVar(&c.Isolated, "isolated", "", ".isolated file to generate or
read") | 80 f.StringVar(&c.Isolated, "isolated", "", ".isolated file to generate or
read") |
| 82 f.StringVar(&c.Isolated, "s", "", "Alias for --isolated") | 81 f.StringVar(&c.Isolated, "s", "", "Alias for --isolated") |
| 83 f.Var(&c.Blacklist, "blacklist", "List of regexp to use as blacklist fil
ter when uploading directories") | 82 f.Var(&c.Blacklist, "blacklist", "List of regexp to use as blacklist fil
ter when uploading directories") |
| 84 f.Var(&c.ConfigVariables, "config-variable", "Config variables are used
to determine which conditions should be matched when loading a .isolate file, de
fault: [].") | 83 f.Var(&c.ConfigVariables, "config-variable", "Config variables are used
to determine which conditions should be matched when loading a .isolate file, de
fault: [].") |
| 85 f.Var(&c.PathVariables, "path-variable", "Path variables are used to rep
lace file paths when loading a .isolate file, default: {}") | 84 f.Var(&c.PathVariables, "path-variable", "Path variables are used to rep
lace file paths when loading a .isolate file, default: {}") |
| 86 f.Var(&c.ExtraVariables, "extra-variable", "Extraneous variables are rep
laced on the command entry and on paths in the .isolate file but are not conside
red relative paths.") | 85 f.Var(&c.ExtraVariables, "extra-variable", "Extraneous variables are rep
laced on the command entry and on paths in the .isolate file but are not conside
red relative paths.") |
| 87 | |
| 88 f.StringVar(&c.EventlogEndpoint, "eventlog-endpoint", "", `The URL desti
nation for eventlogs. The special values "prod" or "test" may be used to target
the standard prod or test urls repspectively. An empty string disables eventlogg
ing.`) | |
| 89 } | 86 } |
| 90 | 87 |
| 91 // RequiredIsolateFlags specifies which flags are required on the command line | 88 // RequiredIsolateFlags specifies which flags are required on the command line |
| 92 // being parsed. | 89 // being parsed. |
| 93 type RequiredIsolateFlags uint | 90 type RequiredIsolateFlags uint |
| 94 | 91 |
| 95 const ( | 92 const ( |
| 96 // RequireIsolateFile means the --isolate flag is required. | 93 // RequireIsolateFile means the --isolate flag is required. |
| 97 RequireIsolateFile RequiredIsolateFlags = 1 << iota | 94 RequireIsolateFile RequiredIsolateFlags = 1 << iota |
| 98 // RequireIsolatedFile means the --isolated flag is required. | 95 // RequireIsolatedFile means the --isolated flag is required. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 125 if flags&RequireIsolatedFile != 0 { | 122 if flags&RequireIsolatedFile != 0 { |
| 126 return errors.New("-isolated must be specified") | 123 return errors.New("-isolated must be specified") |
| 127 } | 124 } |
| 128 } else { | 125 } else { |
| 129 if !filepath.IsAbs(c.Isolated) { | 126 if !filepath.IsAbs(c.Isolated) { |
| 130 c.Isolated = filepath.Clean(filepath.Join(cwd, c.Isolate
d)) | 127 c.Isolated = filepath.Clean(filepath.Join(cwd, c.Isolate
d)) |
| 131 } | 128 } |
| 132 } | 129 } |
| 133 return nil | 130 return nil |
| 134 } | 131 } |
| 132 |
| 133 // loggingFlags configures eventlog logging. |
| 134 type loggingFlags struct { |
| 135 EventlogEndpoint string |
| 136 } |
| 137 |
| 138 func (lf *loggingFlags) Init(f *flag.FlagSet) { |
| 139 f.StringVar(&lf.EventlogEndpoint, "eventlog-endpoint", "", `The URL dest
ination for eventlogs. The special values "prod" or "test" may be used to target
the standard prod or test urls repspectively. An empty string disables eventlog
ging.`) |
| 140 } |
| OLD | NEW |