Skip to content

Commit

Permalink
chore: Add additional field to set Extra Build Information while buil…
Browse files Browse the repository at this point in the history
…ding argo-cd by vendors (argoproj#13324)

* Add additonal field to set Extra Build Information while building argocd by vendors

Signed-off-by: ishitasequeira <[email protected]>

* Include spaces in extra build info

Signed-off-by: ishitasequeira <[email protected]>

* Address comments

Signed-off-by: ishitasequeira <[email protected]>

---------

Signed-off-by: ishitasequeira <[email protected]>
  • Loading branch information
ishitasequeira authored Apr 27, 2023
1 parent daae5ef commit 1fe6257
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 27 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ override LDFLAGS += \
-X ${PACKAGE}.buildDate=${BUILD_DATE} \
-X ${PACKAGE}.gitCommit=${GIT_COMMIT} \
-X ${PACKAGE}.gitTreeState=${GIT_TREE_STATE}\
-X ${PACKAGE}.kubectlVersion=${KUBECTL_VERSION}
-X ${PACKAGE}.kubectlVersion=${KUBECTL_VERSION}\
-X "${PACKAGE}.extraBuildInfo=${EXTRA_BUILD_INFO}"

ifeq (${STATIC_BUILD}, true)
override LDFLAGS += -extldflags "-static"
Expand Down
3 changes: 3 additions & 0 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -8653,6 +8653,9 @@
"Compiler": {
"type": "string"
},
"ExtraBuildInfo": {
"type": "string"
},
"GitCommit": {
"type": "string"
},
Expand Down
6 changes: 6 additions & 0 deletions cmd/argocd/commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ func printClientVersion(version *common.Version, short bool) string {
output += fmt.Sprintf(" GoVersion: %s\n", version.GoVersion)
output += fmt.Sprintf(" Compiler: %s\n", version.Compiler)
output += fmt.Sprintf(" Platform: %s\n", version.Platform)
if version.ExtraBuildInfo != "" {
output += fmt.Sprintf(" ExtraBuildInfo: %s\n", version.ExtraBuildInfo)
}
return output
}

Expand Down Expand Up @@ -147,6 +150,9 @@ func printServerVersion(version *version.VersionMessage, short bool) string {
if version.Platform != "" {
output += fmt.Sprintf(" Platform: %s\n", version.Platform)
}
if version.ExtraBuildInfo != "" {
output += fmt.Sprintf(" ExtraBuildInfo: %s\n", version.ExtraBuildInfo)
}
if version.KustomizeVersion != "" {
output += fmt.Sprintf(" Kustomize Version: %s\n", version.KustomizeVersion)
}
Expand Down
4 changes: 4 additions & 0 deletions common/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var (
gitTag = "" // output from `git describe --exact-match --tags HEAD` (if clean tree state)
gitTreeState = "" // determined from `git status --porcelain`. either 'clean' or 'dirty'
kubectlVersion = "" // determined from go.mod file
extraBuildInfo = "" // extra build information for vendors to populate during build
)

// Version contains Argo version information
Expand All @@ -29,6 +30,7 @@ type Version struct {
Compiler string
Platform string
KubectlVersion string
ExtraBuildInfo string
}

func (v Version) String() string {
Expand Down Expand Up @@ -66,6 +68,7 @@ func GetVersion() Version {
versionStr += "+unknown"
}
}

return Version{
Version: versionStr,
BuildDate: buildDate,
Expand All @@ -76,5 +79,6 @@ func GetVersion() Version {
Compiler: runtime.Compiler,
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
KubectlVersion: kubectlVersion,
ExtraBuildInfo: extraBuildInfo,
}
}
104 changes: 78 additions & 26 deletions pkg/apiclient/version/version.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions server/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package version

import (
"context"

"github.com/golang/protobuf/ptypes/empty"
"github.com/google/go-jsonnet"

Expand Down Expand Up @@ -67,6 +68,7 @@ func (s *Server) Version(ctx context.Context, _ *empty.Empty) (*version.VersionM
HelmVersion: s.helmVersion,
JsonnetVersion: s.jsonnetVersion,
KubectlVersion: vers.KubectlVersion,
ExtraBuildInfo: vers.ExtraBuildInfo,
}, nil
}

Expand Down
1 change: 1 addition & 0 deletions server/version/version.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ message VersionMessage {
string HelmVersion = 11;
string KubectlVersion = 12;
string JsonnetVersion = 13;
string ExtraBuildInfo = 14;
}

// VersionService returns the version of the API server.
Expand Down
3 changes: 3 additions & 0 deletions util/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ func NewVersionCmd(cliName string) *cobra.Command {
fmt.Printf(" GoVersion: %s\n", version.GoVersion)
fmt.Printf(" Compiler: %s\n", version.Compiler)
fmt.Printf(" Platform: %s\n", version.Platform)
if version.ExtraBuildInfo != "" {
fmt.Printf(" ExtraBuildInfo: %s\n", version.ExtraBuildInfo)
}
},
}
versionCmd.Flags().BoolVar(&short, "short", false, "print just the version number")
Expand Down

0 comments on commit 1fe6257

Please sign in to comment.