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

Commit

Permalink
Merge pull request #916 from laverya/include-some-dependency-versions
Browse files Browse the repository at this point in the history
include some vendored dependencies in ship version
  • Loading branch information
laverya committed Apr 19, 2019
2 parents 2253e8f + f22ebee commit 14db0e3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ DOCKER_REPO ?= replicated
VERSION_PACKAGE = github.com/replicatedhq/ship/pkg/version
VERSION ?=`git describe --tags`
DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
HELMV = v2.13.0
KUSTOMIZEV = v2.0.2
TERRAFORMV = v0.11.13

GIT_TREE = $(shell git rev-parse --is-inside-work-tree 2>/dev/null)
ifneq "$(GIT_TREE)" ""
Expand All @@ -36,6 +39,9 @@ define LDFLAGS
-X ${VERSION_PACKAGE}.version=${VERSION} \
-X ${VERSION_PACKAGE}.gitSHA=${GIT_SHA} \
-X ${VERSION_PACKAGE}.buildTime=${DATE} \
-X ${VERSION_PACKAGE}.helm=${HELMV} \
-X ${VERSION_PACKAGE}.kustomize=${KUSTOMIZEV} \
-X ${VERSION_PACKAGE}.terraform=${TERRAFORMV} \
"
endef

Expand Down
3 changes: 3 additions & 0 deletions deploy/.goreleaser.unstable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ builds:
-X github.com/replicatedhq/ship/pkg/version.version={{.Version}}
-X github.com/replicatedhq/ship/pkg/version.gitSHA={{.Commit}}
-X github.com/replicatedhq/ship/pkg/version.buildTime={{.Date}}
-X github.com/replicatedhq/ship/pkg/version.helm=v2.13.0
-X github.com/replicatedhq/ship/pkg/version.kustomize=v2.0.2
-X github.com/replicatedhq/ship/pkg/version.terraform=v0.11.13
-extldflags "-static"
flags: -tags netgo -installsuffix netgo
binary: ship
Expand Down
3 changes: 3 additions & 0 deletions deploy/.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ builds:
-X github.com/replicatedhq/ship/pkg/version.version={{.Version}}
-X github.com/replicatedhq/ship/pkg/version.gitSHA={{.Commit}}
-X github.com/replicatedhq/ship/pkg/version.buildTime={{.Date}}
-X github.com/replicatedhq/ship/pkg/version.helm=v2.13.0
-X github.com/replicatedhq/ship/pkg/version.kustomize=v2.0.2
-X github.com/replicatedhq/ship/pkg/version.terraform=v0.11.13
-extldflags "-static"
flags: -tags netgo -installsuffix netgo
binary: ship
Expand Down
1 change: 1 addition & 0 deletions pkg/version/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ package version

var (
version, gitSHA, buildTime string
helm, kustomize, terraform string
)
22 changes: 18 additions & 4 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ var (

// Build holds details about this build of the Ship binary
type Build struct {
Version string `json:"version,omitempty"`
GitSHA string `json:"git,omitempty"`
BuildTime time.Time `json:"buildTime,omitempty"`
TimeFallback string `json:"buildTimeFallback,omitempty"`
Version string `json:"version,omitempty"`
GitSHA string `json:"git,omitempty"`
BuildTime time.Time `json:"buildTime,omitempty"`
TimeFallback string `json:"buildTimeFallback,omitempty"`
Dependencies BuildDependencies `json:"dependencies,omitempty"`
}

type BuildDependencies struct {
Helm string `json:"helm,omitempty"`
Kustomize string `json:"kustomize,omitempty"`
Terraform string `json:"terraform,omitempty"`
}

// Init sets up the version info from build args
Expand All @@ -25,6 +32,13 @@ func Init() {
if err != nil {
build.TimeFallback = buildTime
}

deps := BuildDependencies{
Helm: helm,
Kustomize: kustomize,
Terraform: terraform,
}
build.Dependencies = deps
}

// GetBuild gets the build
Expand Down

0 comments on commit 14db0e3

Please sign in to comment.