-
Notifications
You must be signed in to change notification settings - Fork 131
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
Tweaking URL regex based on comment from aderuelle #225
Tweaking URL regex based on comment from aderuelle #225
Conversation
@micahflattbuilt - sorry, too fast on that last comment. Confirmed that it works for:
|
No @micahflattbuilt - I goofed and did not copy https://github.com/warrensbox/terraform-switcher/pull/225/files#diff-99b146ff8d948c450dfa0fe84cb71461f9b43acbfc52837fbf712e696ccea2f2R40 (a little too fast off the trigger). I am trying to get our automation back up... |
I know all about trying to get your automation back up quickly... I posted my build to our CD servers to get things rolling again (with success). It's a bit of a silly patch but so far seems to work as a quick fix. |
^^^ merge please |
we need this change please! merge :( |
I pushed a temp release to my fork with these changes in the meantime - https://github.com/Jukie/terraform-switcher/releases/tag/0.13.12345 |
lib/list_versions.go
Outdated
@@ -27,16 +27,17 @@ func GetTFList(mirrorURL string, preRelease bool) ([]string, error) { | |||
var semver string | |||
if preRelease == true { | |||
// Getting versions from body; should return match /X.X.X-@/ where X is a number,@ is a word character between a-z or A-Z | |||
semver = `\/(\d+\.\d+\.\d+)(-[a-zA-z]+\d*)?\/` | |||
semver = `\/(\d+\.\d+\.\d+)(-[a-zA-z]+\d*)?\"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of interest: what is the reason to quote double quote in regex? does it have any special meaning? or is this used down the code and is enclosed in double quotes? (the latter explain the need to quote)
also might probably need to adjust comment above this line to replace last char of regex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- escaping is not needed in raw string literals
- could use word characters class \w for the '@' part
- we also could accomodate for possible reintroduction of trailing '/'
Not tested:
semver = `\/(\d+\.\d+\.\d+)(-[a-zA-z]+\d*)?\"` | |
semver = `/(\d+.\d+.\d+)(-\w+)?/?"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the double quote in the regex, I was finding that it was capturing both pre release and full release versions every time. The double quote acts as an ending delimiter so that the right versions are found when ignoring pre-release versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though the double quote doesn't need to be escaped, right? Oops, please disregard, I didn't make it to see the new commit to this PR by the time of writing the comment.
lib/list_versions.go
Outdated
} | ||
r, _ := regexp.Compile(semver) | ||
for i := range result { | ||
if r.MatchString(result[i]) { | ||
str := r.FindString(result[i]) | ||
trimstr := strings.Trim(str, "/") //remove "/" from /X.X.X/ | ||
trimstr := strings.Trim(str, "/\"") //remove "/" from /X.X.X/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might probably need to adjust comment on this line to reflect regex pattern change.
Also may probably worth to switch to their new API? |
lib/list_versions.go
Outdated
} else if preRelease == false { | ||
// Getting versions from body; should return match /X.X.X/ where X is a number | ||
semver = `\/(\d+\.\d+\.\d+)\/` | ||
// without the ending '"' pre-release folders would be tried and break. | ||
semver = `\/(\d+\.\d+\.\d+)\"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto, not tested:
semver = `\/(\d+\.\d+\.\d+)\"` | |
semver = `/(\d+.\d+.\d+)/?"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now works on interactive mode. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the escape of the double quote and added the optional ending slash. My local tests still work with the additions.
Hello Team, May we expect this to be available today, we have some CRQ going and we got stuck due to this 😄 |
+1 |
4 similar comments
+1 |
+1 |
+1 |
+1 |
No one assigned (15h) |
@yermulnik , I agree that the release API would be the way to go. This PR just tries to provide a quick path for recovery. |
I expect there are timezone differences to see as well :) but bumping this some more! |
Got you. Makes sense. Thanks. |
Is it going to be merged today? I need to know if we need to change our build tools to not use tfswitch to make them work |
We are using temporally @jukie fork in our pipelines and work fine! We apply the following fix to our docker images. |
…iner There is a current issue with the original tfswitch as hashicorp changed their website and so the bit of tfswitch which scrapes that info is failing. This is a temporary fix until the PR is merged on tfswitch. github issue: warrensbox/terraform-switcher#225 differences between versions: warrensbox/terraform-switcher@master...Jukie:fix-release-downloads
We switched to tfenv. https://github.com/tfutils/tfenv |
@warrensbox any chance of getting this merged soon? |
@micahflattbuilt - I found a couple more places around the "pre-release" tests:
|
@allen-servedio applied your diff as a new commit. |
Sorry to piggyback the PR but was anyone able to get the releases api working for anything past the most recent releases(e.g. first batch from whatever's passed in for |
@warrensbox Is it possible to release this as a temporary hotfix? I appreciate that there are conversations around a more reliable implementation using the releases API but suppose that can be addressed in a further release. A hotfix from this PR would be great in the mean time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! MERGE😜! 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
github issue: warrensbox/terraform-switcher#225 differences between versions: warrensbox/[email protected]:fix-release-downloads
Thanks @jukie - fix works great |
This is fixed and released |
URL tweaks based on changes to the hashicorp release site.