diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6fe3aa10..39650d03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,10 +13,10 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: 1.15.7 + go-version: 1.16 - run: go version - run: make get-bats - name: build - run: make cross-compile + run: make compile-releases - name: test run: make integration-tests diff --git a/Makefile b/Makefile index 3eae270c..579dfe07 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,38 @@ APP_NAME := vsh -PLATFORMS := linux darwin -ARCHS := 386 amd64 +SUPPORTED_PLATFORMS := linux darwin +SUPPORTED_ARCHS := amd64 arm64 VERSION := $(shell git describe --tags --always --dirty) +UNAME_M := $(shell uname -m) +ARCH := $(UNAME_M) +ifeq ($(UNAME_M),x86_64) + ARCH=amd64 +endif +ifneq ($(filter %86,$(UNAME_M)),) + ARCH=386 +endif +ifneq ($(filter arm%,$(UNAME_M)),) + ARCH=arm +endif +ifneq ($(filter $(UNAME_M),arm64 aarch64 armv8b armv8l),) + ARCH=arm64 +endif + help: ## Prints help for targets with comments @grep -E '^[a-zA-Z0-9.\ _-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' -cross-compile: clean ## Compile vsh binaries for multiple platforms and architectures +compile-releases: clean ## Compile vsh binaries for multiple platforms and architectures strictly using vendor directory mkdir -p ./build/ - for GOOS in $(PLATFORMS); do \ - for GOARCH in $(ARCHS); do \ + for GOOS in $(SUPPORTED_PLATFORMS); do \ + for GOARCH in $(SUPPORTED_ARCHS); do \ GOOS=$$GOOS GOARCH=$$GOARCH \ - go build -ldflags "-X main.vshVersion=$(VERSION)" -o build/${APP_NAME}_$${GOOS}_$${GOARCH}; \ + go build -mod vendor -ldflags "-X main.vshVersion=$(VERSION)" -o build/${APP_NAME}_$${GOOS}_$${GOARCH}; \ done \ done - ls build/ + cd build/ && sha256sum * > SHA256SUM compile: clean ## Compile vsh for platform based on uname - go build -ldflags "-X main.vshVersion=$(VERSION)" -o build/${APP_NAME}_$(shell uname | tr '[:upper:]' '[:lower:]')_amd64 + go build -ldflags "-X main.vshVersion=$(VERSION)" -o build/${APP_NAME}_$(shell uname | tr '[:upper:]' '[:lower:]')_$(ARCH) get-bats: ## Download bats dependencies to test directory rm -rf test/bin/ @@ -43,5 +58,7 @@ clean: ## Remove builds and vsh related docker containers docker rm -f vsh-integration-test-vault || true rm ./build/* || true +.PHONY: vendor vendor: ## synch dependencies in vendor/ directory + go mod tidy go mod vendor diff --git a/README.md b/README.md index e2758275..b6ebd281 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ Contributions in any form are always welcome! Without contributions from the com Requirements: -- `golang` (compiled and tested with `v1.15.7`) +- `golang` (compiled and tested with `v1.16`) - `docker` for integration testing - `make` for simplified commands diff --git a/go.mod b/go.mod index 5fc3a303..3e84b557 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,6 @@ require ( github.com/hashicorp/vault v1.3.3 github.com/hashicorp/vault/api v1.0.5-0.20200117231345-460d63e36490 github.com/logrusorgru/aurora v0.0.0-20190803045625-94edacc10f9b - github.com/mattn/go-runewidth v0.0.4 // indirect github.com/mattn/go-tty v0.0.0-20190424173100-523744f04859 // indirect github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942 // indirect github.com/sergi/go-diff v1.1.0 // indirect diff --git a/go.sum b/go.sum index 41f62fd0..d530338f 100644 --- a/go.sum +++ b/go.sum @@ -89,7 +89,9 @@ github.com/centrify/cloud-golang-sdk v0.0.0-20190214225812-119110094d0f h1:gJzxr github.com/centrify/cloud-golang-sdk v0.0.0-20190214225812-119110094d0f/go.mod h1:C0rtzmGXgN78pYR0tGJFhtHgkbAs0lIbHwkB81VxDQE= github.com/chrismalek/oktasdk-go v0.0.0-20181212195951-3430665dfaa0 h1:CWU8piLyqoi9qXEUwzOh5KFKGgmSU5ZhktJyYcq6ryQ= github.com/chrismalek/oktasdk-go v0.0.0-20181212195951-3430665dfaa0/go.mod h1:5d8DqS60xkj9k3aXfL3+mXBH0DPYO0FQjcKosxl+b/Q= +github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible h1:C29Ae4G5GtYyYMm1aztcyj/J5ckgJm2zwdDajFbx1NY= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= @@ -577,6 +579,7 @@ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoH github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -752,6 +755,7 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -773,6 +777,7 @@ gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bl gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= diff --git a/test/util/util.bash b/test/util/util.bash index 4339388e..4c96b932 100755 --- a/test/util/util.bash +++ b/test/util/util.bash @@ -10,7 +10,20 @@ export VAULT_ADDR="http://localhost:${VAULT_HOST_PORT}" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" export DIR UNAME=$(uname | tr '[:upper:]' '[:lower:]') -export APP_BIN="${DIR}/../../build/vsh_${UNAME}_amd64" +case "$(uname -m)" in + x86_64) + ARCH=amd64 ;; + arm64|aarch64|armv8b|armv8l) + ARCH=arm64 ;; + arm*) + ARCH=arm ;; + i386|i686) + ARCH=386 ;; + *) + ARCH=$(uname -m) ;; +esac +export ARCH +export APP_BIN="${DIR}/../../build/vsh_${UNAME}_${ARCH}" export NO_VALUE_FOUND="No value found at" setup() {