Skip to content

Commit 96d839a

Browse files
karlklosecommit-bot@chromium.org
authored andcommitted
[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 <[email protected]> Reviewed-by: William Hesse <[email protected]>
1 parent 99b693b commit 96d839a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tools/bots/get_builder_status.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ ${parser.usage}''');
5353
exit(1);
5454
}
5555

56+
Future<String> readGcloudAuthToken(String path) async {
57+
String token = await File(path).readAsString();
58+
return token.split("\n").first;
59+
}
60+
5661
main(List<String> args) async {
5762
final parser = new ArgParser();
5863
parser.addFlag('help', help: 'Show the program usage.', negatable: false);
@@ -72,7 +77,11 @@ main(List<String> args) async {
7277
builder = options['builder'];
7378
buildNumber = int.parse(options['build_number']);
7479
builderBase = builder.replaceFirst(RegExp('-try\$'), '');
75-
token = await File(options['auth_token']).readAsString();
80+
if (options['auth_token'] == null) {
81+
print('Option "--auth_token (-a)" is required\n');
82+
usage(parser);
83+
}
84+
token = await readGcloudAuthToken(options['auth_token']);
7685
client = http.Client();
7786
for (int count = 0; count < numAttempts; ++count) {
7887
if (count > 0) {

0 commit comments

Comments
 (0)