Skip to content

Commit be1e8e4

Browse files
authored
Merge 0be5cbc into 12ad39d
2 parents 12ad39d + 0be5cbc commit be1e8e4

File tree

10 files changed

+2310
-348
lines changed

10 files changed

+2310
-348
lines changed

.github/workflows/tests.yml

Lines changed: 69 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -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,6 +323,7 @@ jobs:
315323
go test -v ./cmd -run "^Test_PAM*"
316324
317325
326+
318327
# Tester Install Script
319328
Test_Install_Script:
320329
runs-on: ubuntu-latest

.github/workflows/update-stores.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152
if: ${{ env.UPDATE_FILE == 'T' && env.PR_BRANCH == 'create' }}
153153
uses: Keyfactor/[email protected]
154154
env:
155-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155+
GITHUB_TOKEN: ${{ secrets.SDK_SYNC_PAT }}
156156
with:
157157
add: store_types.json --force
158158
message: Update store_types.json for ${{env.KFUTIL_ARG}}:${{env.TARGET_REPO_BRANCH}}
@@ -165,7 +165,7 @@ jobs:
165165
if: ${{ env.UPDATE_FILE == 'T' && env.PR_BRANCH == 'commit' }}
166166
uses: Keyfactor/[email protected]
167167
env:
168-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168+
GITHUB_TOKEN: ${{ secrets.SDK_SYNC_PAT }}
169169
with:
170170
add: store_types.json --force
171171
message: Update store_types.json for ${{env.KFUTIL_ARG}}:${{env.TARGET_REPO_BRANCH}}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v1.4.1
2+
## Fixes
3+
- `stores export --all`: Now properly exports all stores where previously it would only export the first page of stores.
4+
15
# v1.4.0
26
## Features
37

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/storeTypes.go

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ package cmd
1717
import (
1818
"encoding/json"
1919
"fmt"
20-
"github.com/AlecAivazis/survey/v2"
21-
"github.com/Keyfactor/keyfactor-go-client/v2/api"
22-
"github.com/rs/zerolog/log"
23-
"github.com/spf13/cobra"
2420
"io"
2521
"net/http"
2622
"os"
2723
"sort"
2824
"strings"
25+
26+
"github.com/AlecAivazis/survey/v2"
27+
"github.com/Keyfactor/keyfactor-go-client/v2/api"
28+
"github.com/rs/zerolog/log"
29+
"github.com/spf13/cobra"
2930
)
3031

3132
var storeTypesCmd = &cobra.Command{
@@ -102,6 +103,14 @@ var storesTypeCreateCmd = &cobra.Command{
102103
}
103104
storeTypeIsValid := false
104105

106+
log.Debug().Str("storeType", storeType).
107+
Bool("listTypes", listTypes).
108+
Str("storeTypeConfigFile", storeTypeConfigFile).
109+
Bool("creatAll", creatAll).
110+
Str("gitRef", gitRef).
111+
Strs("validStoreTypes", validStoreTypes).
112+
Msg("create command flags")
113+
105114
if listTypes {
106115
fmt.Println("Available store types:")
107116
sort.Strings(validStoreTypes)
@@ -138,12 +147,16 @@ var storesTypeCreateCmd = &cobra.Command{
138147
}
139148
for _, v := range validStoreTypes {
140149
if strings.EqualFold(v, strings.ToUpper(storeType)) || creatAll {
141-
log.Printf("[DEBUG] Valid store type: %s", storeType)
150+
log.Debug().Str("storeType", storeType).Msg("Store type is valid")
142151
storeTypeIsValid = true
143152
break
144153
}
145154
}
146155
if !storeTypeIsValid {
156+
log.Error().
157+
Str("storeType", storeType).
158+
Bool("isValid", storeTypeIsValid).
159+
Msg("Invalid store type")
147160
fmt.Printf("ERROR: Invalid store type: %s\nValid types are:\n", storeType)
148161
for _, st := range validStoreTypes {
149162
fmt.Println(fmt.Sprintf("\t%s", st))
@@ -292,7 +305,10 @@ var storesTypeDeleteCmd = &cobra.Command{
292305
}
293306

294307
if dryRun {
295-
outputResult(fmt.Sprintf("dry run delete called on certificate store type (%v) with ID: %d", st, id), outputFormat)
308+
outputResult(
309+
fmt.Sprintf("dry run delete called on certificate store type (%v) with ID: %d", st, id),
310+
outputFormat,
311+
)
296312
} else {
297313
log.Debug().Interface("storeType", st).
298314
Int("id", id).
@@ -410,7 +426,12 @@ func getStoreTypesInternet(gitRef string) (map[string]interface{}, error) {
410426
//resp, err := http.Get("https://raw.githubusercontent.com/keyfactor/kfutil/main/store_types.json")
411427
//resp, err := http.Get("https://raw.githubusercontent.com/keyfactor/kfctl/master/storetypes/storetypes.json")
412428

413-
resp, rErr := http.Get(fmt.Sprintf("https://raw.githubusercontent.com/Keyfactor/kfutil/%s/store_types.json", gitRef))
429+
resp, rErr := http.Get(
430+
fmt.Sprintf(
431+
"https://raw.githubusercontent.com/Keyfactor/kfutil/%s/store_types.json",
432+
gitRef,
433+
),
434+
)
414435
if rErr != nil {
415436
return nil, rErr
416437
}
@@ -489,7 +510,13 @@ func init() {
489510

490511
// GET store type templates
491512
storeTypesCmd.AddCommand(fetchStoreTypesCmd)
492-
fetchStoreTypesCmd.Flags().StringVarP(&gitRef, FlagGitRef, "b", "main", "The git branch or tag to reference when pulling store-types from the internet.")
513+
fetchStoreTypesCmd.Flags().StringVarP(
514+
&gitRef,
515+
FlagGitRef,
516+
"b",
517+
"main",
518+
"The git branch or tag to reference when pulling store-types from the internet.",
519+
)
493520

494521
// LIST command
495522
storeTypesCmd.AddCommand(storesTypesListCmd)
@@ -504,10 +531,28 @@ func init() {
504531
var storeTypeName string
505532
var storeTypeID int
506533
storeTypesCmd.AddCommand(storesTypeCreateCmd)
507-
storesTypeCreateCmd.Flags().StringVarP(&storeTypeName, "name", "n", "", "Short name of the certificate store type to get. Valid choices are: "+validTypesString)
534+
storesTypeCreateCmd.Flags().StringVarP(
535+
&storeTypeName,
536+
"name",
537+
"n",
538+
"",
539+
"Short name of the certificate store type to get. Valid choices are: "+validTypesString,
540+
)
508541
storesTypeCreateCmd.Flags().BoolVarP(&listValidStoreTypes, "list", "l", false, "List valid store types.")
509-
storesTypeCreateCmd.Flags().StringVarP(&filePath, "from-file", "f", "", "Path to a JSON file containing certificate store type data for a single store.")
510-
storesTypeCreateCmd.Flags().StringVarP(&gitRef, FlagGitRef, "b", "main", "The git branch or tag to reference when pulling store-types from the internet.")
542+
storesTypeCreateCmd.Flags().StringVarP(
543+
&filePath,
544+
"from-file",
545+
"f",
546+
"",
547+
"Path to a JSON file containing certificate store type data for a single store.",
548+
)
549+
storesTypeCreateCmd.Flags().StringVarP(
550+
&gitRef,
551+
FlagGitRef,
552+
"b",
553+
"main",
554+
"The git branch or tag to reference when pulling store-types from the internet.",
555+
)
511556
storesTypeCreateCmd.Flags().BoolVarP(&createAll, "all", "a", false, "Create all store types.")
512557

513558
// UPDATE command
@@ -519,7 +564,13 @@ func init() {
519564
var dryRun bool
520565
storeTypesCmd.AddCommand(storesTypeDeleteCmd)
521566
storesTypeDeleteCmd.Flags().IntVarP(&storeTypeID, "id", "i", -1, "ID of the certificate store type to delete.")
522-
storesTypeDeleteCmd.Flags().StringVarP(&storeTypeName, "name", "n", "", "Name of the certificate store type to delete.")
567+
storesTypeDeleteCmd.Flags().StringVarP(
568+
&storeTypeName,
569+
"name",
570+
"n",
571+
"",
572+
"Name of the certificate store type to delete.",
573+
)
523574
storesTypeDeleteCmd.Flags().BoolVarP(&dryRun, "dry-run", "t", false, "Specifies whether to perform a dry run.")
524575
storesTypeDeleteCmd.MarkFlagsMutuallyExclusive("id", "name")
525576
storesTypeDeleteCmd.Flags().BoolVarP(&deleteAll, "all", "a", false, "Delete all store types.")

0 commit comments

Comments
 (0)