-
Notifications
You must be signed in to change notification settings - Fork 551
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
Use GitVersion to parse version from discovery #2312
Use GitVersion to parse version from discovery #2312
Conversation
serverGitVersion, err := semver.Parse(serverVersion.GitVersion) | ||
// need to use the gitversion from version.info.String() because minor version is not always Uint value | ||
// and patch version is not returned as a first class field | ||
semver, err := semver.Parse(strings.Split(strings.TrimPrefix(serverVersion.String(), "v"), "-")[0]) |
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.
Just a quick thought - the apimachinery util package has parsing functions available that output a struct, and methods on that struct for retrieving major/minor/patch fields as uints, so you wouldn't need to also convert the string representation to a uint later.
6fddfd1
to
1da2cb0
Compare
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.
/approve
we should consider using this for the minkubeversion as well, though I'm less concerned about updating that if it's going to be replaced with runtime constraints soon
"github.com/sirupsen/logrus" | ||
versionUtil "k8s.io/apimachinery/pkg/util/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.
supernit: usually lowercase module names?
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ecordell, kevinrizza The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
In some cases, the discovery client can return a kube server version with the minor version field as a non uint value. To properly parse the value and get all version fields correctly, instead directly parse the GitVersion string for all values of the kube server version
1da2cb0
to
f391ebb
Compare
/lgtm |
Fix an issue with the new catalog templating controller where it was incorrectly parsing the version field from discovery. Instead, directly use the gitVersion value to match the behavior for minKubeVersion requirement parsing.