refactor(util): allow tryRun to take a regex. #6640
Merged
+38
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
This is aimed at fixing the following ec2 bug.
Attempting to generate the ssh keys via tryRun can log a failure, when there is no failure. Looking at
aws-toolkit-vscode/packages/core/src/awsService/ec2/sshKeyPair.ts
Lines 78 to 86 in 35502be
We use
tryRun
to detect if the output contains "unknown key type". This allows us to detect when a certain key type such as RSA or ed25519 is not supported on the local machine. Detecting if the key generated successfully is a harder problem, as the output did not contain a consistent message.However, it results in
tryRun
logging a failure to find "unknown key type" in the output, which means failed to find the expected text in the output, but still generated the key. This is then logged as a failure, but is functionally a success. This is very confusing behavior.The root of this problem is we are trying to use
tryRun
in a way it doesn't naturally support. Rather than use it awkwardly, we can extend it.Solution
New logs:
feature/x
branches will not be squash-merged at release time.