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

Update versions information in HostAgent binary #454

Merged

Conversation

sachinkumarsingh092
Copy link
Contributor

What this PR does / why we need it:
The version flag in the host agent binary displays the major, minor and patch versions.
This PR introduces the following flags, similar to kubectl or clusterctl, and removes the patch field from version information.

$ ./bin/byoh-hostagent-linux-amd64 --version
byoh-hostagent version: version.Info{Major:"0", Minor:"1", GitVersion:"v0.1.0-79-42e700c78428bb-dirty", GitCommit:"42e700c78428bb4c2096a85f5641565375d666d0", GitTreeState:"dirty", BuildDate:"2022-03-23T12:29:43Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"}

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #436

Additional information
Changes:

  • .github/workflows/draft-release.yaml: Now we extract version from the hack/version.sh script so no need for AGENT_BINARY_VERSION.
  • Makefile: Now we use ldflags that are generated from the version.sh script.
  • agent/host_agent_test.go: Tests for the agent version are changed according to the new format.
  • agent/version/version.go: All the new required fields are introduced. We take the values of these fields from the variables generated by ldflags during building the binary.
  • agent/version/version_test.go: The tests for version.go. We build a fake binary and check its version info based on the given ldflags and compare these values. Due to the overhead of building and testing continuously, only 2 corner cases are checked which should suffice for all the cases.
  • hack/version.sh: The script with all the logic to assign values for the different fields in the ldflags. It uses git describe to extract all the information required for different fields. This is taken form sigs.k8s.io/cluster-api/hack/version.sh.

Special notes for your reviewer

@codecov-commenter
Copy link

codecov-commenter commented Mar 24, 2022

Codecov Report

Merging #454 (06f7ef6) into main (1e2520f) will decrease coverage by 0.50%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #454      +/-   ##
==========================================
- Coverage   67.69%   67.19%   -0.51%     
==========================================
  Files          23       22       -1     
  Lines        1746     1719      -27     
==========================================
- Hits         1182     1155      -27     
  Misses        492      492              
  Partials       72       72              
Impacted Files Coverage Δ
agent/installer/installer.go 78.10% <0.00%> (ø)
agent/installer/bundle_downloader.go 69.66% <0.00%> (ø)
agent/version/version.go

@anusha94
Copy link
Contributor

sachinkumarsingh092 and others added 2 commits March 24, 2022 10:00
Signed-off-by: Anusha Hegde <[email protected]>
Signed-off-by: Sachin Singh <[email protected]>
@anusha94
Copy link
Contributor

  • Removing version_test and suite because all the logic is now moved to hack/version.sh
  • we have one integration test in host agent to verify ldflags on the binary

For the new test, we match the script generated values and locally
created git values.
agent/host_agent_test.go Outdated Show resolved Hide resolved
agent/host_agent_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@anusha94 anusha94 left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Contributor

@dharmjit dharmjit left a comment

Choose a reason for hiding this comment

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

lgtm

@sachinkumarsingh092 sachinkumarsingh092 merged commit b17b4f0 into vmware-tanzu:main Mar 31, 2022
@sachinkumarsingh092 sachinkumarsingh092 deleted the version-hostagent-bin branch March 31, 2022 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update version information in HostAgent binary
6 participants