Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use HasSuffix to check for suffix #1505

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

amangale
Copy link

@amangale amangale commented Jan 20, 2025

For checking the existence of a workspace, the existing regular expression match is not required and is prone to failure. Given that the workspace name is essentially a suffix, the idiomatic way would be to use HasSuffix.

The existing regular expression match is not required and is prone to failure. Given that the workspace name is essentially a suffix, the idiomatic way would be to use `HasSuffix`.
@amangale amangale requested a review from denis256 as a code owner January 20, 2025 10:13
The function `nameMatchesWorkspace` is no longer required.
This function is no longer required.
@james03160927
Copy link
Contributor

Hi @amangale, I believe this change might not be backward compatible since it alters the existing behavior. Could you elaborate on why this change is necessary and clarify what you mean by "prone to failure"?

@amangale
Copy link
Author

Hi @amangale, I believe this change might not be backward compatible since it alters the existing behavior. Could you elaborate on why this change is necessary and clarify what you mean by "prone to failure"?

Hi @james03160927 -
The earlier code was looking for the ws name at the end of the string which is a suffix.
We recently upgraded to TF v1.10 and Terragrunt v0.72 and modified the logging. This broke WorkspaceSelectOrNewE since the output of terraform workspace list was a different string with the ws name at the end.
I have this sample code: https://go.dev/play/p/g8JiafkjXmU
It demonstrates backward compatibility. If there is a specific use case you can share, I can modify the PR to accommodate it.

@james03160927
Copy link
Contributor

If we can modify the code to support the same functionality while also accommodating new use cases with the upgrade, it will ensure that existing users do not encounter sudden errors, especially in scenarios where their automatic setups update to the latest Terratest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants