-
Notifications
You must be signed in to change notification settings - Fork 55
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
chore: add version flag test #24
base: master
Are you sure you want to change the base?
Conversation
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.
很赞的path,可以按着CR修改下。然后,我测下merge了
pkg/version/flag.go
Outdated
@@ -83,14 +96,21 @@ func AddFlags(fs *flag.FlagSet) { | |||
fs.AddFlag(flag.Lookup(versionFlagName)) | |||
} | |||
|
|||
// variables for unit testing PrintAndExitIfRequested | |||
var ( | |||
appName = "onex-apiserver" |
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.
这里不能写appName=“onex-apiserver”,这么一写,pkg/version包就跟onex项目的onex-apiserver耦合了。变成了一个非完全独立的Go包,version包也不适合放在pkg/目录下了。
pkg/version/flag.go
Outdated
@@ -39,6 +42,16 @@ func (v *versionValue) Set(s string) error { | |||
*v = VersionRaw | |||
return nil | |||
} | |||
|
|||
if strings.HasPrefix(s, "v") { | |||
err := version.SetDynamicVersion(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.
github.com/superproj/onex/pkg/version 有SetDynamicVersion,可以直接引用
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.
has been modified, thanks for review the code again
What type of PR is this?
/kind chore
What this PR does / why we need it:
fix version flag test