Skip to content

Commit

Permalink
v1.5.0 Squash (#208)
Browse files Browse the repository at this point in the history
* fix(store-types): Store type create omits empty fields.
* fix(pam-types): `types-list` does not crash on nil httpResponse.
* chore: Update license year, and bump AKV runner go version
* fix(tests): Remove "ProviderTypeParams" from pam-types tests for KFC v11.0.0+
* fix(tests): Fix nil pointer issues on tests.
* feat(stores): `stores export` now allows for `--all` and user interactive exports
* feat(ci): Add KFC v12.0.0 tests.  
* fix(storetypes): Update all store type definitions.
* fix(storetypes): Update `AzureAppGw`, `CiscoAsa`, `CitrixAdc`, `PaloAlto`, and `WinSql`
* fix(store-types): Update `BIPCamera` definition with correct `Capability` and remove unsupported operations.
* fix(cli): `stores export` supports paging.
* feat(cli): Add flag `--offline` that will prevent `kfutil` from reaching out to GitHub for latest releases of resources like store type definitions.
* chore(docs): Update docs with `--offline` flag
* fix(cli): Set zerolog to disabled on init to prevent logs from going out before the `--debug` flag is evaluated.
* fix(cli): Use embedded store-types data on init to prevent online lookup until called.
  • Loading branch information
spbsoluble authored Sep 10, 2024
1 parent 8113674 commit b61b2a3
Show file tree
Hide file tree
Showing 72 changed files with 6,743 additions and 752 deletions.
165 changes: 89 additions & 76 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: go tests

on:
# workflow_dispatch:
# workflow_run:
# workflows:
# - "Check and Update Package Version"
# types:
# - completed
# branches:
# - "*"
# workflow_dispatch:
# workflow_run:
# workflows:
# - "Check and Update Package Version"
# types:
# - completed
# branches:
# - "*"
push:
branches:
- '*'
Expand Down Expand Up @@ -142,25 +142,6 @@ jobs:
run: echo "Running tests for KF 11.x.x"

### Store Type Tests
Test_StoreTypes_KFC_11_2_0:
runs-on: ubuntu-latest
needs:
- build
- kf_11_x_x
env:
SECRET_NAME: "command-config-1120-clean"
KEYFACTOR_HOSTNAME: "int1120-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_11_1_2:
runs-on: ubuntu-latest
needs:
Expand All @@ -182,15 +163,15 @@ jobs:
### Store Tests
Test_Stores_KFC_11_2_0:
Test_Stores_KFC_11_1_2:
runs-on: ubuntu-latest
needs:
- build
- kf_11_x_x
- Test_StoreTypes_KFC_11_2_0
- Test_StoreTypes_KFC_11_1_2
env:
SECRET_NAME: "command-config-1120"
KEYFACTOR_HOSTNAME: "integrations1120-lab.kfdelivery.com"
SECRET_NAME: "command-config-1112"
KEYFACTOR_HOSTNAME: "integrations1112-lab.kfdelivery.com"
KEYFACTOR_DOMAIN: "command"
KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }}
KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }}
Expand All @@ -199,7 +180,9 @@ jobs:
uses: actions/checkout@v4
- name: Run tests
run: go test -v ./cmd -run "^Test_Stores_*"
Test_Stores_KFC_11_1_2:

### PAM Tests
Test_PAM_KFC_11_1_2:
runs-on: ubuntu-latest
needs:
- build
Expand All @@ -215,18 +198,50 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Run tests
run: go test -v ./cmd -run "^Test_Stores_*"
run: |
unset KFUTIL_DEBUG
go test -v ./cmd -run "^Test_PAM*"
### PAM Tests
Test_PAM_KFC_11_2_0:
### PAM Tests AKV Auth Provider
Test_AKV_PAM_KFC_11_1_2:
runs-on: self-hosted
needs:
- Test_PAM_KFC_11_1_2
env:
SECRET_NAME: "command-config-1112-az"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
- 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 12.x.x
### Store Type Tests
Test_StoreTypes_KFC_12_2_0:
runs-on: ubuntu-latest
needs:
- build
- kf_11_x_x
- Test_StoreTypes_KFC_11_2_0
env:
SECRET_NAME: "command-config-1120"
KEYFACTOR_HOSTNAME: "integrations1120-lab.kfdelivery.com"
SECRET_NAME: "command-config-1220-clean"
KEYFACTOR_HOSTNAME: "int1220-test-clean.kfdelivery.com"
KEYFACTOR_DOMAIN: "command"
KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }}
KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }}
Expand All @@ -236,64 +251,57 @@ jobs:
- name: Run tests
run: |
unset KFUTIL_DEBUG
go test -v ./cmd -run "^Test_PAM*"
go test -v ./cmd -run "^Test_StoreTypes*"
Test_PAM_KFC_11_1_2:
### Store Tests
Test_Stores_KFC_12_2_0:
runs-on: ubuntu-latest
needs:
- build
- kf_11_x_x
- Test_StoreTypes_KFC_11_1_2
- Test_StoreTypes_KFC_12_2_0
env:
SECRET_NAME: "command-config-1112"
KEYFACTOR_HOSTNAME: "integrations1112-lab.kfdelivery.com"
SECRET_NAME: "command-config-1220"
KEYFACTOR_HOSTNAME: "integrations1220-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*"
run: go test -v ./cmd -run "^Test_Stores_*"

### PAM Tests AKV Auth Provider
Test_AKV_PAM_KFC_11_2_0:
runs-on: self-hosted
### PAM Tests
Test_PAM_KFC_12_2_0:
runs-on: ubuntu-latest
needs:
- Test_PAM_KFC_11_2_0
- build
- kf_11_x_x
- Test_StoreTypes_KFC_12_2_0
env:
SECRET_NAME: "command-config-1120-az"
SECRET_NAME: "command-config-1220"
KEYFACTOR_HOSTNAME: "integrations1220-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: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
- 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: |
unset KFUTIL_DEBUG
go test -v ./cmd -run "^Test_PAM*"
Test_AKV_PAM_KFC_11_1_2:
### PAM Tests AKV Auth Provider
Test_AKV_PAM_KFC_12_2_0:
runs-on: self-hosted
needs:
- Test_PAM_KFC_11_1_2
- Test_PAM_KFC_12_2_0
env:
SECRET_NAME: "command-config-1112-az"
SECRET_NAME: "command-config-1220-az"
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -315,16 +323,21 @@ jobs:
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)
runs-on: ubuntu-latest
steps:
- name: Test Quick Install Script
run: |
sudo apt update && sudo apt upgrade -y && sudo apt install -y curl wget unzip jq openssl && sudo apt clean
echo curl -s "https://raw.githubusercontent.com/Keyfactor/kfutil/${GITHUB_REF_NAME}/install.sh"
GITHUB_REF_NAME_ENCODED=$(echo -n "${GITHUB_REF_NAME}" | jq -sRr @uri)
VERIFY_CHECKSUM=0
bash <(curl -s "https://raw.githubusercontent.com/Keyfactor/kfutil/${GITHUB_REF_NAME_ENCODED}/install.sh")
which kfutil
kfutil version
rm $(which kfutil)
# Package Tests
Test_Kfutil_pkg:
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# v1.5.0

## Features

### CLI

- The CLI will now embed the store_type definitions for each release of `kfutil`.
- Add global flag `--offline` to allow for offline mode. This will prevent the CLI from making requests to GitHub for
store types and store type templates and will use embedded store types and templates instead.

## Fixes

### Stores

- `stores export --all`: Correctly paginates through all stores when exporting.

### CLI

- No longer log before the `--debug` flag is evaluated.

# v1.4.0
## Features

Expand Down
28 changes: 15 additions & 13 deletions cmd/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@ package cmd
import "fmt"

const (
ColorRed = "\033[31m"
ColorWhite = "\033[37m"
DefaultAPIPath = "KeyfactorAPI"
DefaultConfigFileName = "command_config.json"
FailedAuthMsg = "Login failed!"
SuccessfulAuthMsg = "Login successful!"
XKeyfactorRequestedWith = "APIClient"
XKeyfactorApiVersion = "1"
FlagGitRef = "git-ref"
FlagFromFile = "from-file"
DebugFuncEnter = "entered: %s"
DebugFuncExit = "exiting: %s"
DebugFuncCall = "calling: %s"
ColorRed = "\033[31m"
ColorWhite = "\033[37m"
DefaultAPIPath = "KeyfactorAPI"
DefaultConfigFileName = "command_config.json"
DefaultStoreTypesFileName = "store_types.json"
FailedAuthMsg = "Login failed!"
SuccessfulAuthMsg = "Login successful!"
XKeyfactorRequestedWith = "APIClient"
XKeyfactorApiVersion = "1"
FlagGitRef = "git-ref"
FlagFromFile = "from-file"
DebugFuncEnter = "entered: %s"
DebugFuncExit = "exiting: %s"
DebugFuncCall = "calling: %s"
MinHttpTimeout = 3
)

var ProviderTypeChoices = []string{
Expand Down
12 changes: 7 additions & 5 deletions cmd/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/google/uuid"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"io"
"net/http"
"os"
"path/filepath"
"strconv"
"time"

"github.com/google/uuid"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)

func boolToPointer(b bool) *bool {
Expand Down Expand Up @@ -180,7 +181,6 @@ func getCurrentTime(f string) string {

func informDebug(debugFlag bool) {
debugModeEnabled := checkDebug(debugFlag)
zerolog.SetGlobalLevel(zerolog.Disabled)
if debugModeEnabled {
//zerolog.SetGlobalLevel(zerolog.InfoLevel)
zerolog.SetGlobalLevel(zerolog.DebugLevel)
Expand All @@ -189,8 +189,10 @@ func informDebug(debugFlag bool) {

func initLogger() {
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
zerolog.SetGlobalLevel(zerolog.Disabled) // default to disabled
log.Logger = log.With().Caller().Logger()
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339})

}

func intToPointer(i int) *int {
Expand Down
Loading

0 comments on commit b61b2a3

Please sign in to comment.