-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docs): Add verbose examples of
store-types create
Signed-off-by: spbsoluble <[email protected]>
- Loading branch information
1 parent
ca778b6
commit 103cbad
Showing
3 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# store-types examples | ||
|
||
This directory contains examples of how to use `kfutil` to manage Keyfactor Command store types. For exhaustive details | ||
on the `store-types` command, see the [cli docs](../../docs/kfutil_store-types.md). | ||
|
||
- [store-types examples](#store-types-examples) | ||
- [Examples](#examples) | ||
- [create](#create) | ||
- [User Interactive](#user-interactive) | ||
- [Non-Interactive](#non-interactive) | ||
- [From File](#from-file) | ||
- [Simple](#simple) | ||
- [Complex](#complex) | ||
- [Demo Scenarios](#demo-scenarios) | ||
- [Create Bosch Camera Store Type Offline](#create-bosch-camera-store-type-offline) | ||
- [Summary](#summary) | ||
|
||
## Examples | ||
|
||
### create | ||
|
||
#### User Interactive | ||
|
||
Below is an example of creating a store type using the user interactive mode using `kfutil store-types create` command. | ||
|
||
*NOTE*: The list of options is pulled from [this file](../../store_types.json). | ||
|
||
```text | ||
kfutil store-types create | ||
? Choose an option: [Use arrows to move, type to filter] | ||
> AKV | ||
AWS-ACM | ||
Akamai | ||
AppGwBin | ||
AzureApp | ||
AzureAppGw | ||
AzureSP | ||
Certificate store type AKV created with ID: 150 | ||
``` | ||
|
||
#### Non-Interactive | ||
|
||
Below is an example of creating a store type using the non-interactive mode using | ||
`kfutil store-types create $KF_ST_SHORTNAME` command. | ||
*NOTE*: This will pull the latest store type definition from the [kfutil store-types.json](../../store_types.json) file. | ||
```bash | ||
KF_ST_SHORTNAME=AKV | ||
kfutil store-types create $KF_ST_SHORTNAME | ||
``` | ||
|
||
##### From File | ||
Below is an example of creating a store type using the non-interactive mode using | ||
`kfutil store-types create --file $KF_ST_FILE` command. | ||
|
||
###### Simple | ||
|
||
```bash | ||
KF_ST_FILE=AKV.json | ||
kfutil store-types create --file $KF_ST_FILE | ||
``` | ||
|
||
###### Complex | ||
|
||
Below is a bit more complex example of creating a store type using the non-interactive mode using a downloaded Command | ||
store type definition JSON file. This file can either be sourced from GitHub using `kfutil store-types templates-fetch` | ||
or from a downloaded `intergration-manifest.json` from a (Keyfactor Universal Orchestrator extension) | ||
[https://github.com/search?q=topic%3Akeyfactor-universal-orchestrator+org%3AKeyfactor+fork%3Atrue&type=repositories]. | ||
|
||
```bash | ||
#!/usr/bin/env bash | ||
function create_store_type_from_template() { | ||
kfutil store-types templates-fetch | jq -r ."$1" > "$1".json | ||
kfutil store-types create --from-file "$1".json | ||
} | ||
|
||
function create_store_type_from_manifest() { | ||
local shortname=$1 | ||
local manifest_file=${2:-integration-manifest.json} | ||
|
||
jq --arg shortname "$shortname" '.about.orchestrator.store_types[] | select(.ShortName == $shortname)' "$manifest_file" > "$shortname".json | ||
|
||
kfutil store-types create --from-file "$shortname".json | ||
} | ||
|
||
# Examples | ||
echo "Uses store-types templates-fetch to get the AKV template from GitHub" | ||
create_store_type_from_template "AKV" | ||
|
||
echo "Assumes you have an integration-manifest.json file in the current directory" | ||
create_store_type_from_manifest "AKV" # "path/to/integration-manifest.json" # (Optional) will default to looking for integration-manifest.json in the current directory | ||
``` | ||
|
||
## Demo Scenarios | ||
|
||
### Create Bosch Camera Store Type Offline | ||
|
||
#### Summary | ||
|
||
This scenario demonstrates how to create a store type for a Bosch Camera offline using a downloaded Command store type | ||
definition JSON file. | ||
|
||
#### Steps | ||
1. From an online machine download the latest version of [kfutil](https://github.com/Keyfactor/kfutil/releases/latest) | ||
2. Download the `integration-manifest.json` from | ||
the [Keyfactor Universal Orchestrator extension](https://github.com/Keyfactor/bosch-ipcamera-orchestrator/blob/main/integration-manifest.json) | ||
, or use `store-types templates-fetch` to get the latest templates from GitHub. | ||
|
||
```bash | ||
kfutil store-types templates-fetch | jq -r ."BIPCamera" > "BIPCamera.json" | ||
``` | ||
|
||
3. Copy the `kfutil` and `integration-manifest.json`/`BIPCamera.json` files to an offline machine. | ||
4. If using Pull the store type definition from the `integration-manifest.json` file either manually or using | ||
|
||
```bash | ||
jq --arg shortname \ | ||
"BIPCamera" '.about.orchestrator.store_types[] | select(.ShortName == BIPCamera)' \ | ||
integration-manifest.json > "BIPCamera.json" | ||
``` | ||
|
||
5. Create the store type using the `kfutil store-types create --from-file BIPCamera.json` command. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env bash | ||
function create_store_type_from_template() { | ||
echo "Creating store type from template $1.json" | ||
kfutil store-types templates-fetch | jq -r ."$1" > "$1".json | ||
kfutil store-types create --from-file "$1".json | ||
} | ||
|
||
function download_store_type_template() { | ||
echo "Downloading store type template $1 to $1.json" | ||
kfutil store-types templates-fetch | jq -r ."$1" > "$1".json | ||
} | ||
|
||
function download_integration_manifest() { | ||
local repo_name=${1:-kfutil} | ||
local ref=${2:-main} | ||
local manifest_file=${3:-integration-manifest.json} | ||
echo "Downloading integration manifest from Keyfactor/$repo_name@$ref to $manifest_file" | ||
echo curl -o $manifest_file https://raw.githubusercontent.com/Keyfactor/${repo_name}/${ref}/integration-manifest.json | ||
curl -o $manifest_file https://raw.githubusercontent.com/Keyfactor/${repo_name}/${ref}/integration-manifest.json | ||
} | ||
|
||
function create_store_type_from_manifest() { | ||
local shortname=$1 | ||
local manifest_file=${2:-integration-manifest.json} | ||
|
||
# check if manifest file exists | ||
if [ ! -f "$manifest_file" ]; then | ||
echo "Manifest file '$manifest_file' does not exist" | ||
return 1 | ||
fi | ||
|
||
# check if $1 is empty | ||
if [ -z "$shortname" ]; then | ||
echo "StoreType 'shortname' is required" | ||
cat $manifest_file | jq '.about.orchestrator.store_types[] | .ShortName' | ||
return 1 | ||
fi | ||
|
||
echo "Creating store type from manifest $manifest_file for $shortname" | ||
jq --arg shortname "$shortname" '.about.orchestrator.store_types[] | select(.ShortName == $shortname)' "$manifest_file" > "$shortname".json | ||
|
||
kfutil store-types create --from-file "$shortname".json | ||
} | ||
|
||
# Examples | ||
#create_store_type_from_template "BIPCamera" # Use for online creation | ||
function offline_create_store_type_from_template() { | ||
# Use for offline creation | ||
local store_type_name=$1 | ||
local orchestrator_name=$2 | ||
local orchestrator_version=${3:-main} | ||
local manifest_file=${4:-test-manifest.json} | ||
echo "Downloading store type template $store_type_name" | ||
download_integration_manifest "${orchestrator_name}" "${orchestrator_version}" "${manifest_file}" | ||
|
||
# Use for offline creation | ||
echo "Download the latest kfutil binary from https://github.com/Keyfactor/kfutil/releases/latest" | ||
echo "Copy 'kfutil' and the '${manifest_file}' to offline machine and then run the following command" | ||
echo create_store_type_from_manifest "${store_type_name}" "${manifest_file}" | ||
#create_store_type_from_manifest "${store_type_name}" "${manifest_file}" # Uncomment to run directly | ||
} | ||
|
||
function offline_create_bipcamera_store_type() { | ||
offline_create_store_type_from_template "BIPCamera" "bosch-ipcamera-orchestrator" "main" "bipcamera-manifest.json" | ||
} | ||
|
||
offline_create_bipcamera_store_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
function create_store_type_from_template() { | ||
kfutil store-types templates-fetch | jq -r ."$1" > "$1".json | ||
kfutil store-types create --from-file "$1".json | ||
} | ||
|
||
function create_store_type_from_manifest() { | ||
local shortname=$1 | ||
local manifest_file=${2:-integration-manifest.json} | ||
|
||
jq --arg shortname "$shortname" '.about.orchestrator.store_types[] | select(.ShortName == $shortname)' "$manifest_file" > "$shortname".json | ||
|
||
kfutil store-types create --from-file "$shortname".json | ||
} | ||
|
||
# Examples | ||
create_store_type_from_template "AKV" | ||
create_store_type_from_manifest "K8SSecret" test-manifest.json |