getActiveGcloudAccount method
Email of the gcloud account currently active for this terminal session
(gcloud config get-value account), or null when gcloud is not
authenticated / not installed.
This is the principal that all gcloud … calls run as when Oracular
has no _authEnvironment override (i.e. no service-account.json
found in the project folder). When the user previously ran
gcloud auth activate-service-account, this can return a service
account email even though Oracular itself never set
GOOGLE_APPLICATION_CREDENTIALS. The wizard uses it as a fallback
detector so the IAM gate fires correctly in that case.
Implementation
Future<String?> getActiveGcloudAccount() async {
final ProcessResult r = await _runner.run('gcloud', <String>[
'config',
'get-value',
'account',
]);
if (!r.success) return null;
final String trimmed = _stripAnsi(r.stdout).trim();
if (trimmed.isEmpty || trimmed == '(unset)') return null;
return trimmed;
}