Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Provide automatic buildinfo for plugins #3261

Merged
merged 1 commit into from
Sep 2, 2022

Conversation

marckhouzam
Copy link
Contributor

What this PR does / why we need it

This is kind of a follow-up of the refactoring of #3201.
The PR simply copies pkg/v1/buildinfo/buildvar.go to a new cli/runtime/buildinfo package.
This will allow plugins to get access to buildinfo.Version, buildinfo.SHA and buildinfo.Date without having to import Framework.

The PR also updates the Makefile.tmpl template to inject those values and the main.go.tmpl to use this mechanism for new plugins.

Which issue(s) this PR fixes

Fixes #3230

Describe testing done for PR

Created a new plugin and built it and verified that Version and SHA were injected automatically:

tanzu builder init myplugin --repo-type github
cd myplugin
tanzu builder cli add-plugin myplugin --description myplugin
git add .
git commit -m start
make init || true

# point the go.mod to my local Framework repo
echo "replace github.com/vmware-tanzu/tanzu-framework/cli/runtime => /Users/$USER/git/tanzu-framework/cli/runtime" >> go.mod
go mod tidy -compat=1.17
make build-local

# Call the built binary which depends on your machine arch and os
artifacts/darwin/arm64/cli/myplugin/v0.0.1/tanzu-myplugin-darwin_arm64 info

# Check that the Version and SHA are set properly

Release note

Additional information

We would need some doc to teach this to plugin developers. I can add it once #3259 is merged.

Fixes vmware-tanzu#3230

Signed-off-by: Marc Khouzam <kmarc@vmware.com>
@marckhouzam marckhouzam requested a review from a team as a code owner September 2, 2022 17:51
Copy link
Member

@rajathagasthya rajathagasthya left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@rajathagasthya rajathagasthya added the ok-to-merge PRs should be labelled with this before merging label Sep 2, 2022
@rajathagasthya
Copy link
Member

Looks like build/test is failing. Good to merge after that's addressed.

Copy link
Contributor

@anujc25 anujc25 left a comment

Choose a reason for hiding this comment

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

Thanks for this change. LGTM

@codecov
Copy link

codecov bot commented Sep 2, 2022

Codecov Report

Merging #3261 (407977d) into main (254f018) will decrease coverage by 0.03%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #3261      +/-   ##
==========================================
- Coverage   45.82%   45.78%   -0.04%     
==========================================
  Files         361      361              
  Lines       37642    37642              
==========================================
- Hits        17249    17235      -14     
- Misses      18820    18829       +9     
- Partials     1573     1578       +5     
Impacted Files Coverage Δ
pkg/v1/tkg/tkgpackageclient/package_update.go 83.57% <0.00%> (-1.43%) ⬇️
addons/controllers/clusterbootstrap_controller.go 63.90% <0.00%> (-1.06%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@marckhouzam marckhouzam merged commit 833477e into vmware-tanzu:main Sep 2, 2022
@marckhouzam marckhouzam deleted the feat/pluginBuildInfo branch September 2, 2022 21:28
marckhouzam added a commit to marckhouzam/tanzu-framework that referenced this pull request Sep 14, 2022
Follow-up to vmware-tanzu#3261

Signed-off-by: Marc Khouzam <kmarc@vmware.com>
marckhouzam added a commit that referenced this pull request Sep 14, 2022
Follow-up to #3261

Signed-off-by: Marc Khouzam <kmarc@vmware.com>
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
cla-not-required ok-to-merge PRs should be labelled with this before merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CLI Integration Library] Provide a buildinfo system
4 participants