diff --git a/cmd/app/main-win.go b/cmd/app/main-win.go index 25826618db..bc47892005 100644 --- a/cmd/app/main-win.go +++ b/cmd/app/main-win.go @@ -1,4 +1,4 @@ -// +build windows +//go:build windows package app diff --git a/cmd/app/main.go b/cmd/app/main.go index e692ae80d8..5875d5a03d 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -1,5 +1,5 @@ //nolint:gofmt,goimports -// +build !windows +//go:build !windows package app diff --git a/docs/cmd/jx.md b/docs/cmd/jx.md index 2913365df7..ac7e8eaaa3 100644 --- a/docs/cmd/jx.md +++ b/docs/cmd/jx.md @@ -22,6 +22,7 @@ Jenkins X 3.x command line * [jx add](jx_add.md) - Adds one or more resources * [jx create](jx_create.md) - Create one or more resources +* [jx ctx](jx_ctx.md) - alias for: jx ctx * [jx dashboard](jx_dashboard.md) - View the Jenkins X Pipelines Dashboard * [jx get](jx_get.md) - Display one or more resources * [jx import](jx_import.md) - alias for: jx import @@ -32,4 +33,4 @@ Jenkins X 3.x command line * [jx upgrade](jx_upgrade.md) - Upgrades resources * [jx version](jx_version.md) - Displays the version of this command -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_add.md b/docs/cmd/jx_add.md index dc0597a9cb..b122e23c29 100644 --- a/docs/cmd/jx_add.md +++ b/docs/cmd/jx_add.md @@ -23,4 +23,4 @@ Adds one or more resources * [jx](jx.md) - Jenkins X 3.x command line * [jx add app](jx_add_app.md) - alias for: jx app -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_add_app.md b/docs/cmd/jx_add_app.md index d66184cc40..ab1dddb67e 100644 --- a/docs/cmd/jx_add_app.md +++ b/docs/cmd/jx_add_app.md @@ -24,4 +24,4 @@ alias for: jx app * [jx add](jx_add.md) - Adds one or more resources -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_create.md b/docs/cmd/jx_create.md index 3ed112ea27..2d541ceb45 100644 --- a/docs/cmd/jx_create.md +++ b/docs/cmd/jx_create.md @@ -26,4 +26,4 @@ Create one or more resources * [jx create quickstart](jx_create_quickstart.md) - alias for: jx quickstart * [jx create spring](jx_create_spring.md) - alias for: jx spring -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_create_project.md b/docs/cmd/jx_create_project.md index 8e4e498340..4683232597 100644 --- a/docs/cmd/jx_create_project.md +++ b/docs/cmd/jx_create_project.md @@ -22,4 +22,4 @@ alias for: jx project * [jx create](jx_create.md) - Create one or more resources -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_create_pullrequest.md b/docs/cmd/jx_create_pullrequest.md index 826dfce6ab..4b1591fb1c 100644 --- a/docs/cmd/jx_create_pullrequest.md +++ b/docs/cmd/jx_create_pullrequest.md @@ -24,4 +24,4 @@ alias for: jx pullrequest * [jx create](jx_create.md) - Create one or more resources -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_create_quickstart.md b/docs/cmd/jx_create_quickstart.md index e86716a1c7..b39be41910 100644 --- a/docs/cmd/jx_create_quickstart.md +++ b/docs/cmd/jx_create_quickstart.md @@ -24,4 +24,4 @@ alias for: jx quickstart * [jx create](jx_create.md) - Create one or more resources -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_create_spring.md b/docs/cmd/jx_create_spring.md index 305cd447c1..dfd3325704 100644 --- a/docs/cmd/jx_create_spring.md +++ b/docs/cmd/jx_create_spring.md @@ -24,4 +24,4 @@ alias for: jx spring * [jx create](jx_create.md) - Create one or more resources -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_ctx.md b/docs/cmd/jx_ctx.md new file mode 100644 index 0000000000..a1c9ddb88d --- /dev/null +++ b/docs/cmd/jx_ctx.md @@ -0,0 +1,25 @@ +## jx ctx + +alias for: jx ctx + +### Usage + +``` +jx ctx +``` + +### Synopsis + +alias for: jx ctx + +### Options + +``` + -h, --help help for ctx +``` + +### SEE ALSO + +* [jx](jx.md) - Jenkins X 3.x command line + +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_dashboard.md b/docs/cmd/jx_dashboard.md index 2e3c4480c9..1e489e2352 100644 --- a/docs/cmd/jx_dashboard.md +++ b/docs/cmd/jx_dashboard.md @@ -38,4 +38,4 @@ View the Jenkins X Pipelines Dashboard. * [jx](jx.md) - Jenkins X 3.x command line -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_get.md b/docs/cmd/jx_get.md index 10950551c2..5fa5a0370f 100644 --- a/docs/cmd/jx_get.md +++ b/docs/cmd/jx_get.md @@ -27,4 +27,4 @@ Display one or more resources * [jx get pipelines](jx_get_pipelines.md) - alias for: jx pipelines * [jx get previews](jx_get_previews.md) - alias for: jx previews -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_get_activities.md b/docs/cmd/jx_get_activities.md index 0a0441cce4..c0a7f955e7 100644 --- a/docs/cmd/jx_get_activities.md +++ b/docs/cmd/jx_get_activities.md @@ -24,4 +24,4 @@ alias for: jx activities * [jx get](jx_get.md) - Display one or more resources -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_get_application.md b/docs/cmd/jx_get_application.md index ab40f12a67..359f320796 100644 --- a/docs/cmd/jx_get_application.md +++ b/docs/cmd/jx_get_application.md @@ -24,4 +24,4 @@ alias for: jx application * [jx get](jx_get.md) - Display one or more resources -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_get_build.md b/docs/cmd/jx_get_build.md index f654ce2003..cfe9af2963 100644 --- a/docs/cmd/jx_get_build.md +++ b/docs/cmd/jx_get_build.md @@ -26,4 +26,4 @@ Display one or more resources relating to a pipeline build * [jx get build logs](jx_get_build_logs.md) - alias for: jx logs * [jx get build pods](jx_get_build_pods.md) - alias for: jx pods -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_get_build_logs.md b/docs/cmd/jx_get_build_logs.md index aed6c1d0f2..a0188fb9e1 100644 --- a/docs/cmd/jx_get_build_logs.md +++ b/docs/cmd/jx_get_build_logs.md @@ -24,4 +24,4 @@ alias for: jx logs * [jx get build](jx_get_build.md) - Display one or more resources relating to a pipeline build -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_get_build_pods.md b/docs/cmd/jx_get_build_pods.md index 44389d8bd9..f1b977e33c 100644 --- a/docs/cmd/jx_get_build_pods.md +++ b/docs/cmd/jx_get_build_pods.md @@ -24,4 +24,4 @@ alias for: jx pods * [jx get build](jx_get_build.md) - Display one or more resources relating to a pipeline build -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_get_pipelines.md b/docs/cmd/jx_get_pipelines.md index 4d3a540a81..e090e193be 100644 --- a/docs/cmd/jx_get_pipelines.md +++ b/docs/cmd/jx_get_pipelines.md @@ -24,4 +24,4 @@ alias for: jx pipelines * [jx get](jx_get.md) - Display one or more resources -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_get_previews.md b/docs/cmd/jx_get_previews.md index 085680c097..629ca0fe7e 100644 --- a/docs/cmd/jx_get_previews.md +++ b/docs/cmd/jx_get_previews.md @@ -24,4 +24,4 @@ alias for: jx previews * [jx get](jx_get.md) - Display one or more resources -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_import.md b/docs/cmd/jx_import.md index 24f625c844..dc9c13cecd 100644 --- a/docs/cmd/jx_import.md +++ b/docs/cmd/jx_import.md @@ -24,4 +24,4 @@ alias for: jx import * [jx](jx.md) - Jenkins X 3.x command line -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_namespace.md b/docs/cmd/jx_namespace.md index 54725af8fd..41ba69d165 100644 --- a/docs/cmd/jx_namespace.md +++ b/docs/cmd/jx_namespace.md @@ -2,7 +2,7 @@ View or change the current namespace context in the current Kubernetes cluster -***Aliases**: ns,ctx* +***Aliases**: ns* ### Usage @@ -52,4 +52,4 @@ Displays or changes the current namespace. * [jx](jx.md) - Jenkins X 3.x command line -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_start.md b/docs/cmd/jx_start.md index 8487542c41..68ac1f1ed7 100644 --- a/docs/cmd/jx_start.md +++ b/docs/cmd/jx_start.md @@ -23,4 +23,4 @@ Starts a resource * [jx](jx.md) - Jenkins X 3.x command line * [jx start pipeline](jx_start_pipeline.md) - alias for: jx pipeline -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_start_pipeline.md b/docs/cmd/jx_start_pipeline.md index 961ef76f9f..ab3fbb7900 100644 --- a/docs/cmd/jx_start_pipeline.md +++ b/docs/cmd/jx_start_pipeline.md @@ -24,4 +24,4 @@ alias for: jx pipeline * [jx start](jx_start.md) - Starts a resource -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_stop.md b/docs/cmd/jx_stop.md index daa5c768da..d6599ef7bd 100644 --- a/docs/cmd/jx_stop.md +++ b/docs/cmd/jx_stop.md @@ -23,4 +23,4 @@ Stops a resource * [jx](jx.md) - Jenkins X 3.x command line * [jx stop pipeline](jx_stop_pipeline.md) - alias for: jx pipeline -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_stop_pipeline.md b/docs/cmd/jx_stop_pipeline.md index 31828eec5f..1c63ebcdfd 100644 --- a/docs/cmd/jx_stop_pipeline.md +++ b/docs/cmd/jx_stop_pipeline.md @@ -24,4 +24,4 @@ alias for: jx pipeline * [jx stop](jx_stop.md) - Stops a resource -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_ui.md b/docs/cmd/jx_ui.md index d0bcfc6aaa..13791e4f82 100644 --- a/docs/cmd/jx_ui.md +++ b/docs/cmd/jx_ui.md @@ -36,4 +36,4 @@ Views the Jenkins X UI (octant). * [jx](jx.md) - Jenkins X 3.x command line -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_upgrade.md b/docs/cmd/jx_upgrade.md index f465a964e2..7c7d7836f8 100644 --- a/docs/cmd/jx_upgrade.md +++ b/docs/cmd/jx_upgrade.md @@ -29,4 +29,4 @@ Upgrades all of the plugins in your local Jenkins X CLI * [jx upgrade cli](jx_upgrade_cli.md) - Upgrades your local Jenkins X CLI * [jx upgrade plugins](jx_upgrade_plugins.md) - Upgrades all of the plugins in your local Jenkins X CLI -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_upgrade_cli.md b/docs/cmd/jx_upgrade_cli.md index e6d345a9d5..e9b947ccbc 100644 --- a/docs/cmd/jx_upgrade_cli.md +++ b/docs/cmd/jx_upgrade_cli.md @@ -30,4 +30,4 @@ Upgrades your local Jenkins X CLI * [jx upgrade](jx_upgrade.md) - Upgrades resources -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_upgrade_plugins.md b/docs/cmd/jx_upgrade_plugins.md index 851db21b81..86bfb30abd 100644 --- a/docs/cmd/jx_upgrade_plugins.md +++ b/docs/cmd/jx_upgrade_plugins.md @@ -30,4 +30,4 @@ Upgrades all of the plugins in your local Jenkins X CLI * [jx upgrade](jx_upgrade.md) - Upgrades resources -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/cmd/jx_version.md b/docs/cmd/jx_version.md index d364d2568f..6042e88575 100644 --- a/docs/cmd/jx_version.md +++ b/docs/cmd/jx_version.md @@ -17,10 +17,11 @@ Displays the version of this command ``` -h, --help help for version -q, --quiet uses the quiet format of just outputting the version number only + -s, --short uses the short format of just outputting the version number only ``` ### SEE ALSO * [jx](jx.md) - Jenkins X 3.x command line -###### Auto generated by spf13/cobra on 9-Nov-2021 +###### Auto generated by spf13/cobra on 29-Jul-2022 diff --git a/docs/man/man1/jx-ctx.1 b/docs/man/man1/jx-ctx.1 new file mode 100644 index 0000000000..c59c976173 --- /dev/null +++ b/docs/man/man1/jx-ctx.1 @@ -0,0 +1,34 @@ +.TH "JX\-CTX" "1" "" "Auto generated by spf13/cobra" "" +.nh +.ad l + + +.SH NAME +.PP +jx\-ctx \- alias for: jx ctx + + +.SH SYNOPSIS +.PP +\fBjx ctx\fP + + +.SH DESCRIPTION +.PP +alias for: jx ctx + + +.SH OPTIONS +.PP +\fB\-h\fP, \fB\-\-help\fP[=false] + help for ctx + + +.SH SEE ALSO +.PP +\fBjx(1)\fP + + +.SH HISTORY +.PP +Auto generated by spf13/cobra diff --git a/docs/man/man1/jx-version.1 b/docs/man/man1/jx-version.1 index 5a2087a016..bcb7efb99b 100644 --- a/docs/man/man1/jx-version.1 +++ b/docs/man/man1/jx-version.1 @@ -27,6 +27,10 @@ Displays the version of this command \fB\-q\fP, \fB\-\-quiet\fP[=false] uses the quiet format of just outputting the version number only +.PP +\fB\-s\fP, \fB\-\-short\fP[=false] + uses the short format of just outputting the version number only + .SH SEE ALSO .PP diff --git a/docs/man/man1/jx.1 b/docs/man/man1/jx.1 index 42b99dbb09..d59646209c 100644 --- a/docs/man/man1/jx.1 +++ b/docs/man/man1/jx.1 @@ -26,7 +26,7 @@ Jenkins X 3.x command line .SH SEE ALSO .PP -\fBjx\-add(1)\fP, \fBjx\-create(1)\fP, \fBjx\-dashboard(1)\fP, \fBjx\-get(1)\fP, \fBjx\-import(1)\fP, \fBjx\-namespace(1)\fP, \fBjx\-start(1)\fP, \fBjx\-stop(1)\fP, \fBjx\-ui(1)\fP, \fBjx\-upgrade(1)\fP, \fBjx\-version(1)\fP +\fBjx\-add(1)\fP, \fBjx\-create(1)\fP, \fBjx\-ctx(1)\fP, \fBjx\-dashboard(1)\fP, \fBjx\-get(1)\fP, \fBjx\-import(1)\fP, \fBjx\-namespace(1)\fP, \fBjx\-start(1)\fP, \fBjx\-stop(1)\fP, \fBjx\-ui(1)\fP, \fBjx\-upgrade(1)\fP, \fBjx\-version(1)\fP .SH HISTORY diff --git a/hack/generate.sh b/hack/generate.sh index a2b411580d..33dd99ff15 100755 --- a/hack/generate.sh +++ b/hack/generate.sh @@ -8,7 +8,7 @@ RESET='\033[0m' if ! [ -x "$(command -v goimports)" ]; then echo "Installing goimports" - go get golang.org/x/tools/cmd/goimports + go install golang.org/x/tools/cmd/goimports fi echo "Running validation scripts..." diff --git a/hack/install_golint.sh b/hack/install_golint.sh deleted file mode 100755 index 6010f3b276..0000000000 --- a/hack/install_golint.sh +++ /dev/null @@ -1,388 +0,0 @@ -#!/bin/sh -set -e -# Code generated by godownloader on 2018-06-05T12:04:55Z. DO NOT EDIT. -# - -usage() { - this=$1 - cat </dev/null -} -echoerr() { - echo "$@" 1>&2 -} -log_prefix() { - echo "$0" -} -_logp=6 -log_set_priority() { - _logp="$1" -} -log_priority() { - if test -z "$1"; then - echo "$_logp" - return - fi - [ "$1" -le "$_logp" ] -} -log_tag() { - case $1 in - 0) echo "emerg" ;; - 1) echo "alert" ;; - 2) echo "crit" ;; - 3) echo "err" ;; - 4) echo "warning" ;; - 5) echo "notice" ;; - 6) echo "info" ;; - 7) echo "debug" ;; - *) echo "$1" ;; - esac -} -log_debug() { - log_priority 7 || return 0 - echoerr "$(log_prefix)" "$(log_tag 7)" "$@" -} -log_info() { - log_priority 6 || return 0 - echoerr "$(log_prefix)" "$(log_tag 6)" "$@" -} -log_err() { - log_priority 3 || return 0 - echoerr "$(log_prefix)" "$(log_tag 3)" "$@" -} -log_crit() { - log_priority 2 || return 0 - echoerr "$(log_prefix)" "$(log_tag 2)" "$@" -} -uname_os() { - os=$(uname -s | tr '[:upper:]' '[:lower:]') - case "$os" in - msys_nt) os="windows" ;; - esac - echo "$os" -} -uname_arch() { - arch=$(uname -m) - case $arch in - x86_64) arch="amd64" ;; - x86) arch="386" ;; - i686) arch="386" ;; - i386) arch="386" ;; - aarch64) arch="arm64" ;; - armv5*) arch="armv5" ;; - armv6*) arch="armv6" ;; - armv7*) arch="armv7" ;; - esac - echo ${arch} -} -uname_os_check() { - os=$(uname_os) - case "$os" in - darwin) return 0 ;; - dragonfly) return 0 ;; - freebsd) return 0 ;; - linux) return 0 ;; - android) return 0 ;; - nacl) return 0 ;; - netbsd) return 0 ;; - openbsd) return 0 ;; - plan9) return 0 ;; - solaris) return 0 ;; - windows) return 0 ;; - esac - log_crit "uname_os_check '$(uname -s)' got converted to '$os' which is not a GOOS value. Please file bug at https://github.com/client9/shlib" - return 1 -} -uname_arch_check() { - arch=$(uname_arch) - case "$arch" in - 386) return 0 ;; - amd64) return 0 ;; - arm64) return 0 ;; - armv5) return 0 ;; - armv6) return 0 ;; - armv7) return 0 ;; - ppc64) return 0 ;; - ppc64le) return 0 ;; - mips) return 0 ;; - mipsle) return 0 ;; - mips64) return 0 ;; - mips64le) return 0 ;; - s390x) return 0 ;; - amd64p32) return 0 ;; - esac - log_crit "uname_arch_check '$(uname -m)' got converted to '$arch' which is not a GOARCH value. Please file bug report at https://github.com/client9/shlib" - return 1 -} -untar() { - tarball=$1 - case "${tarball}" in - *.tar.gz | *.tgz) tar -xzf "${tarball}" ;; - *.tar) tar -xf "${tarball}" ;; - *.zip) unzip "${tarball}" ;; - *) - log_err "untar unknown archive format for ${tarball}" - return 1 - ;; - esac -} -mktmpdir() { - test -z "$TMPDIR" && TMPDIR="$(mktemp -d)" - mkdir -p "${TMPDIR}" - echo "${TMPDIR}" -} -http_download_curl() { - local_file=$1 - source_url=$2 - header=$3 - if [ -z "$header" ]; then - code=$(curl -w '%{http_code}' -sL -o "$local_file" "$source_url") - else - code=$(curl -w '%{http_code}' -sL -H "$header" -o "$local_file" "$source_url") - fi - if [ "$code" != "200" ]; then - log_debug "http_download_curl received HTTP status $code" - return 1 - fi - return 0 -} -http_download_wget() { - local_file=$1 - source_url=$2 - header=$3 - if [ -z "$header" ]; then - wget -q -O "$local_file" "$source_url" - else - wget -q --header "$header" -O "$local_file" "$source_url" - fi -} -http_download() { - log_debug "http_download $2" - if is_command curl; then - http_download_curl "$@" - return - elif is_command wget; then - http_download_wget "$@" - return - fi - log_crit "http_download unable to find wget or curl" - return 1 -} -http_copy() { - tmp=$(mktemp) - http_download "${tmp}" "$1" "$2" || return 1 - body=$(cat "$tmp") - rm -f "${tmp}" - echo "$body" -} -github_release() { - owner_repo=$1 - version=$2 - test -z "$version" && version="latest" - giturl="https://github.com/${owner_repo}/releases/${version}" - json=$(http_copy "$giturl" "Accept:application/json") - test -z "$json" && return 1 - version=$(echo "$json" | tr -s '\n' ' ' | sed 's/.*"tag_name":"//' | sed 's/".*//') - test -z "$version" && return 1 - echo "$version" -} -hash_sha256() { - TARGET=${1:-/dev/stdin} - if is_command gsha256sum; then - hash=$(gsha256sum "$TARGET") || return 1 - echo "$hash" | cut -d ' ' -f 1 - elif is_command sha256sum; then - hash=$(sha256sum "$TARGET") || return 1 - echo "$hash" | cut -d ' ' -f 1 - elif is_command shasum; then - hash=$(shasum -a 256 "$TARGET" 2>/dev/null) || return 1 - echo "$hash" | cut -d ' ' -f 1 - elif is_command openssl; then - hash=$(openssl -dst openssl dgst -sha256 "$TARGET") || return 1 - echo "$hash" | cut -d ' ' -f a - else - log_crit "hash_sha256 unable to find command to compute sha-256 hash" - return 1 - fi -} -hash_sha256_verify() { - TARGET=$1 - checksums=$2 - if [ -z "$checksums" ]; then - log_err "hash_sha256_verify checksum file not specified in arg2" - return 1 - fi - BASENAME=${TARGET##*/} - want=$(grep "${BASENAME}" "${checksums}" 2>/dev/null | tr '\t' ' ' | cut -d ' ' -f 1) - if [ -z "$want" ]; then - log_err "hash_sha256_verify unable to find checksum for '${TARGET}' in '${checksums}'" - return 1 - fi - got=$(hash_sha256 "$TARGET") - if [ "$want" != "$got" ]; then - log_err "hash_sha256_verify checksum for '$TARGET' did not verify ${want} vs $got" - return 1 - fi -} -cat /dev/null <