Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 99d160e

Browse files
committed
fix: update ibmcloud plugin compilation to use client version
This PR also adds a Makefile to facilitate builds. Fixes #4359
1 parent 143b7e3 commit 99d160e

File tree

8 files changed

+83
-18
lines changed

8 files changed

+83
-18
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ after_script: if [ -n "$NYC" ]; then cd "${TRAVIS_BUILD_DIR}" && ./tools/codecov
3939
install:
4040
- if [ -n "$NEEDS_K8S" ]; then ./tools/travis/microk8s.sh & k8s=$!; fi
4141
- npm ci
42+
- if [ -n "$NEEDS_IBMCLOUD" ]; then ./tools/travis/ibmcloud.sh && ./tools/travis/ibmcloud-plugin-build-install.sh; fi
4243
- ./bin/switch-client.sh ${CLIENT-default}
4344
- ./tools/codecov/instrument.sh
4445
- if [ "$MOCHA_RUN_TARGET" = "webpack" ]; then export KUI_USE_PROXY=true; if [ "$DEPLOY" = "cluster" ]; then npx kui-build-webpack && npx kui-build-docker-with-proxy && (kui-run-cproxy &); else npm run watch:webpack; fi; elif [ -z "$TEST_FROM_BUILD" ]; then npm run watch:electron; else npm run build:electron:$TRAVIS_OS_NAME; fi
@@ -54,8 +55,7 @@ jobs:
5455

5556
include:
5657
- env: DEPLOY="cluster" LAYERS="core" MOCHA_RUN_TARGET=webpack
57-
- env: LAYERS="k8s k8s-popup helm logs" NEEDS_K8S=true NEEDS_HELM=true TEST_FROM_BUILD="${TRAVIS_BUILD_DIR}/dist/electron/Kui-linux-x64/Kui" KUI_DIST_PATH=${TEST_FROM_BUILD}
58-
before_install: ./tools/travis/ibmcloud.sh; ./tools/travis/ibmcloud-plugin-build-install.sh
58+
- env: LAYERS="k8s k8s-popup helm logs" NEEDS_K8S=true NEEDS_HELM=true TEST_FROM_BUILD="${TRAVIS_BUILD_DIR}/dist/electron/Kui-linux-x64/Kui" KUI_DIST_PATH=${TEST_FROM_BUILD} NEEDS_IBMCLOUD=true
5959

6060
- env: LAYERS=k8s1 MOCHA_RUN_TARGET=webpack NEEDS_K8S=true NEEDS_OC=true
6161
- env: LAYERS=k8s2 MOCHA_RUN_TARGET=webpack NEEDS_K8S=true NEEDS_OC=true NEEDS_TOP=true

tools/go/ibmcloud/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ bin/node_modules/*
2222

2323
# local testing binaries
2424
kui
25+
kui-ibmcloud-plugin*

tools/go/ibmcloud/Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
BINARY=kui-ibmcloud-plugin
2+
3+
PLATFORMS=darwin linux windows
4+
ARCHITECTURES=amd64
5+
6+
VERSION=$(shell node -e 'console.log(require("@kui-shell/client/package.json").version)')
7+
LDFLAGS=-ldflags "-X github.com/IBM/kui/launcher.PLUGIN_VERSION=$(VERSION)"
8+
9+
all: clean build
10+
11+
# build for current platform
12+
build: main.go launcher/launcher.go
13+
go build ${LDFLAGS} -o ${BINARY}
14+
15+
# build for all platforms and architectures
16+
build_all:
17+
$(foreach GOOS, $(PLATFORMS),\
18+
$(foreach GOARCH, $(ARCHITECTURES), $(shell export GOOS=$(GOOS); export GOARCH=$(GOARCH); go build ${LDFLAGS} -o $(BINARY)-$(GOOS)-$(GOARCH))))
19+
20+
# install as ibmcloud plugin
21+
install: build
22+
ibmcloud plugin install ${BINARY}
23+
24+
test: all
25+
go test ./... ${LDFLAGS}
26+
27+
clean:
28+
rm -f ${BINARY}
29+
$(foreach GOOS, $(PLATFORMS),\
30+
$(foreach GOARCH, $(ARCHITECTURES), rm -f $(BINARY)-$(GOOS)-$(GOARCH)))

tools/go/ibmcloud/README.md

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,48 @@
1-
# IBMCloud CLI Plugin for Kui
1+
# ibmcloud CLI Plugin for Kui
22

3-
## Getting Started
3+
This directory offers Kui as a plugin to the [`ibmcloud` CLI](https://clis.ng.bluemix.net).
44

5-
Download and install the Bluemix CLI. See instructions [here](https://clis.ng.bluemix.net).
5+
## Prebuilt Binaries
66

7-
To build the plugin, you firstly need [Go](http://www.golang.org) (1.12+) installed on your
8-
machine. Next, compile the plugin source code with `go build` command, for example
7+
> Coming Soon
8+
9+
## Usage
10+
11+
For example:
912

1013
```bash
11-
$ go build
14+
ibmcloud kui kubectl get pods
1215
```
1316

14-
Install the plugin:
17+
## Building the Plugin Yourself
18+
19+
If you wish to develop the plugin, first
20+
download and install the Bluemix CLI. See instructions [here](https://clis.ng.bluemix.net).
21+
22+
The plugin is written in [go](https://golang.org/), and depends on go
23+
1.12+. To compile the plugin, you may leverage the Makefile:
1524

1625
```bash
17-
$ ibmcloud plugin install ./kui
26+
$ make
1827
```
1928

20-
Use the plugin:
29+
This should produce a binary `kui-ibmcloud-plugin`. You may then
30+
install the plugin:
2131

22-
For example:
32+
```bash
33+
$ make install
34+
```
35+
36+
To run unit tests:
2337

2438
```bash
25-
ibmcloud kui kubectl get pods
39+
$ make test
40+
```
41+
42+
### Building for multiple platforms
43+
44+
If you wish to build for all supported Electron platforms, you may leverage the
45+
46+
```bash
47+
$ make build_all
2648
```

tools/go/ibmcloud/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
github.com/nicksnyder/go-i18n v1.10.1
1717
github.com/nwaples/rardecode v1.1.0 // indirect
1818
github.com/pierrec/lz4 v2.5.1+incompatible // indirect
19+
github.com/stretchr/testify v1.5.1
1920
github.com/ulikunitz/xz v0.5.7 // indirect
2021
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
2122
golang.org/x/crypto v0.0.0-20200420104511-884d27f42877 // indirect

tools/go/ibmcloud/go.sum

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.4.0 h1:gCN1sOP5aCjHOgWlNK3buvZTl91GxCz
44
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.4.0/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
55
github.com/cloudfoundry-attic/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 h1:Yg2hDs4b13Evkpj42FU2idX2cVXVFqQSheXYKM86Qsk=
66
github.com/cloudfoundry-attic/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21/go.mod h1:MgJyK38wkzZbiZSKeIeFankxxSA8gayko/nr5x5bgBA=
7+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
8+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
79
github.com/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q=
810
github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5JflhBbQEHo=
911
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
@@ -35,6 +37,11 @@ github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181
3537
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
3638
github.com/pierrec/lz4 v2.5.1+incompatible h1:Yq0up0149Hh5Ekhm/91lgkZuD1ZDnXNM26bycpTzYBM=
3739
github.com/pierrec/lz4 v2.5.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
40+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
41+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
42+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
43+
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
44+
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
3845
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
3946
github.com/ulikunitz/xz v0.5.7 h1:YvTNdFzX6+W5m9msiYg/zpkSURPPtOlzbqYjrFn7Yt4=
4047
github.com/ulikunitz/xz v0.5.7/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
@@ -57,3 +64,5 @@ gopkg.in/cheggaaa/pb.v1 v1.0.28 h1:n1tBJnnK2r7g9OW2btFH91V92STTUevLXYFb8gy9EMk=
5764
gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
5865
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
5966
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
67+
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
68+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

tools/go/ibmcloud/launcher/launcher.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ type CloudShellPlugin struct {
2121
ui terminal.UI
2222
}
2323

24-
// THE PLUGIN_VERSION CONSTANT SHOULD BE LEFT EXACTLY AS-IS SINCE IT CAN BE PROGRAMMATICALLY SUBSTITUTED
25-
const PLUGIN_VERSION = "8.4.3"
24+
// this value will be injected at build time, e.g. via
25+
// go build -ldflags "-X github.com/IBM/kui/launcher.PLUGIN_VERSION=$(node -e 'console.log(require("@kui-shell/client/package.json").version)')"
26+
// which pulls the version from @kui-shell/client/package.json
27+
var PLUGIN_VERSION string
2628

2729
func Start() {
2830
argsWithoutProg := os.Args[1:]

tools/travis/ibmcloud-plugin-build-install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ echo "Installing Go Stable"
66
eval "$(gimme stable)";
77

88
echo "Building ibmcloud kui binary"
9-
go build
9+
make
1010

1111
echo "Installing ibmcloud kui plugin"
12-
ibmcloud plugin install ./kui
12+
make install
1313

1414
echo "Testing Kui dist download and duplicate download"
15-
go test ./...
15+
make test

0 commit comments

Comments
 (0)