createOrSelectStackInWorkspace method
Creates the stack when missing, otherwise selects it.
Implementation
Future<Stack> createOrSelectStackInWorkspace(String stackName) async {
final selectArgs = _selectStackArguments(stackName);
final selectResult = await runPulumiCommand(selectArgs, check: false);
if (selectResult.succeeded) {
return Stack(stackName, this);
}
if (!_looksLikeMissingStackError(selectResult)) {
final request = PulumiCommandRequest(
executable: pulumiBinary,
arguments: selectArgs,
workingDirectory: workDir,
environment: <String, String>{
...Platform.environment,
...environmentVariables,
},
runInShell: runInShell,
stdoutEncoding: stdoutEncoding,
stderrEncoding: stderrEncoding,
);
throw PulumiCommandException(request: request, result: selectResult);
}
await createStackInWorkspace(stackName);
return Stack(stackName, this);
}