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

Add some validation on version-var before passing it to Go #173

Open
ashrayjain opened this issue Feb 12, 2020 · 1 comment
Open

Add some validation on version-var before passing it to Go #173

ashrayjain opened this issue Feb 12, 2020 · 1 comment

Comments

@ashrayjain
Copy link

What happened?

Sometimes version-var can have typos/incorrect package names after renames/moves/etc.

What did you want to happen?

Instead of silently dropping the version substitution, it would be much nicer UX if we errored/warned and alerted the user.

@nmiyake
Copy link
Contributor

nmiyake commented Feb 12, 2020

Work involved would be the following:

  • Parse content of the version-var configuration to determine the package path and variable
    • Fail/error if format is not correct
  • Load the target package using the Go packages API
    • Note that we need to consider the directory that is the build target as well, since "main" is a valid package identifier and, in that case, the directory location matters
  • Look up the named variable to verify that it exists in the package
    • Possibly verify the type as well

Error output should clearly indicate what failed:

"unable to set version variable: package a.b.c does not exist"
"unable to set version variable: variable "version" not in package a.b.c"
"unable to set version variable: variable "version" is not of type string" (may need to verify if this is truly an error case)

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

No branches or pull requests

2 participants