Skip to content

Commit 85d7574

Browse files
John Liuguangbochen
John Liu
authored andcommitted
Show harvester version on console dashboard
* Add a new version variable `HarvesterVersion` to store version of harvester. Console dashboard shows this version, instead of the installer version. * Add a new script `version-harvester` to determine and set up `HARVESTER_VERSION` variable for later use. * Update script `version`: Unset variable `DIRTY` in case it was set somewhere else. * Update script `build`: - Pull harvester source from github if not exists. This will happen if we're calling `make` from harvester-installer, but not from calling `make build-iso` from harvester. - Source "version-harvester" script to get the version of harvester. - Update both harvester and harvester-installer version variables using ldflags, `HarvesterVersion` and `Version` respectively. Tested by calling `make` from harvester-installer and `make build-iso` from harvester.
1 parent 68c789d commit 85d7574

File tree

6 files changed

+25
-4
lines changed

6 files changed

+25
-4
lines changed

pkg/console/dashboard_panels.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func logoPanel(g *gocui.Gui) error {
9898
}
9999
v.Frame = false
100100
fmt.Fprintf(v, logo)
101-
versionStr := "version: " + version.Version
101+
versionStr := "version: " + version.HarvesterVersion
102102
logoLength := 74
103103
nSpace := logoLength - len(versionStr)
104104
fmt.Fprintf(v, "\n%*s", nSpace, "")

pkg/version/version.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package version
22

33
var (
4-
Version = "dev"
4+
Version = "dev"
5+
HarvesterVersion = "dev" // Will be replaced by ldflags
56
)

scripts/build

+17-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,28 @@ TOP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )"
55
SCRIPTS_DIR="${TOP_DIR}/scripts"
66
PACKAGE_HARVESTER_OS_DIR="${TOP_DIR}/package/harvester-os"
77

8+
cd ${TOP_DIR}
9+
10+
# Pull harvester source and determine harvester version
11+
harvester_path=../harvester
12+
if [ ! -d ${harvester_path} ];then
13+
echo "No existed harvester source. Pulling..."
14+
git clone --branch master --single-branch --depth 1 https://github.com/harvester/harvester.git ../harvester
15+
fi
16+
17+
source ${SCRIPTS_DIR}/version-harvester $harvester_path
818
source ${SCRIPTS_DIR}/version-rke2
19+
source ${SCRIPTS_DIR}/version
920

10-
cd ${TOP_DIR}
21+
echo "Harvester version: ${HARVESTER_VERSION}"
22+
echo "Installer version: ${VERSION}"
1123

1224
mkdir -p bin
1325

14-
LINKFLAGS="-X github.com/harvester/harvester-installer/pkg/config.RKE2Version=$RKE2_VERSION $LINKFLAGS"
26+
LINKFLAGS="-X github.com/harvester/harvester-installer/pkg/config.RKE2Version=$RKE2_VERSION
27+
-X github.com/harvester/harvester-installer/pkg/version.Version=$VERSION
28+
-X github.com/harvester/harvester-installer/pkg/version.HarvesterVersion=$HARVESTER_VERSION
29+
$LINKFLAGS"
1530

1631
if [ "$(uname)" = "Linux" ]; then
1732
OTHER_LINKFLAGS="-extldflags -static -s"

scripts/build-bundle

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ get_url()
6868
# Prepare Harvester chart
6969
harvester_path=../harvester
7070
if [ ! -d ${harvester_path} ];then
71+
echo "No existed harvester source. Pulling into /tmp/harvester"
7172
git clone --branch master --single-branch --depth 1 https://github.com/harvester/harvester.git /tmp/harvester
7273
harvester_path=/tmp/harvester
7374
fi

scripts/version

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22

3+
unset DIRTY
34
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
45
DIRTY="-dirty"
56
fi

scripts/version-harvester

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
HARVESTER_VERSION=$(cd $1; source ./scripts/version &> /dev/null; echo $VERSION)

0 commit comments

Comments
 (0)