From a49f8c4f7792b69bf5afd20ca21c0863121182bc Mon Sep 17 00:00:00 2001 From: Shane Utt Date: Mon, 12 Jul 2021 16:03:53 -0400 Subject: [PATCH] fix: script and README.md cleanup This patch makes several fixes to the script, moves the ktf main.go for better "go install" support, and cleans up the README.md in preparation for the first release. --- .gitignore | 2 +- Makefile | 2 +- README.md | 10 +++++++++- main.go => cmd/ktf/main.go | 0 docs/install.sh | 14 ++++++++------ 5 files changed, 19 insertions(+), 9 deletions(-) rename main.go => cmd/ktf/main.go (100%) diff --git a/.gitignore b/.gitignore index 8ed686fb..c23082cc 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ *.dll *.so *.dylib -ktf* +./ktf* # Test binary, built with `go test -c` *.test diff --git a/Makefile b/Makefile index 8c82ffa4..9b442408 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ clean: .PHONY: build build: - GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o ktf.$(GOOS).$(GOARCH) main.go + GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o ktf.$(GOOS).$(GOARCH) cmd/ktf/main.go .PHONY: test test: test.unit diff --git a/README.md b/README.md index cb9f78e4..9fae4873 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,16 @@ This project provides a command line tool `ktf` which can be used for reason suc ### Install +If you have [Golang](https://go.dev) installed locally you can install with `go`: + +```shell +$ go install github.com/kong/kubernetes-testing-framework/cmd/ktf@latest +``` + +Otherwise you can use the shell script to install the latest release for your operating system: + ```shell -$ curl --proto '=https' --tls1.2 -sSf https://kong.github.io/kubernetes-testing-framework/install.sh | sh +$ curl --proto '=https' -sSf https://kong.github.io/kubernetes-testing-framework/install.sh | sh ``` ### Testing Environments diff --git a/main.go b/cmd/ktf/main.go similarity index 100% rename from main.go rename to cmd/ktf/main.go diff --git a/docs/install.sh b/docs/install.sh index e09f0cbe..9bec2a79 100755 --- a/docs/install.sh +++ b/docs/install.sh @@ -42,7 +42,7 @@ fi # Determine Latest Release # ------------------------------------------------------------------------------ -LATEST_RELEASE=$(curl -s https://api.github.com/repos/${BASE}/releases/latest | perl -ne 'print $1 if m{"name": "(.*)"}') +LATEST_RELEASE=$(curl -s https://api.github.com/repos/${BASE}/releases/latest | perl -ne 'print $1 if m{"name": "(v[0-9]+\.[0-9]+\.[0-9]+.*)"}') if [ "$LATEST_RELEASE" = "" ]; then echo "Error: could not find latest release for ${BASE}!${LATEST_RELEASE}" @@ -60,18 +60,18 @@ DOWNLOAD_CHECKSUMS_URL="https://github.com/${BASE}/releases/download/${LATEST_RE TEMPDIR=$(mktemp -d) echo "INFO: downloading ktf cli for ${OSTYPE}/${ARCH}" -curl --proto '=https' --tlsv1.2 -sSf ${DOWNLOAD_URL} > ${TEMPDIR}/ktf.${OSTYPE}.${ARCH} +curl -L --proto '=https' --tlsv1.2 -sSf ${DOWNLOAD_URL} > ${TEMPDIR}/ktf.${OSTYPE}.${ARCH} echo "INFO: downloading checksums for release ${LATEST_RELEASE}" -curl --proto '=https' --tlsv1.2 -sSf ${DOWNLOAD_CHECKSUMS_URL} > ${TEMPDIR}/CHECKSUMS +curl -L --proto '=https' --tlsv1.2 -sSf ${DOWNLOAD_CHECKSUMS_URL} > ${TEMPDIR}/CHECKSUMS # ------------------------------------------------------------------------------ # Checksum Verification # ------------------------------------------------------------------------------ -pushd ${TEMPDIR} -sha256sum -c CHECKSUM --ignore-missing -popd +pushd ${TEMPDIR} 1>/dev/null +sha256sum -c CHECKSUMS --ignore-missing 1>/dev/null +popd 1>/dev/null # ------------------------------------------------------------------------------ # Installation @@ -90,3 +90,5 @@ chmod +x ${INSTALL_LOCATION} rm -f ${TEMPDIR}/ktf.${OSTYPE}.${ARCH} rm -f ${TEMPDIR}/CHECKSUMS rmdir ${TEMPDIR} + +echo "SUCCESS! Checksums verified, ktf (version: ${LATEST_RELEASE}) was installed at: ${INSTALL_LOCATION}"