Skip to content

Conversation

@disq
Copy link
Member

@disq disq commented Nov 9, 2023

Also adds another ldflag path (resources/plugin) to set Version which is what we already have in github releases.

serve/package.go Outdated
return err
}
defer f.Close()
if ok, err := fileContains(f, "Version"); err != nil {
Copy link
Member Author

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...

Copy link
Member

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*=?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add regex

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

github-actions bot commented Nov 9, 2023

⏱️ Benchmark results

Comparing with f5cd387

  • Glob-8 ns/op: 90.59 ⬇️ 2.90% decrease vs. f5cd387

disq and others added 2 commits November 9, 2023 11:38
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*=`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
versionRegex := regexp.MustCompile(`^\s?Version\s*=`)
versionRegex := regexp.MustCompile(`Version\s*=`)

otherwise var Version = "development" would fail

Copy link
Member Author

@disq disq Nov 9, 2023

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?...

https://regex101.com/r/7Hm4PT/3

Copy link
Member Author

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*=`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
versionRegex := regexp.MustCompile(`^(var)?\s?Version\s*=`)
versionRegex := regexp.MustCompile(`^\s*(var\s+)?Version\s*=`)

Copy link
Member Author

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)

Copy link
Member

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

@disq disq merged commit 2f1aff8 into cloudquery:main Nov 9, 2023
@disq disq deleted the feat/check-for-Version branch November 9, 2023 14:47
kodiakhq bot pushed a commit that referenced this pull request Nov 9, 2023
🤖 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants