Skip to content

Commit 2fce868

Browse files
committed
added export and import functions to README
1 parent a3f3d78 commit 2fce868

File tree

4 files changed

+98
-3
lines changed

4 files changed

+98
-3
lines changed

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,40 @@ kfutil stores inventory remove \
364364
--cn <additional cert subject name>
365365
```
366366
367+
### Export Instance Data
368+
369+
For full documentation, see [export](docs/kfutil_export.md).
370+
371+
Export select instance data to JSON file:
372+
373+
```bash
374+
# export only collections, metadata, and roles
375+
kfutil export --collections --metadata --roles --file <path to JSON file>
376+
```
377+
378+
Export all exportable instance data to JSON file:
379+
380+
```bash
381+
kfutil export --all --file <path to JSON file>
382+
```
383+
384+
### Import Instance Data
385+
386+
For full documentation, see [import](docs/kfutil_import.md).
387+
388+
Import select instance data from exported JSON file:
389+
390+
```bash
391+
# export only collections, metadata, and roles
392+
kfutil import --collections --metadata --roles --file <path to JSON file>
393+
```
394+
395+
Import all importable instance data from exported JSON file:
396+
397+
```bash
398+
kfutil import --all --file <path to JSON file>
399+
```
400+
367401
## Development
368402
369403
This CLI developed using [cobra](https://umarcor.github.io/cobra/)
@@ -379,4 +413,3 @@ alternatively you can specify the parent command
379413
```bash
380414
cobra-cli add <my-new-command> -p '<parent>Cmd'
381415
```
382-

cmd/import.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ func importNetworks(networks []keyfactor_command_client_api.KeyfactorApiModelsSs
167167
}
168168
}
169169

170-
func findMatchingTempIds(exportedWorkflowDef exportKeyfactorApiModelsWorkflowsDefinitionCreateRequest, kfClient *keyfactor_command_client_api.APIClient) *string {
170+
// identify matching templates between instances by name, then return the template Id of the matching template in the import instance
171+
func findMatchingTemplates(exportedWorkflowDef exportKeyfactorApiModelsWorkflowsDefinitionCreateRequest, kfClient *keyfactor_command_client_api.APIClient) *string {
171172
importInstanceTemplates, _, _ := kfClient.TemplateApi.TemplateGetTemplates(context.Background()).XKeyfactorRequestedWith(xKeyfactorRequestedWith).XKeyfactorApiVersion(xKeyfactorApiVersion).Execute()
172173
for _, template := range importInstanceTemplates {
173174
importInstTempNameJson, _ := json.Marshal(template.TemplateName)
@@ -190,7 +191,7 @@ func importWorkflowDefinitions(workflowDefs []exportKeyfactorApiModelsWorkflowsD
190191
fmt.Printf("Error: %s\n", jErr)
191192
log.Fatalf("Error: %s", jErr)
192193
}
193-
newTemplateId := findMatchingTempIds(workflowDef, kfClient)
194+
newTemplateId := findMatchingTemplates(workflowDef, kfClient)
194195
if newTemplateId != nil {
195196
workflowDefReq.Key = newTemplateId
196197
}
@@ -204,6 +205,7 @@ func importWorkflowDefinitions(workflowDefs []exportKeyfactorApiModelsWorkflowsD
204205
}
205206
}
206207

208+
// check for built-in report discrepancies between instances, return the report id of reports that need to be updated in import instance
207209
func checkBuiltInReportDiffs(exportedReport exportModelsReport, kfClient *keyfactor_command_client_api.APIClient) *int32 {
208210
importInstanceReports, _, _ := kfClient.ReportsApi.ReportsQueryReports(context.Background()).XKeyfactorRequestedWith(xKeyfactorRequestedWith).XKeyfactorApiVersion(xKeyfactorApiVersion).Execute()
209211
//check if built in report was modified from default in exported instance; if modified, update built-in report in new instance

docs/kfutil_export.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## kfutil export
2+
3+
Keyfactor export utilities.
4+
5+
### Synopsis
6+
7+
A collections of APIs and utilities for exporting Keyfactor instance data.
8+
9+
### Options
10+
11+
```
12+
-a, --all export all exportable data to JSON file
13+
-c, --collections export collections to JSON file
14+
-d, --denied-alerts export denied cert alerts to JSON file
15+
-e, --expiration-alerts export expiration cert alerts to JSON file
16+
-f, --file string export JSON to a specified filepath
17+
-h, --help help for export
18+
-i, --issued-alerts export issued cert alerts to JSON file
19+
-m, --metadata export metadata to JSON file
20+
-n, --networks export SSL networks to JSON file
21+
-p, --pending-alerts export pending cert alerts to JSON file
22+
-r, --reports export reports to JSON file
23+
-s, --security-roles export security roles to JSON file
24+
-w, --workflow-definitions export workflow definitions to JSON file
25+
```
26+
27+
### SEE ALSO
28+
29+
* [kfutil](kfutil.md) - Keyfactor CLI utilities
30+

docs/kfutil_import.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## kfutil import
2+
3+
Keyfactor import utilities.
4+
5+
### Synopsis
6+
7+
A collections of APIs and utilities for importing Keyfactor instance data.
8+
9+
### Options
10+
11+
```
12+
-a, --all import all importable data to JSON file
13+
-c, --collections import collections to JSON file
14+
-d, --denied-alerts import denied cert alerts to JSON file
15+
-e, --expiration-alerts import expiration cert alerts to JSON file
16+
-f, --file string import JSON to a specified filepath
17+
-h, --help help for import
18+
-i, --issued-alerts import issued cert alerts to JSON file
19+
-m, --metadata import metadata to JSON file
20+
-n, --networks import SSL networks to JSON file
21+
-p, --pending-alerts import pending cert alerts to JSON file
22+
-r, --reports import reports to JSON file
23+
-s, --security-roles import security roles to JSON file
24+
-w, --workflow-definitions import workflow definitions to JSON file
25+
```
26+
27+
### SEE ALSO
28+
29+
* [kfutil](kfutil.md) - Keyfactor CLI utilities
30+

0 commit comments

Comments
 (0)