Skip to content

Commit

Permalink
Add Windows support (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
superbrothers authored Jul 20, 2020
1 parent a937afd commit d83aff7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
PLUGIN_NAME := kubectl-view_serviceaccount_kubeconfig
OUT_DIR := ./_out
OUTS := $(OUT_DIR)/linux-amd64/$(PLUGIN_NAME) $(OUT_DIR)/darwin-amd64/$(PLUGIN_NAME)
OUTS := $(OUT_DIR)/linux-amd64/$(PLUGIN_NAME) \
$(OUT_DIR)/darwin-amd64/$(PLUGIN_NAME) \
$(OUT_DIR)/windows-amd64/$(PLUGIN_NAME).exe
DIST_DIR := ./_dist
DISTS := $(DIST_DIR)/$(PLUGIN_NAME)-linux-amd64.zip $(DIST_DIR)/$(PLUGIN_NAME)-darwin-amd64.zip
DISTS := $(DIST_DIR)/$(PLUGIN_NAME)-linux-amd64.zip \
$(DIST_DIR)/$(PLUGIN_NAME)-darwin-amd64.zip \
$(DIST_DIR)/$(PLUGIN_NAME)-windows-amd64.zip
CHECKSUMS := $(DISTS:.zip=.zip.sha256)

GO := GO111MODULE=on go
Expand Down Expand Up @@ -31,6 +35,9 @@ test-dist: dist
$(OUT_DIR)/%-amd64/$(PLUGIN_NAME):
GOOS=$* GOARCH=amd64 $(GO) build -o $@ cmd/$(PLUGIN_NAME).go

$(OUT_DIR)/windows-amd64/$(PLUGIN_NAME).exe:
GOOS=windows GOARCH=amd64 $(GO) build -o $@ cmd/$(PLUGIN_NAME).go

$(DIST_DIR)/$(PLUGIN_NAME)-%-amd64.zip.sha256: $(DIST_DIR)/$(PLUGIN_NAME)-%-amd64.zip
shasum -a 256 "$^" | awk '{print $$1}' > "$@"

Expand All @@ -42,6 +49,14 @@ $(DIST_DIR)/$(PLUGIN_NAME)-%-amd64.zip: $(OUT_DIR)/%-amd64/$(PLUGIN_NAME)
zip -r ../../$@ * \
)

$(DIST_DIR)/$(PLUGIN_NAME)-windows-amd64.zip: $(OUT_DIR)/windows-amd64/$(PLUGIN_NAME).exe
( \
cd $(OUT_DIR)/windows-amd64/ && \
cp ../../LICENSE . && \
cp ../../README.md . && \
zip -r ../../$@ * \
)

$(DIST_DIR)/view-serviceaccount-kubeconfig.yaml: $(DISTS) $(CHECKSUMS)
./hack/generate-plugin-yaml.sh >"$@"

Expand Down
7 changes: 6 additions & 1 deletion hack/generate-plugin-yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ set -e -o pipefail; [[ -n "$DEBUG" ]] && set -x
VERSION="$(./hack/git-version.sh)"
DARWIN_SHA256="$(cat ./_dist/kubectl-view_serviceaccount_kubeconfig-darwin-amd64.zip.sha256)"
LINUX_SHA256="$(cat ./_dist/kubectl-view_serviceaccount_kubeconfig-linux-amd64.zip.sha256)"
WINDOWS_SHA256="$(cat ./_dist/kubectl-view_serviceaccount_kubeconfig-windows-amd64.zip.sha256)"

sed -e "s/VERSION/${VERSION}/g" -e "s/DARWIN_SHA256/${DARWIN_SHA256}/g" -e "s/LINUX_SHA256/${LINUX_SHA256}/g" ./hack/view-serviceaccount-kubeconfig.yaml
sed -e "s/VERSION/${VERSION}/g" \
-e "s/DARWIN_SHA256/${DARWIN_SHA256}/g" \
-e "s/LINUX_SHA256/${LINUX_SHA256}/g" \
-e "s/WINDOWS_SHA256/${WINDOWS_SHA256}/g" \
./hack/view-serviceaccount-kubeconfig.yaml
12 changes: 12 additions & 0 deletions hack/view-serviceaccount-kubeconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ spec:
matchLabels:
os: linux
arch: amd64
- uri: https://github.com/superbrothers/kubectl-view-serviceaccount-kubeconfig-plugin/releases/download/VERSION/kubectl-view_serviceaccount_kubeconfig-windows-amd64.zip
sha256: "WINDOWS_SHA256"
bin: kubectl-view_serviceaccount_kubeconfig.exe
files:
- from: kubectl-view_serviceaccount_kubeconfig.exe
to: .
- from: LICENSE
to: .
selector:
matchLabels:
os: windows
arch: amd64
version: "VERSION"
homepage: https://github.com/superbrothers/kubectl-view-serviceaccount-kubeconfig-plugin
shortDescription: Show a kubeconfig setting to access the apiserver with a specified serviceaccount.
Expand Down

0 comments on commit d83aff7

Please sign in to comment.