mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[infra] Remove trailing new-line from auth token file
The result from 'gcloud auth print-access-token' contains a new-line that cannot be used in the header. To make this use case easier, remove new-lines, if found. Change-Id: I44a9cc2bcfe4a8ef06e47a8495e69e116e9a6dfa Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153921 Commit-Queue: Karl Klose <karlklose@google.com> Reviewed-by: William Hesse <whesse@google.com>
This commit is contained in:
parent
99b693ba88
commit
96d839a436
|
@ -53,6 +53,11 @@ ${parser.usage}''');
|
|||
exit(1);
|
||||
}
|
||||
|
||||
Future<String> readGcloudAuthToken(String path) async {
|
||||
String token = await File(path).readAsString();
|
||||
return token.split("\n").first;
|
||||
}
|
||||
|
||||
main(List<String> args) async {
|
||||
final parser = new ArgParser();
|
||||
parser.addFlag('help', help: 'Show the program usage.', negatable: false);
|
||||
|
@ -72,7 +77,11 @@ main(List<String> args) async {
|
|||
builder = options['builder'];
|
||||
buildNumber = int.parse(options['build_number']);
|
||||
builderBase = builder.replaceFirst(RegExp('-try\$'), '');
|
||||
token = await File(options['auth_token']).readAsString();
|
||||
if (options['auth_token'] == null) {
|
||||
print('Option "--auth_token (-a)" is required\n');
|
||||
usage(parser);
|
||||
}
|
||||
token = await readGcloudAuthToken(options['auth_token']);
|
||||
client = http.Client();
|
||||
for (int count = 0; count < numAttempts; ++count) {
|
||||
if (count > 0) {
|
||||
|
|
Loading…
Reference in a new issue