-
Notifications
You must be signed in to change notification settings - Fork 26
feat(package): Check for Version variable #1359
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
Conversation
serve/package.go
Outdated
| return err | ||
| } | ||
| defer f.Close() | ||
| if ok, err := fileContains(f, "Version"); err != nil { |
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.
could also have a regex that requires whitespace around Version...
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.
Or maybe a regex that checks for Version\s*=?
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.
Will add 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.
Regex in cdb8b66
Co-authored-by: Herman Schaaf <hermanschaaf@gmail.com>
serve/package.go
Outdated
| return fmt.Errorf("plugin directory must contain at least one of the following directories: %s", strings.Join(checkRelativeDirs, ", ")) | ||
| } | ||
|
|
||
| versionRegex := regexp.MustCompile(`^\s?Version\s*=`) |
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.
| versionRegex := regexp.MustCompile(`^\s?Version\s*=`) | |
| versionRegex := regexp.MustCompile(`Version\s*=`) |
otherwise var Version = "development" would fail
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.
Fixed by adding (var)?
var Version = wouldn't work (preceding space before var) but I think that's fine, or I could add another \s?...
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.
will add regex tests.
serve/package.go
Outdated
| return fmt.Errorf("plugin directory must contain at least one of the following directories: %s", strings.Join(checkRelativeDirs, ", ")) | ||
| } | ||
|
|
||
| versionRegex := regexp.MustCompile(`^(var)?\s?Version\s*=`) |
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.
| versionRegex := regexp.MustCompile(`^(var)?\s?Version\s*=`) | |
| versionRegex := regexp.MustCompile(`^\s*(var\s+)?Version\s*=`) |
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.
do we really want to allow that though? Would lead to more false matches (inside a function... I know others also do)
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.
oh yeah I guess it would be a false match inside a function. fair enough
🤖 I have created a release *beep* *boop* --- ## [4.18.0](v4.17.2...v4.18.0) (2023-11-09) ### Features * **package:** Check for Version variable ([#1359](#1359)) ([2f1aff8](2f1aff8)) ### Bug Fixes * **deps:** Update module github.com/cloudquery/cloudquery-api-go to v1.4.3 ([#1357](#1357)) ([f5cd387](f5cd387)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Also adds another ldflag path (
resources/plugin) to setVersionwhich is what we already have in github releases.