diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cebd2727..d1f28768 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,7 @@ jobs: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.PASSPHRASE }} - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v5 with: args: release --clean env: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 02c66799..51e86f8c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,18 +26,18 @@ jobs: # 10.x.x kf_10_x_x: runs-on: ubuntu-latest - needs: + needs: - build steps: - name: Checkout code uses: actions/checkout@v4 - name: Run tests run: echo "Running tests for KF 10.x.x" - + ### Store Type Tests Test_StoreTypes_KFC_10_4_5: runs-on: ubuntu-latest - needs: + needs: - build - kf_10_x_x env: @@ -55,7 +55,7 @@ jobs: go test -v ./cmd -run "^Test_StoreTypes*" Test_StoreTypes_KFC_10_2_1: runs-on: ubuntu-latest - needs: + needs: - build - kf_10_x_x env: @@ -72,24 +72,43 @@ jobs: unset KFUTIL_DEBUG go test -v ./cmd -run "^Test_StoreTypes*" -# Test_StoreTypes_KFC_10_1_1: -# runs-on: ubuntu-latest -# needs: -# - build -# - kf_10_x_x -# env: -# SECRET_NAME: "command-config-1011-clean" -# KEYFACTOR_HOSTNAME: "int1011-test-clean.kfdelivery.com" -# KEYFACTOR_DOMAIN: "command" -# KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} -# KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} -# steps: -# - name: Checkout code -# uses: actions/checkout@v4 -# - name: Run tests -# run: | -# unset KFUTIL_DEBUG -# go test -v ./cmd -run "^Test_StoreTypes*" + Test_StoreTypes_KFC_10_1_1: + runs-on: ubuntu-latest + needs: + - build + - kf_10_x_x + env: + SECRET_NAME: "command-config-1011-clean" + KEYFACTOR_HOSTNAME: "int1011-test-clean.kfdelivery.com" + KEYFACTOR_DOMAIN: "command" + KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} + KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Run tests + run: | + unset KFUTIL_DEBUG + go test -v ./cmd -run "^Test_StoreTypes*" + + # Test_StoreTypes_KFC_10_1_1: + # runs-on: ubuntu-latest + # needs: + # - build + # - kf_10_x_x + # env: + # SECRET_NAME: "command-config-1011-clean" + # KEYFACTOR_HOSTNAME: "int1011-test-clean.kfdelivery.com" + # KEYFACTOR_DOMAIN: "command" + # KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} + # KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} + # steps: + # - name: Checkout code + # uses: actions/checkout@v4 + # - name: Run tests + # run: | + # unset KFUTIL_DEBUG + # go test -v ./cmd -run "^Test_StoreTypes*" ### Store Tests Test_Stores_KFC_10_4_5: @@ -129,25 +148,45 @@ jobs: unset KFUTIL_DEBUG go test -v ./cmd -run "^Test_Stores_*" -# Test_Stores_KFC_10_1_1: -# runs-on: ubuntu-latest -# needs: -# - build -# - kf_10_x_x -# - Test_StoreTypes_KFC_10_1_1 -# env: -# SECRET_NAME: "command-config-1011" -# KEYFACTOR_HOSTNAME: "integrations1011-lab.kfdelivery.com" -# KEYFACTOR_DOMAIN: "command" -# KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} -# KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} -# steps: -# - name: Checkout code -# uses: actions/checkout@v4 -# - name: Run tests -# run: | -# unset KFUTIL_DEBUG -# go test -v ./cmd -run "^Test_Stores_*" + Test_Stores_KFC_10_1_1: + runs-on: ubuntu-latest + needs: + - build + - kf_10_x_x + - Test_StoreTypes_KFC_10_1_1 + env: + SECRET_NAME: "command-config-1011" + KEYFACTOR_HOSTNAME: "integrations1011-lab.kfdelivery.com" + KEYFACTOR_DOMAIN: "command" + KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} + KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Run tests + run: | + unset KFUTIL_DEBUG + go test -v ./cmd -run "^Test_Stores_*" + + # Test_Stores_KFC_10_1_1: + # runs-on: ubuntu-latest + # needs: + # - build + # - kf_10_x_x + # - Test_StoreTypes_KFC_10_1_1 + # env: + # SECRET_NAME: "command-config-1011" + # KEYFACTOR_HOSTNAME: "integrations1011-lab.kfdelivery.com" + # KEYFACTOR_DOMAIN: "command" + # KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} + # KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} + # steps: + # - name: Checkout code + # uses: actions/checkout@v4 + # - name: Run tests + # run: | + # unset KFUTIL_DEBUG + # go test -v ./cmd -run "^Test_Stores_*" ### PAM Tests Test_PAM_KFC_10_4_5: @@ -189,25 +228,44 @@ jobs: run: | unset KFUTIL_DEBUG go test -v ./cmd -run "^Test_PAM*" -# Test_PAM_KFC_10_1_1: -# runs-on: ubuntu-latest -# needs: -# - build -# - kf_10_x_x -# - Test_StoreTypes_KFC_10_1_1 -# env: -# SECRET_NAME: "command-config-1011" -# KEYFACTOR_HOSTNAME: "integrations1011-lab.kfdelivery.com" -# KEYFACTOR_DOMAIN: "command" -# KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} -# KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} -# steps: -# - name: Checkout code -# uses: actions/checkout@v4 -# - name: Run tests -# run: | -# unset KFUTIL_DEBUG -# go test -v ./cmd -run "^Test_PAM*" + Test_PAM_KFC_10_1_1: + runs-on: ubuntu-latest + needs: + - build + - kf_10_x_x + - Test_StoreTypes_KFC_10_1_1 + env: + SECRET_NAME: "command-config-1011" + KEYFACTOR_HOSTNAME: "integrations1011-lab.kfdelivery.com" + KEYFACTOR_DOMAIN: "command" + KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} + KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Run tests + run: | + unset KFUTIL_DEBUG + go test -v ./cmd -run "^Test_PAM*" + # Test_PAM_KFC_10_1_1: + # runs-on: ubuntu-latest + # needs: + # - build + # - kf_10_x_x + # - Test_StoreTypes_KFC_10_1_1 + # env: + # SECRET_NAME: "command-config-1011" + # KEYFACTOR_HOSTNAME: "integrations1011-lab.kfdelivery.com" + # KEYFACTOR_DOMAIN: "command" + # KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} + # KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} + # steps: + # - name: Checkout code + # uses: actions/checkout@v4 + # - name: Run tests + # run: | + # unset KFUTIL_DEBUG + # go test -v ./cmd -run "^Test_PAM*" ### PAM Tests AKV Auth Provider Test_AKV_PAM_KFC_10_4_5: @@ -261,128 +319,147 @@ jobs: - name: Run tests run: | go test -v ./cmd -run "^Test_PAM*" -# Test_AKV_PAM_KFC_10_1_1: -# runs-on: self-hosted -# needs: -# - kf_10_x_x -# - Test_PAM_KFC_10_1_1 -# env: -# SECRET_NAME: "command-config-1011-az" -# steps: -# - name: Checkout code -# uses: actions/checkout@v4 -# - name: Set up Go -# uses: actions/setup-go@v4 -# with: -# go-version: "1.20" -# - name: Install dependencies -# run: go mod download && go mod tidy -# - name: Get secret from Azure Key Vault -# run: | -# . ./examples/auth/akv/akv_auth.sh -# cat $HOME/.keyfactor/command_config.json -# - name: Install kfutil -# run: | -# make install -# - name: Run tests -# run: | -# go test -v ./cmd -run "^Test_PAM*" -# # 11.x.x -# kf_11_x_x: -# runs-on: ubuntu-latest -# needs: -# - build -# steps: -# - name: Checkout code -# uses: actions/checkout@v4 -# - name: Run tests -# run: echo "Running tests for KF 11.x.x" -# ### Store Type Tests -# Test_StoreTypes_KFC_11_0_0: -# runs-on: ubuntu-latest -# needs: -# - build -# - kf_11_x_x -# env: -# SECRET_NAME: "command-config-1100-clean" -# KEYFACTOR_HOSTNAME: "int11-test-clean.kfdelivery.com" -# KEYFACTOR_DOMAIN: "command" -# KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} -# KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} -# steps: -# - name: Checkout code -# uses: actions/checkout@v4 -# - name: Run tests -# run: | -# unset KFUTIL_DEBUG -# go test -v ./cmd -run "^Test_StoreTypes*" -# -# ### Store Tests -# Test_Stores_KFC_11_0_0: -# runs-on: ubuntu-latest -# needs: -# - build -# - kf_11_x_x -# - Test_StoreTypes_KFC_11_0_0 -# env: -# SECRET_NAME: "command-config-1100" -# KEYFACTOR_HOSTNAME: "integrations1100b3-lab.kfdelivery.com" -# KEYFACTOR_DOMAIN: "command" -# KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} -# KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} -# steps: -# - name: Checkout code -# uses: actions/checkout@v4 -# - name: Run tests -# run: | -# unset KFUTIL_DEBUG -# go test -v ./cmd -run "^Test_Stores_*" -# -# ### PAM Tests -# Test_PAM_KFC_11_0_0: -# runs-on: ubuntu-latest -# needs: -# - build -# - kf_11_x_x -# - Test_StoreTypes_KFC_11_0_0 -# env: -# SECRET_NAME: "command-config-1100" -# KEYFACTOR_HOSTNAME: "integrations1100b3-lab.kfdelivery.com" -# KEYFACTOR_DOMAIN: "command" -# KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} -# KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} -# steps: -# - name: Checkout code -# uses: actions/checkout@v4 -# - name: Run tests -# run: | -# unset KFUTIL_DEBUG -# go test -v ./cmd -run "^Test_PAM*" -# ### PAM Tests AKV Auth Provider -# Test_AKV_PAM_KFC_11_0_0: -# runs-on: self-hosted -# needs: -# - build -# - kf_11_x_x -# - Test_StoreTypes_KFC_11_0_0 -# - Test_PAM_KFC_11_0_0 -# env: -# SECRET_NAME: "command-config-1100-az" -# steps: -# - name: Checkout code -# uses: actions/checkout@v4 -# -# - name: Get secret from Azure Key Vault -# run: | -# . ./examples/auth/akv/akv_auth.sh -# -# - name: Run tests -# run: | -# unset KFUTIL_DEBUG -# kfutil logout || true -# printenv | grep -i keyfactor -# go test -v ./cmd -run "^Test_PAM*" + Test_AKV_PAM_KFC_10_1_1: + runs-on: self-hosted + needs: + - Test_PAM_KFC_10_1_1 + env: + SECRET_NAME: "command-config-1011-az" + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.20" + - name: Install dependencies + run: go mod download && go mod tidy + - name: Get secret from Azure Key Vault + run: | + . ./examples/auth/akv/akv_auth.sh + cat $HOME/.keyfactor/command_config.json + - name: Install kfutil + run: | + make install + - name: Run tests + run: | + go test -v ./cmd -run "^Test_PAM*" + + + + ## KFC 11.x.x + kf_11_x_x: + runs-on: ubuntu-latest + needs: + - build + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Run tests + run: echo "Running tests for KF 11.x.x" + + ### Store Type Tests + Test_StoreTypes_KFC_11_0_0: + runs-on: ubuntu-latest + needs: + - build + - kf_11_x_x + env: + SECRET_NAME: "command-config-1100-clean" + KEYFACTOR_HOSTNAME: "int11-test-clean.kfdelivery.com" + KEYFACTOR_DOMAIN: "command" + KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} + KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Run tests + run: | + unset KFUTIL_DEBUG + go test -v ./cmd -run "^Test_StoreTypes*" + + ### Store Tests + Test_Stores_KFC_11_0_0: + runs-on: ubuntu-latest + needs: + - build + - kf_11_x_x + - Test_StoreTypes_KFC_11_0_0 + env: + SECRET_NAME: "command-config-1100" + KEYFACTOR_HOSTNAME: "integrations1100-lab.kfdelivery.com" + KEYFACTOR_DOMAIN: "command" + KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} + KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Run tests + run: go test -v ./cmd -run "^Test_Stores_*" + + ### PAM Tests + Test_PAM_KFC_11_0_0: + runs-on: ubuntu-latest + needs: + - build + - kf_11_x_x + - Test_StoreTypes_KFC_11_0_0 + env: + SECRET_NAME: "command-config-1100" + KEYFACTOR_HOSTNAME: "integrations1100-lab.kfdelivery.com" + KEYFACTOR_DOMAIN: "command" + KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} + KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Run tests + run: | + unset KFUTIL_DEBUG + go test -v ./cmd -run "^Test_PAM*" + + + ### PAM Tests AKV Auth Provider + Test_AKV_PAM_KFC_11_0_0: + runs-on: self-hosted + needs: + - Test_PAM_KFC_11_0_0 + env: + SECRET_NAME: "command-config-1100-az" + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.20" + - name: Install dependencies + run: go mod download && go mod tidy + - name: Get secret from Azure Key Vault + run: | + . ./examples/auth/akv/akv_auth.sh + cat $HOME/.keyfactor/command_config.json + - name: Install kfutil + run: | + make install + - name: Run tests + run: | + go test -v ./cmd -run "^Test_PAM*" + + + # Tester Install Script + Test_Install_Script: + runs-on: ubuntu-latest + steps: + - name: Test Quick Install Script + run: | + bash <(curl -s https://raw.githubusercontent.com/Keyfactor/kfutil/${GITHUB_REF_NAME}/install.sh) + which kfutil + kfutil version + rm $(which kfutil) + + # Package Tests Test_Kfutil_pkg: runs-on: ubuntu-latest needs: diff --git a/GNUmakefile b/GNUmakefile index 8846389f..d3c64625 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -8,7 +8,7 @@ NAME=kfutil BINARY=${NAME} VERSION := $(GITHUB_REF_NAME) ifeq ($(VERSION),) - VERSION := v1.2.0 + VERSION := v1.2.1 endif OS_ARCH := $(shell go env GOOS)_$(shell go env GOARCH) BASEDIR := ${HOME}/go/bin diff --git a/README.md b/README.md index 9355c8be..51f5344f 100644 --- a/README.md +++ b/README.md @@ -48,16 +48,18 @@ through their Keyfactor representative. ## Quickstart ### Prerequisites: - -- [Github CLI](https://cli.github.com/) -- [zip](https://linuxize.com/post/how-to-unzip-files-in-linux/#installing-unzip) CLI tool, used to unzip the release - files. +- [jq](https://stedolan.github.io/jq/download/) CLI tool, used to parse JSON output. +- Either + - [curl](https://curl.se/download.html) CLI tool, used to download the release files. + - OR [wget](https://www.gnu.org/software/wget/) CLI tool, used to download the release files. +- [unzip](https://linuxize.com/post/how-to-unzip-files-in-linux/#installing-unzip) CLI tool, used to unzip the release +- [openssl](https://www.openssl.org/source/) CLI tool, used to validate package checksum. - `$HOME/.local/bin` in your `$PATH` and exists. ### Installation: ```bash -bash <(curl -s https://raw.githubusercontent.com/Keyfactor/kfutil/main/gh-dl-release.sh) +bash <(curl -s https://raw.githubusercontent.com/Keyfactor/kfutil/main/install.sh) ```` ### Environmental Variables diff --git a/cmd/storeTypes.go b/cmd/storeTypes.go index e0847207..e4d08aca 100644 --- a/cmd/storeTypes.go +++ b/cmd/storeTypes.go @@ -402,7 +402,7 @@ var storesTypeDeleteCmd = &cobra.Command{ }, } -var fetchStoreTypes = &cobra.Command{ +var fetchStoreTypesCmd = &cobra.Command{ Use: "templates-fetch", Short: "Fetches store type templates from Keyfactor's Github.", Long: `Fetches store type templates from Keyfactor's Github.`, @@ -634,7 +634,8 @@ func init() { RootCmd.AddCommand(storeTypesCmd) // GET store type templates - storeTypesCmd.AddCommand(fetchStoreTypes) + storeTypesCmd.AddCommand(fetchStoreTypesCmd) + fetchStoreTypesCmd.Flags().StringVarP(&gitRef, FlagGitRef, "b", "main", "The git branch or tag to reference when pulling store-types from the internet.") // LIST command storeTypesCmd.AddCommand(storesTypesListCmd) diff --git a/cmd/storeTypes_test.go b/cmd/storeTypes_test.go index ded1a485..2bd93cda 100644 --- a/cmd/storeTypes_test.go +++ b/cmd/storeTypes_test.go @@ -18,6 +18,7 @@ import ( "encoding/json" "fmt" "github.com/stretchr/testify/assert" + "os" "strings" "testing" ) @@ -112,7 +113,7 @@ func Test_StoreTypesFetchTemplatesCmd(t *testing.T) { func Test_StoreTypesGetCmd(t *testing.T) { testCmd := RootCmd // Attempt to get the AWS store type because it comes with the product - testCmd.SetArgs([]string{"store-types", "get", "--name", "IIS"}) + testCmd.SetArgs([]string{"store-types", "get", "--name", "PEM"}) output := captureOutput(func() { err := testCmd.Execute() assert.NoError(t, err) @@ -136,13 +137,13 @@ func Test_StoreTypesGetCmd(t *testing.T) { _, ok = storeType["Name"].(string) assert.True(t, ok, "Expected name to be a string") // check that shortname == AWS - assert.Equal(t, storeType["ShortName"], "IIS", "Expected short name to be IIS") + assert.Equal(t, storeType["ShortName"], "PEM", "Expected short name to be PEM") } func Test_StoreTypesGetGenericCmd(t *testing.T) { testCmd := RootCmd // Attempt to get the AWS store type because it comes with the product - testCmd.SetArgs([]string{"store-types", "get", "--name", "IIS", "--generic"}) + testCmd.SetArgs([]string{"store-types", "get", "--name", "PEM", "--generic"}) output := captureOutput(func() { err := testCmd.Execute() assert.NoError(t, err) @@ -169,14 +170,24 @@ func Test_StoreTypesGetGenericCmd(t *testing.T) { // verify name is a string _, ok = storeType["Name"].(string) assert.True(t, ok, "Expected name to be a string") - // check that shortname == IIS - assert.Equal(t, storeType["ShortName"], "IIS", "Expected short name to be IIS") + // check that shortname == PEM + assert.Equal(t, storeType["ShortName"], "PEM", "Expected short name to be PEM") } func Test_StoreTypesCreateFromTemplatesCmd(t *testing.T) { testCmd := RootCmd // test - testCmd.SetArgs([]string{"store-types", "templates-fetch"}) + testArgs := []string{"store-types", "templates-fetch"} + isGhAction := os.Getenv("GITHUB_ACTIONS") + t.Log("GITHUB_ACTIONS: ", isGhAction) + if isGhAction == "true" { + ghBranch := os.Getenv("GITHUB_REF") + ghBranch = strings.Replace(ghBranch, "refs/heads/", "", 1) + testArgs = append(testArgs, "--git-ref", ghBranch) + t.Log("GITHUB_REF: ", ghBranch) + } + t.Log("testArgs: ", testArgs) + testCmd.SetArgs(testArgs) templatesOutput := captureOutput(func() { err := testCmd.Execute() assert.NoError(t, err) @@ -191,6 +202,7 @@ func Test_StoreTypesCreateFromTemplatesCmd(t *testing.T) { // iterate over the store types and verify that each has a name shortname and storetype for sType := range storeTypes { + t.Log("Creating store type: " + sType) storeType := storeTypes[sType].(map[string]interface{}) assert.NotNil(t, storeType["Name"], "Expected store type to have a name") assert.NotNil(t, storeType["ShortName"], "Expected store type to have short name") @@ -212,8 +224,21 @@ func Test_StoreTypesCreateFromTemplatesCmd(t *testing.T) { func createAllStoreTypes(t *testing.T, storeTypes map[string]interface{}) { t.Run(fmt.Sprintf("Create ALL StoreTypes"), func(t *testing.T) { testCmd := RootCmd + // check if I'm running inside a GitHub Action + testArgs := []string{"store-types", "create", "--all"} + isGhAction := os.Getenv("GITHUB_ACTIONS") + t.Log("GITHUB_ACTIONS: ", isGhAction) + if isGhAction == "true" { + ghBranch := os.Getenv("GITHUB_REF") + ghBranch = strings.Replace(ghBranch, "refs/heads/", "", 1) + testArgs = append(testArgs, "--git-ref", ghBranch) + t.Log("GITHUB_REF: ", ghBranch) + + } + t.Log("testArgs: ", testArgs) + // Attempt to get the AWS store type because it comes with the product - testCmd.SetArgs([]string{"store-types", "create", "--all"}) + testCmd.SetArgs(testArgs) output := captureOutput(func() { err := testCmd.Execute() assert.NoError(t, err) diff --git a/go.mod b/go.mod index 65de0ad8..98f0fa6e 100644 --- a/go.mod +++ b/go.mod @@ -4,22 +4,22 @@ go 1.20 require ( github.com/AlecAivazis/survey/v2 v2.3.7 - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 github.com/Jeffail/gabs v1.4.0 github.com/Keyfactor/keyfactor-go-client-sdk v1.0.2 github.com/Keyfactor/keyfactor-go-client/v2 v2.1.4 github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 github.com/creack/pty v1.1.18 - github.com/google/go-cmp v0.5.9 - github.com/google/uuid v1.3.0 + github.com/google/go-cmp v0.6.0 + github.com/google/uuid v1.3.1 github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02 github.com/joho/godotenv v1.5.1 github.com/rs/zerolog v1.30.0 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.7.0 - golang.org/x/crypto v0.12.0 + golang.org/x/crypto v0.14.0 gopkg.in/yaml.v3 v3.0.1 //github.com/google/go-cmp/cmp v0.5.9 ) @@ -41,8 +41,8 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/spbsoluble/go-pkcs12 v0.3.3 // indirect go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 // indirect - golang.org/x/net v0.14.0 // indirect - golang.org/x/sys v0.12.0 // indirect - golang.org/x/term v0.11.0 // indirect - golang.org/x/text v0.12.0 // indirect + golang.org/x/net v0.15.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/term v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect ) diff --git a/go.sum b/go.sum index 11b13ef1..f53a28ff 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,9 @@ github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ= github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1 h1:/iHxaJhsFr0+xVFfbMr5vxz848jyiWuIEDhYq3y5odY= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1 h1:LNHhpdK7hzUcx/k1LIcuh5k7k1LGIWLQfCjaneSj7Fc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1/go.mod h1:uE9zaUfEQT/nbQjVi2IblCG9iaLtZsuYZ8ne+PuQ02M= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0 h1:9kDVnTz3vbfweTqAUmk/a/pH5pWFCHtvRpHYC0G/dcA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0/go.mod h1:3Ug6Qzto9anB6mGlEdgYMDF5zHQ+wwhEaYR4s17PHMw= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= @@ -30,10 +30,10 @@ github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68= github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02 h1:AgcIVYPa6XJnU3phs104wLj8l5GEththEw6+F79YsIY= github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68= @@ -81,14 +81,14 @@ go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 h1:CCriYyAfq1Br1aIYettdH go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= -golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -102,18 +102,18 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= -golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= +golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= diff --git a/install.sh b/install.sh new file mode 100644 index 00000000..9ccd20aa --- /dev/null +++ b/install.sh @@ -0,0 +1,312 @@ +#!/usr/bin/env bash + +# Copyright 2023 The Keyfactor Command Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +: "${BINARY_NAME:=kfutil}" +: "${USE_SUDO:=false}" +: "${VERIFY_CHECKSUM:=true}" + +if [ $EUID -ne 0 ] && [ "$USE_SUDO" = "true" ]; then + : "${KFUTIL_INSTALL_DIR:=/usr/local/bin}" + else + : "${KFUTIL_INSTALL_DIR:=${HOME}/.local/bin}" +fi + + +HAS_CURL="$(type "curl" &>/dev/null && echo true || echo false)" +HAS_WGET="$(type "wget" &>/dev/null && echo true || echo false)" +HAS_JQ="$(type "jq" &>/dev/null && echo true || echo false)" +HAS_OPENSSL="$(type "openssl" &>/dev/null && echo true || echo false)" +HAS_UNZIP="$(type "unzip" &>/dev/null && echo true || echo false)" + +# Runs the given command as root (detects if we are root already) +runAsRoot() { + if [ $EUID -ne 0 ] && [ "$USE_SUDO" = "true" ]; then + sudo "${@}" + else + "${@}" + fi +} + +# fail_trap is executed if an error occurs. +fail_trap() { + result=$? + if [ "$result" != "0" ]; then + if [[ ${#INPUT_ARGUMENTS[@]} -ne 0 ]]; then + echo "Failed to install $BINARY_NAME with the arguments provided: ${INPUT_ARGUMENTS[*]}" + usage + else + echo "Failed to install $BINARY_NAME" + fi + echo -e "For support, go to https://github.com/Keyfactor/kfutil" + fi + cleanup + exit $result +} + +# Get host architecture +initArch() { + ARCH=$(uname -m) + case $ARCH in + armv5*) ARCH="armv5" ;; + armv6*) ARCH="armv6" ;; + armv7*) ARCH="arm" ;; + aarch64) ARCH="arm64" ;; + x86) ARCH="386" ;; + x86_64) ARCH="amd64" ;; + i686) ARCH="386" ;; + i386) ARCH="386" ;; + esac +} + +# Get host OS +initOS() { + OS=$(echo `uname`|tr '[:upper:]' '[:lower:]') + + case "$OS" in + # Minimalist GNU for Windows + mingw*|cygwin*) OS='windows';; + esac +} + +# Verify that the host OS/Arch is supported +verifySupported() { + supported_builds=( + "darwin-amd64" + "darwin-arm64" + "linux-386" + "linux-amd64" + "linux-arm" + "linux-arm64" + "linux-ppc64le" + "linux-s390x" + "windows-amd64" + ) + + match_found=false + for build in "${supported_builds[@]}"; do + if [[ "${build}" == "${OS}-${ARCH}" ]]; then + match_found=true + break + fi + done + + if [[ "${match_found}" == "false" ]]; then + echo "No prebuilt binary for ${OS}-${ARCH}." + echo "To build from source, go to https://github.com/Keyfactor/kfutil" + exit 1 + fi + + if [ "${HAS_CURL}" != "true" ] && [ "${HAS_WGET}" != "true" ]; then + echo "Either curl or wget is required" + exit 1 + fi + + if [ "${HAS_JQ}" != "true" ]; then + echo "jq is required" + exit 1 + fi + + if [ "${HAS_UNZIP}" != "true" ]; then + echo "unzip is required" + exit 1 + fi + + if [ "${VERIFY_CHECKSUM}" == "true" ] && [ "${HAS_OPENSSL}" != "true" ]; then + echo "In order to verify checksum, openssl must first be installed." + echo "Please install openssl or set VERIFY_CHECKSUM=false in your environment." + exit 1 + fi +} + +# checkDesiredVersion checks if the desired version is available. +getVersion() { + local remote_release_url="https://api.github.com/repos/keyfactor/kfutil/releases" + # Get tag from release URL + local releases_response="" + if [ "${HAS_CURL}" == "true" ]; then + releases_response=$(curl -L --silent --show-error --fail "$remote_release_url" 2>&1 || true) + elif [ "${HAS_WGET}" == "true" ]; then + releases_response=$(wget "$remote_release_url" -O - 2>&1 || true) + fi + + # If VERSION is not set, get latest from GitHub API + if [ -z "$VERSION" ]; then + + VERSION=$(echo "$releases_response" | jq '[.[] | select(.prerelease == false)] | max_by(.created_at) | .tag_name' | tr -d '"' | tr -d 'v') + if [ -z "$VERSION" ]; then + printf "Could not retrieve the latest release tag information from %s: %s\n" "${remote_release_url}" "${releases_response}" + exit 1 + fi + else + # Clean up version if prefixed with 'v' + VERSION=$(echo "$VERSION" | tr -d 'v') + + # Verify that the version exists as a release before continuing + if ! echo "$releases_response" | jq '.[] | select(.tag_name == "v'"$VERSION"'")' >/dev/null; then + printf "Cannot find release '%s' for %s.\n" "$VERSION" "$remote_release_url" + exit 1 + else + echo "kfutil version $VERSION exists" + fi + fi +} + +# checkkfutilInstalledVersion checks which version of kfutil is installed and +# if it needs to be changed. +checkkfutilInstalledVersion() { + if [[ -f "${KFUTIL_INSTALL_DIR}/${BINARY_NAME}" ]]; then + local version + version=$("${KFUTIL_INSTALL_DIR}/${BINARY_NAME}" version) + raw_version=$version + version=${raw_version#*version } + version=${version%%\%*} + version=$(echo "$version" | tr -d 'v') + if [[ "$version" == "$VERSION" ]]; then + echo "kfutil ${version} is already installed" + return 0 + else + echo "Changing from kfutil 'v${version}' to 'v${VERSION}'." + return 1 + fi + else + return 1 + fi +} + +# downloadFile downloads the latest binary package and checksums +downloadFile() { + local download_url + local base_url + base_url="https://github.com/Keyfactor/kfutil/releases/download/v${VERSION}" + KFUTIL_DIST="kfutil_${VERSION}_${OS}_${ARCH}.zip" + download_url="${base_url}/${KFUTIL_DIST}" + checksum_url="${base_url}/kfutil_${VERSION}_SHA256SUMS" + + BASE_TEMP_DIR=$(mktemp -dt kfutil-installer-XXXXXX) + KFUTIL_TMP_FILE="$BASE_TEMP_DIR/$KFUTIL_DIST" + KFUTIL_SUM_FILE="$BASE_TEMP_DIR/kfutil_${VERSION}_SHA256SUMS" + + echo "Downloading kfutil ${VERSION} ${OS}-${ARCH}" + if [ "${HAS_CURL}" == "true" ]; then + curl -SsL "$download_url" -o "$KFUTIL_TMP_FILE" + curl -SsL "$checksum_url" -o "$KFUTIL_SUM_FILE" + elif [ "${HAS_WGET}" == "true" ]; then + wget -q -O "$KFUTIL_TMP_FILE" "$download_url" + wget -q -O "$KFUTIL_SUM_FILE" "$checksum_url" + fi +} + +# verifyChecksum verifies the SHA256 checksum of the binary package. +verifyChecksum() { + local sum + local expected_sum + + printf "Verifying checksum... " + sum=$(openssl sha1 -sha256 "${KFUTIL_TMP_FILE}" | awk '{print $2}') + + expected_sum=$(grep "${KFUTIL_DIST}" "${KFUTIL_SUM_FILE}" | cut -d ' ' -f1) + if [ "$sum" != "$expected_sum" ]; then + echo "SHA sum of ${KFUTIL_TMP_FILE} does not match. Aborting." + exit 1 + fi + echo "Done." +} + +# installFile installs the kfutil binary. +installFile() { + local tmp_bin_dir + tmp_bin_dir="${BASE_TEMP_DIR}/bin" + mkdir -p "$tmp_bin_dir" + unzip "$KFUTIL_TMP_FILE" -d "$tmp_bin_dir" >/dev/null + echo "Preparing to install $BINARY_NAME into ${KFUTIL_INSTALL_DIR}" + runAsRoot mkdir -p "$KFUTIL_INSTALL_DIR" + runAsRoot cp "${tmp_bin_dir}/$BINARY_NAME" "$KFUTIL_INSTALL_DIR/$BINARY_NAME" + echo "$BINARY_NAME installed into $KFUTIL_INSTALL_DIR/$BINARY_NAME" + + testVersion +} + +# testVersion tests the installed client to make sure it is working. +testVersion() { + set +e + command -v $BINARY_NAME >/dev/null 2>&1 + if [ "$?" = "1" ]; then + echo "$BINARY_NAME not found. Is $KFUTIL_INSTALL_DIR on your "'$PATH?' + exit 1 + fi + + local version + version=$("${KFUTIL_INSTALL_DIR}/${BINARY_NAME}" version) + raw_version=$version + version=${raw_version#*version } + version=${version%%\%*} + version=$(echo "$version" | tr -d 'v') + + if [[ "$version" == "$VERSION" ]]; then + echo "$BINARY_NAME $version is installed and available." + else + echo "$BINARY_NAME $version is installed, but wanted version $VERSION." + exit 1 + fi + + set -e +} + +cleanup() { + if [[ -d "${BASE_TEMP_DIR:-}" ]]; then + rm -rf "$BASE_TEMP_DIR" + fi +} + +usage() { + echo "Usage: get-kfutil [-v] [-h]" + echo " -v -- kfutil version to install in the form of v0.0.0" + echo " -h -- Print this usage message" + echo "" + echo "Or, set the following environment variables:" + echo " VERSION -- kfutil version to install in the form of v0.0.0" +} + +# Trap if any command in a pipeline exits non-zero +trap "fail_trap" EXIT +set -e + +# Parse command line arguments +INPUT_ARGUMENTS=("$@") +set -u +while getopts v:h option +do + case "${option}" + in + v) VERSION=${OPTARG};; + h) usage && exit 0;; + *) usage && exit 1;; + esac +done +set +u + +initArch +initOS +verifySupported +getVersion + +if ! checkkfutilInstalledVersion; then + downloadFile + verifyChecksum + installFile +fi + +cleanup \ No newline at end of file diff --git a/pkg/version/version.go b/pkg/version/version.go index 093e7405..15fc9392 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -14,4 +14,4 @@ package version -const VERSION = "v1.2.0" +const VERSION = "v1.2.1" diff --git a/readme_source.md b/readme_source.md index 340ba9ef..3649ea97 100644 --- a/readme_source.md +++ b/readme_source.md @@ -1,16 +1,18 @@ ## Quickstart ### Prerequisites: - -- [Github CLI](https://cli.github.com/) -- [zip](https://linuxize.com/post/how-to-unzip-files-in-linux/#installing-unzip) CLI tool, used to unzip the release - files. -- `$HOME/.local/bin` in your `$PATH` and exists. +- [jq](https://stedolan.github.io/jq/download/) CLI tool, used to parse JSON output. +- Either + - [curl](https://curl.se/download.html) CLI tool, used to download the release files. + - OR [wget](https://www.gnu.org/software/wget/) CLI tool, used to download the release files. +- [unzip](https://linuxize.com/post/how-to-unzip-files-in-linux/#installing-unzip) CLI tool, used to unzip the release +- [openssl](https://www.openssl.org/source/) CLI tool, used to validate package checksum. +- `$HOME/.local/bin` in your `$PATH` and exists if not running as root, else `/usr/local/bin` if running as root. ### Installation: ```bash -bash <(curl -s https://raw.githubusercontent.com/Keyfactor/kfutil/main/gh-dl-release.sh) +bash <(curl -s https://raw.githubusercontent.com/Keyfactor/kfutil/main/install.sh) ```` ### Environmental Variables