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

Commit

Permalink
Use buildinfo.Version from tanzu framework
Browse files Browse the repository at this point in the history
Replaces using buildVersion ldflag

Signed-off-by: John McBride <[email protected]>
  • Loading branch information
jpmcb committed Nov 15, 2021
1 parent 8093787 commit 826324a
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ TANZU_FRAMEWORK_REPO_BRANCH ?= v0.10.0
TANZU_FRAMEWORK_REPO_HASH ?=
# TKG_DEFAULT_IMAGE_REPOSITORY override for using a different image repo
ifndef TKG_DEFAULT_IMAGE_REPOSITORY
TKG_DEFAULT_IMAGE_REPOSITORY ?= projects.registry.vmware.com/tkg
TKG_DEFAULT_IMAGE_REPOSITORY ?= projects-stg.registry.vmware.com/tkg
endif
FRAMEWORK_BUILD_VERSION=$$(cat "./hack/FRAMEWORK_BUILD_VERSION")

Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/plugin/conformance/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/vmware-tanzu/community-edition/cli/cmd/plugin/conformance
go 1.16

require (
github.com/spf13/cobra v1.2.1 // indirect
github.com/spf13/cobra v1.2.1
github.com/vmware-tanzu/sonobuoy v0.53.2
github.com/vmware-tanzu/tanzu-framework v0.10.0
k8s.io/klog/v2 v2.9.0 // indirect
Expand Down
27 changes: 14 additions & 13 deletions cli/cmd/plugin/conformance/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import (
"os"

conformance "github.com/vmware-tanzu/community-edition/cli/cmd/plugin/conformance/pkg"
"github.com/vmware-tanzu/tanzu-framework/pkg/v1/buildinfo"

cliv1alpha1 "github.com/vmware-tanzu/tanzu-framework/apis/cli/v1alpha1"
"github.com/vmware-tanzu/tanzu-framework/pkg/v1/cli"
"github.com/vmware-tanzu/tanzu-framework/pkg/v1/cli/command/plugin"
)

var descriptor = cliv1alpha1.PluginDescriptor{
Name: "conformance",
Description: "Run Sonobuoy conformance tests against clusters",
Group: cliv1alpha1.RunCmdGroup,
Version: cli.BuildVersion,
Version: buildinfo.Version,
}

var (
Expand All @@ -28,9 +28,10 @@ var (
var logLevel int32

func main() {
// if descriptor.Version == "" {
// descriptor.Version = defaultVersion
// }
if descriptor.Version == "" {
descriptor.Version = defaultVersion
}

// plugin!
p, err := plugin.NewPlugin(&descriptor)
if err != nil {
Expand All @@ -49,17 +50,17 @@ func main() {

// Remove the generated version command and replace it with ours,
// so we get more version information.
// c, _, err := p.Cmd.Find([]string{"version"})
c, _, err := p.Cmd.Find([]string{"version"})

// if err != nil {
// log.Fatalf("%v", err)
// }
if err != nil {
log.Fatalf("%v", err)
}

// p.Cmd.RemoveCommand(c)
p.Cmd.RemoveCommand(c)

// p.AddCommands(
// conformance.VersionCmd,
// )
p.AddCommands(
conformance.VersionCmd,
)

p.Cmd.PersistentFlags().Int32VarP(&logLevel, "verbose", "v", 0, "Number for the log level verbosity(0-9)")
if err := p.Execute(); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/plugin/diagnostics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/vmware-tanzu/community-edition/cli/cmd/plugin/diagnostics/pkg"
cliv1alpha1 "github.com/vmware-tanzu/tanzu-framework/apis/cli/v1alpha1"
"github.com/vmware-tanzu/tanzu-framework/pkg/v1/cli"
"github.com/vmware-tanzu/tanzu-framework/pkg/v1/buildinfo"
"github.com/vmware-tanzu/tanzu-framework/pkg/v1/cli/command/plugin"
)

Expand All @@ -19,7 +19,7 @@ var pluginDesc = cliv1alpha1.PluginDescriptor{
Description: "Cluster diagnostics",
Group: cliv1alpha1.RunCmdGroup,
Aliases: []string{"diag", "diags", "diagnostic"},
Version: cli.BuildVersion,
Version: buildinfo.Version,
}

var (
Expand Down
5 changes: 5 additions & 0 deletions cli/cmd/plugin/standalone-cluster/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ Warning - Standalone clusters will be deprecated in a future release of Tanzu Co
Create clusters without a dedicated management cluster`,
Group: cliv1alpha1.RunCmdGroup,

// Since standalone cluster is being deprecated, no changes are being made to it's dependencies,
// and cli.BuildVersion was deprecated in the build version of tanzu framework v0.10.0,
// we need to manually set the plugin version in order to compile
Version: "v0.9.1",
}

var (
Expand Down
6 changes: 3 additions & 3 deletions hack/builder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ SONO_VERSION := $(shell working_dir=`pwd`; cd ../../cli/cmd/plugin/conformance;

LD_FLAGS = -s -w
LD_FLAGS += -X "github.com/vmware-tanzu/tanzu-framework/pkg/v1/tkg/tkgconfigpaths.TKGDefaultImageRepo=$(TKG_DEFAULT_IMAGE_REPOSITORY)"
LD_FLAGS += -X "github.com/vmware-tanzu/tanzu-framework/pkg/v1/cli.BuildDate=$(BUILD_DATE)"
LD_FLAGS += -X "github.com/vmware-tanzu/tanzu-framework/pkg/v1/cli.BuildSHA=$(BUILD_SHA)"
LD_FLAGS += -X "github.com/vmware-tanzu/tanzu-framework/pkg/v1/cli.BuildVersion=$(BUILD_VERSION)"
LD_FLAGS += -X "github.com/vmware-tanzu/tanzu-framework/pkg/v1/buildinfo.Date=$(BUILD_DATE)"
LD_FLAGS += -X "github.com/vmware-tanzu/tanzu-framework/pkg/v1/buildinfo.SHA=$(BUILD_SHA)"
LD_FLAGS += -X "github.com/vmware-tanzu/tanzu-framework/pkg/v1/buildinfo.Version=$(BUILD_VERSION)"
LD_FLAGS += -X 'main.BuildEdition=$(BUILD_EDITION)'
LD_FLAGS += -X 'github.com/vmware-tanzu/tanzu-framework/pkg/v1/tkg/buildinfo.IsOfficialBuild=$(IS_OFFICIAL_BUILD)'

Expand Down
2 changes: 2 additions & 0 deletions hack/install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ rmdir /Q /S %TANZU_CACHE_DIR%

:: core
copy /B /Y bin\tanzu-plugin-builder.exe %PLUGIN_DIR%
copy /B /Y bin\tanzu-plugin-codegen.exe %PLUGIN_DIR%
copy /B /Y bin\tanzu-plugin-cluster.exe %PLUGIN_DIR%
copy /B /Y bin\tanzu-plugin-kubernetes-release.exe %PLUGIN_DIR%
copy /B /Y bin\tanzu-plugin-login.exe %PLUGIN_DIR%
copy /B /Y bin\tanzu-plugin-secret.exe %PLUGIN_DIR%
copy /B /Y bin\tanzu-plugin-management-cluster.exe %PLUGIN_DIR%
copy /B /Y bin\tanzu-plugin-pinniped-auth.exe %PLUGIN_DIR%
copy /B /Y bin\tanzu-plugin-package.exe %PLUGIN_DIR%
Expand Down
4 changes: 3 additions & 1 deletion hack/release/package-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ for env in ${ENVS}; do
cp -f "${ROOT_FRAMEWORK_ARTFACTS_DIR}/cluster/${FRAMEWORK_BUILD_VERSION}/tanzu-cluster-${binaryname}${extension}" "${PACKAGE_DIR}/bin/tanzu-plugin-cluster${extension}"
cp -f "${ROOT_FRAMEWORK_ARTFACTS_DIR}/kubernetes-release/${FRAMEWORK_BUILD_VERSION}/tanzu-kubernetes-release-${binaryname}${extension}" "${PACKAGE_DIR}/bin/tanzu-plugin-kubernetes-release${extension}"
cp -f "${ROOT_FRAMEWORK_ARTFACTS_DIR}/login/${FRAMEWORK_BUILD_VERSION}/tanzu-login-${binaryname}${extension}" "${PACKAGE_DIR}/bin/tanzu-plugin-login${extension}"
cp -f "${ROOT_FRAMEWORK_ARTFACTS_DIR}/secret/${FRAMEWORK_BUILD_VERSION}/tanzu-secret-${binaryname}${extension}" "${PACKAGE_DIR}/bin/tanzu-plugin-secret${extension}"
cp -f "${ROOT_FRAMEWORK_ARTFACTS_DIR}/package/${FRAMEWORK_BUILD_VERSION}/tanzu-package-${binaryname}${extension}" "${PACKAGE_DIR}/bin/tanzu-plugin-package${extension}"
cp -f "${ROOT_FRAMEWORK_ARTFACTS_DIR}/pinniped-auth/${FRAMEWORK_BUILD_VERSION}/tanzu-pinniped-auth-${binaryname}${extension}" "${PACKAGE_DIR}/bin/tanzu-plugin-pinniped-auth${extension}"
cp -f "${ROOT_FRAMEWORK_ARTFACTS_DIR}/management-cluster/${FRAMEWORK_BUILD_VERSION}/tanzu-management-cluster-${binaryname}${extension}" "${PACKAGE_DIR}/bin/tanzu-plugin-management-cluster${extension}"
cp -f "${ROOT_FRAMEWORK_ARTFACTS_ADMIN_DIR}/builder/${FRAMEWORK_BUILD_VERSION}/tanzu-builder-${binaryname}${extension}" "${PACKAGE_DIR}/bin/tanzu-plugin-builder${extension}"
cp -f "${ROOT_FRAMEWORK_ARTFACTS_ADMIN_DIR}/codegen/${FRAMEWORK_BUILD_VERSION}/tanzu-codegen-${binaryname}${extension}" "${PACKAGE_DIR}/bin/tanzu-plugin-codegen${extension}"

# TCE bits (New folder structure using tanzu-framework main)
cp -f "${ROOT_TCE_ARTIFACTS_DIR}/standalone-cluster/${TCE_BUILD_VERSION}/tanzu-standalone-cluster-${binaryname}${extension}" "${PACKAGE_DIR}/bin/tanzu-plugin-standalone-cluster${extension}"
cp -f "${ROOT_TCE_ARTIFACTS_DIR}/standalone-cluster/v0.9.1/tanzu-standalone-cluster-${binaryname}${extension}" "${PACKAGE_DIR}/bin/tanzu-plugin-standalone-cluster${extension}"
cp -f "${ROOT_TCE_ARTIFACTS_DIR}/conformance/${TCE_BUILD_VERSION}/tanzu-conformance-${binaryname}${extension}" "${PACKAGE_DIR}/bin/tanzu-plugin-conformance${extension}"
cp -f "${ROOT_TCE_ARTIFACTS_DIR}/diagnostics/${TCE_BUILD_VERSION}/tanzu-diagnostics-${binaryname}${extension}" "${PACKAGE_DIR}/bin/tanzu-plugin-diagnostics${extension}"

Expand Down

0 comments on commit 826324a

Please sign in to comment.