Skip to content

Commit

Permalink
[infra] Remove trailing new-line from auth token file
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
karlklose authored and commit-bot@chromium.org committed Jul 10, 2020
1 parent 99b693b commit 96d839a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tools/bots/get_builder_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit 96d839a

Please sign in to comment.