Skip to content

Commit e4051e0

Browse files
authored
Merge pull request #209 from Keyfactor/ab#63022
v1.5.0
2 parents 05690f3 + b61b2a3 commit e4051e0

File tree

73 files changed

+6744
-752
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+6744
-752
lines changed

.github/workflows/tests.yml

Lines changed: 89 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: go tests
22

33
on:
4-
# workflow_dispatch:
5-
# workflow_run:
6-
# workflows:
7-
# - "Check and Update Package Version"
8-
# types:
9-
# - completed
10-
# branches:
11-
# - "*"
4+
# workflow_dispatch:
5+
# workflow_run:
6+
# workflows:
7+
# - "Check and Update Package Version"
8+
# types:
9+
# - completed
10+
# branches:
11+
# - "*"
1212
push:
1313
branches:
1414
- '*'
@@ -142,25 +142,6 @@ jobs:
142142
run: echo "Running tests for KF 11.x.x"
143143

144144
### Store Type Tests
145-
Test_StoreTypes_KFC_11_2_0:
146-
runs-on: ubuntu-latest
147-
needs:
148-
- build
149-
- kf_11_x_x
150-
env:
151-
SECRET_NAME: "command-config-1120-clean"
152-
KEYFACTOR_HOSTNAME: "int1120-test-clean.kfdelivery.com"
153-
KEYFACTOR_DOMAIN: "command"
154-
KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }}
155-
KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }}
156-
steps:
157-
- name: Checkout code
158-
uses: actions/checkout@v4
159-
- name: Run tests
160-
run: |
161-
unset KFUTIL_DEBUG
162-
go test -v ./cmd -run "^Test_StoreTypes*"
163-
164145
Test_StoreTypes_KFC_11_1_2:
165146
runs-on: ubuntu-latest
166147
needs:
@@ -182,15 +163,15 @@ jobs:
182163
183164
184165
### Store Tests
185-
Test_Stores_KFC_11_2_0:
166+
Test_Stores_KFC_11_1_2:
186167
runs-on: ubuntu-latest
187168
needs:
188169
- build
189170
- kf_11_x_x
190-
- Test_StoreTypes_KFC_11_2_0
171+
- Test_StoreTypes_KFC_11_1_2
191172
env:
192-
SECRET_NAME: "command-config-1120"
193-
KEYFACTOR_HOSTNAME: "integrations1120-lab.kfdelivery.com"
173+
SECRET_NAME: "command-config-1112"
174+
KEYFACTOR_HOSTNAME: "integrations1112-lab.kfdelivery.com"
194175
KEYFACTOR_DOMAIN: "command"
195176
KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }}
196177
KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }}
@@ -199,7 +180,9 @@ jobs:
199180
uses: actions/checkout@v4
200181
- name: Run tests
201182
run: go test -v ./cmd -run "^Test_Stores_*"
202-
Test_Stores_KFC_11_1_2:
183+
184+
### PAM Tests
185+
Test_PAM_KFC_11_1_2:
203186
runs-on: ubuntu-latest
204187
needs:
205188
- build
@@ -215,18 +198,50 @@ jobs:
215198
- name: Checkout code
216199
uses: actions/checkout@v4
217200
- name: Run tests
218-
run: go test -v ./cmd -run "^Test_Stores_*"
201+
run: |
202+
unset KFUTIL_DEBUG
203+
go test -v ./cmd -run "^Test_PAM*"
219204
220-
### PAM Tests
221-
Test_PAM_KFC_11_2_0:
205+
206+
### PAM Tests AKV Auth Provider
207+
Test_AKV_PAM_KFC_11_1_2:
208+
runs-on: self-hosted
209+
needs:
210+
- Test_PAM_KFC_11_1_2
211+
env:
212+
SECRET_NAME: "command-config-1112-az"
213+
steps:
214+
- name: Checkout code
215+
uses: actions/checkout@v4
216+
- name: Set up Go
217+
uses: actions/setup-go@v5
218+
with:
219+
go-version: "1.21"
220+
- name: Install dependencies
221+
run: go mod download && go mod tidy
222+
- name: Get secret from Azure Key Vault
223+
run: |
224+
. ./examples/auth/akv/akv_auth.sh
225+
cat $HOME/.keyfactor/command_config.json
226+
- name: Install kfutil
227+
run: |
228+
make install
229+
- name: Run tests
230+
run: |
231+
go test -v ./cmd -run "^Test_PAM*"
232+
233+
234+
235+
## KFC 12.x.x
236+
### Store Type Tests
237+
Test_StoreTypes_KFC_12_2_0:
222238
runs-on: ubuntu-latest
223239
needs:
224240
- build
225241
- kf_11_x_x
226-
- Test_StoreTypes_KFC_11_2_0
227242
env:
228-
SECRET_NAME: "command-config-1120"
229-
KEYFACTOR_HOSTNAME: "integrations1120-lab.kfdelivery.com"
243+
SECRET_NAME: "command-config-1220-clean"
244+
KEYFACTOR_HOSTNAME: "int1220-test-clean.kfdelivery.com"
230245
KEYFACTOR_DOMAIN: "command"
231246
KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }}
232247
KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }}
@@ -236,64 +251,57 @@ jobs:
236251
- name: Run tests
237252
run: |
238253
unset KFUTIL_DEBUG
239-
go test -v ./cmd -run "^Test_PAM*"
254+
go test -v ./cmd -run "^Test_StoreTypes*"
240255
241256
242-
Test_PAM_KFC_11_1_2:
257+
### Store Tests
258+
Test_Stores_KFC_12_2_0:
243259
runs-on: ubuntu-latest
244260
needs:
245261
- build
246262
- kf_11_x_x
247-
- Test_StoreTypes_KFC_11_1_2
263+
- Test_StoreTypes_KFC_12_2_0
248264
env:
249-
SECRET_NAME: "command-config-1112"
250-
KEYFACTOR_HOSTNAME: "integrations1112-lab.kfdelivery.com"
265+
SECRET_NAME: "command-config-1220"
266+
KEYFACTOR_HOSTNAME: "integrations1220-lab.kfdelivery.com"
251267
KEYFACTOR_DOMAIN: "command"
252268
KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }}
253269
KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }}
254270
steps:
255271
- name: Checkout code
256272
uses: actions/checkout@v4
257273
- name: Run tests
258-
run: |
259-
unset KFUTIL_DEBUG
260-
go test -v ./cmd -run "^Test_PAM*"
261-
274+
run: go test -v ./cmd -run "^Test_Stores_*"
262275

263-
### PAM Tests AKV Auth Provider
264-
Test_AKV_PAM_KFC_11_2_0:
265-
runs-on: self-hosted
276+
### PAM Tests
277+
Test_PAM_KFC_12_2_0:
278+
runs-on: ubuntu-latest
266279
needs:
267-
- Test_PAM_KFC_11_2_0
280+
- build
281+
- kf_11_x_x
282+
- Test_StoreTypes_KFC_12_2_0
268283
env:
269-
SECRET_NAME: "command-config-1120-az"
284+
SECRET_NAME: "command-config-1220"
285+
KEYFACTOR_HOSTNAME: "integrations1220-lab.kfdelivery.com"
286+
KEYFACTOR_DOMAIN: "command"
287+
KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }}
288+
KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }}
270289
steps:
271290
- name: Checkout code
272291
uses: actions/checkout@v4
273-
- name: Set up Go
274-
uses: actions/setup-go@v5
275-
with:
276-
go-version: "1.21"
277-
- name: Install dependencies
278-
run: go mod download && go mod tidy
279-
- name: Get secret from Azure Key Vault
280-
run: |
281-
. ./examples/auth/akv/akv_auth.sh
282-
cat $HOME/.keyfactor/command_config.json
283-
- name: Install kfutil
284-
run: |
285-
make install
286292
- name: Run tests
287293
run: |
294+
unset KFUTIL_DEBUG
288295
go test -v ./cmd -run "^Test_PAM*"
289296
290297
291-
Test_AKV_PAM_KFC_11_1_2:
298+
### PAM Tests AKV Auth Provider
299+
Test_AKV_PAM_KFC_12_2_0:
292300
runs-on: self-hosted
293301
needs:
294-
- Test_PAM_KFC_11_1_2
302+
- Test_PAM_KFC_12_2_0
295303
env:
296-
SECRET_NAME: "command-config-1112-az"
304+
SECRET_NAME: "command-config-1220-az"
297305
steps:
298306
- name: Checkout code
299307
uses: actions/checkout@v4
@@ -315,16 +323,21 @@ jobs:
315323
go test -v ./cmd -run "^Test_PAM*"
316324
317325
326+
318327
# Tester Install Script
319328
Test_Install_Script:
320-
runs-on: ubuntu-latest
321-
steps:
322-
- name: Test Quick Install Script
323-
run: |
324-
bash <(curl -s https://raw.githubusercontent.com/Keyfactor/kfutil/${GITHUB_REF_NAME}/install.sh)
325-
which kfutil
326-
kfutil version
327-
rm $(which kfutil)
329+
runs-on: ubuntu-latest
330+
steps:
331+
- name: Test Quick Install Script
332+
run: |
333+
sudo apt update && sudo apt upgrade -y && sudo apt install -y curl wget unzip jq openssl && sudo apt clean
334+
echo curl -s "https://raw.githubusercontent.com/Keyfactor/kfutil/${GITHUB_REF_NAME}/install.sh"
335+
GITHUB_REF_NAME_ENCODED=$(echo -n "${GITHUB_REF_NAME}" | jq -sRr @uri)
336+
VERIFY_CHECKSUM=0
337+
bash <(curl -s "https://raw.githubusercontent.com/Keyfactor/kfutil/${GITHUB_REF_NAME_ENCODED}/install.sh")
338+
which kfutil
339+
kfutil version
340+
rm $(which kfutil)
328341
329342
# Package Tests
330343
Test_Kfutil_pkg:

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
# v1.5.0
2+
3+
## Features
4+
5+
### CLI
6+
7+
- The CLI will now embed the store_type definitions for each release of `kfutil`.
8+
- Add global flag `--offline` to allow for offline mode. This will prevent the CLI from making requests to GitHub for
9+
store types and store type templates and will use embedded store types and templates instead.
10+
11+
## Fixes
12+
13+
### Stores
14+
15+
- `stores export --all`: Correctly paginates through all stores when exporting.
16+
17+
### CLI
18+
19+
- No longer log before the `--debug` flag is evaluated.
20+
121
# v1.4.0
222
## Features
323

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,3 +440,4 @@ alternatively you can specify the parent command
440440
cobra-cli add <my-new-command> -p '<parent>Cmd'
441441
```
442442
443+

cmd/constants.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,21 @@ package cmd
1616
import "fmt"
1717

1818
const (
19-
ColorRed = "\033[31m"
20-
ColorWhite = "\033[37m"
21-
DefaultAPIPath = "KeyfactorAPI"
22-
DefaultConfigFileName = "command_config.json"
23-
FailedAuthMsg = "Login failed!"
24-
SuccessfulAuthMsg = "Login successful!"
25-
XKeyfactorRequestedWith = "APIClient"
26-
XKeyfactorApiVersion = "1"
27-
FlagGitRef = "git-ref"
28-
FlagFromFile = "from-file"
29-
DebugFuncEnter = "entered: %s"
30-
DebugFuncExit = "exiting: %s"
31-
DebugFuncCall = "calling: %s"
19+
ColorRed = "\033[31m"
20+
ColorWhite = "\033[37m"
21+
DefaultAPIPath = "KeyfactorAPI"
22+
DefaultConfigFileName = "command_config.json"
23+
DefaultStoreTypesFileName = "store_types.json"
24+
FailedAuthMsg = "Login failed!"
25+
SuccessfulAuthMsg = "Login successful!"
26+
XKeyfactorRequestedWith = "APIClient"
27+
XKeyfactorApiVersion = "1"
28+
FlagGitRef = "git-ref"
29+
FlagFromFile = "from-file"
30+
DebugFuncEnter = "entered: %s"
31+
DebugFuncExit = "exiting: %s"
32+
DebugFuncCall = "calling: %s"
33+
MinHttpTimeout = 3
3234
)
3335

3436
var ProviderTypeChoices = []string{

cmd/helpers.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@ import (
1919
"encoding/json"
2020
"errors"
2121
"fmt"
22-
"github.com/google/uuid"
23-
"github.com/rs/zerolog"
24-
"github.com/rs/zerolog/log"
25-
"github.com/spf13/cobra"
2622
"io"
2723
"net/http"
2824
"os"
2925
"path/filepath"
3026
"strconv"
3127
"time"
28+
29+
"github.com/google/uuid"
30+
"github.com/rs/zerolog"
31+
"github.com/rs/zerolog/log"
32+
"github.com/spf13/cobra"
3233
)
3334

3435
func boolToPointer(b bool) *bool {
@@ -180,7 +181,6 @@ func getCurrentTime(f string) string {
180181

181182
func informDebug(debugFlag bool) {
182183
debugModeEnabled := checkDebug(debugFlag)
183-
zerolog.SetGlobalLevel(zerolog.Disabled)
184184
if debugModeEnabled {
185185
//zerolog.SetGlobalLevel(zerolog.InfoLevel)
186186
zerolog.SetGlobalLevel(zerolog.DebugLevel)
@@ -189,8 +189,10 @@ func informDebug(debugFlag bool) {
189189

190190
func initLogger() {
191191
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
192+
zerolog.SetGlobalLevel(zerolog.Disabled) // default to disabled
192193
log.Logger = log.With().Caller().Logger()
193194
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339})
195+
194196
}
195197

196198
func intToPointer(i int) *int {

0 commit comments

Comments
 (0)