forked from rockcarver/frodo-cli
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add config-manager push secrets #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dallinjsevy
wants to merge
10
commits into
main
Choose a base branch
from
feature-config-manager-push-secrets
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8f05a43
feat: Add config-manager push secrets command
hfranklin 124b1ef
Add test secrets
dallinjsevy 85f958e
Add resolve place holder and support .env files for secret imports
dallinjsevy f130e60
update tests
dallinjsevy be0129f
update import to use readToJson function. UPdate tests
dallinjsevy 6b1adb6
update FrConfigSecretOps to use loadEnvFile from frodo-lib
dallinjsevy 22bed9c
wip
dallinjsevy cfabcad
fixup! wip
dallinjsevy cfcc29f
fixup! resolve PR comments. update tests
dallinjsevy e54c82d
fixup! resolve PR comments. update tests
dallinjsevy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
src/cli/config-manager/config-manager-push/config-manager-push-secrets.ts
This file contains hidden or 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,61 @@ | ||
| import { frodo } from '@rockcarver/frodo-lib'; | ||
| import { Option } from 'commander'; | ||
|
|
||
| import { configManagerImportSecrets } from '../../../configManagerOps/FrConfigSecretOps'; | ||
| import { getTokens } from '../../../ops/AuthenticateOps'; | ||
| import { verboseMessage } from '../../../utils/Console'; | ||
| import { FrodoCommand } from '../../FrodoCommand'; | ||
|
|
||
| const { CLOUD_DEPLOYMENT_TYPE_KEY } = frodo.utils.constants; | ||
|
|
||
| const deploymentTypes = [CLOUD_DEPLOYMENT_TYPE_KEY]; | ||
|
|
||
| export default function setup() { | ||
| const program = new FrodoCommand( | ||
| 'frodo config-manager push secrets', | ||
| [], | ||
| deploymentTypes | ||
| ); | ||
|
|
||
| program | ||
| .description('Import secrets.') | ||
| .addOption( | ||
| new Option( | ||
| '-n, --name <name>', | ||
| 'Secret name; import only the specified secret' | ||
| ) | ||
| ) | ||
|
|
||
| .addOption( | ||
| new Option( | ||
| '-p, --prune', | ||
| 'Prunes old versions that are still enabled before importing the new version(s)' | ||
| ) | ||
| ) | ||
|
|
||
| .action(async (host, realm, user, password, options, command) => { | ||
| command.handleDefaultArgsAndOpts( | ||
| host, | ||
| realm, | ||
| user, | ||
| password, | ||
| options, | ||
| command | ||
| ); | ||
|
|
||
| const getTokensIsSuccessful = await getTokens( | ||
| false, | ||
| true, | ||
| deploymentTypes | ||
| ); | ||
| if (!getTokensIsSuccessful) process.exit(1); | ||
| verboseMessage('Importing secrets to cloud'); | ||
| const outcome = await configManagerImportSecrets( | ||
| options.name, | ||
| options.prune | ||
| ); | ||
| if (!outcome) process.exitCode = 1; | ||
| }); | ||
|
|
||
| return program; | ||
| } | ||
This file contains hidden or 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
This file contains hidden or 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
34 changes: 34 additions & 0 deletions
34
test/client_cli/en/__snapshots__/config-manager-push-secrets.test.js.snap
This file contains hidden or 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,34 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`CLI help interface for 'config-manager push secrets' should be expected english 1`] = ` | ||
| "Usage: frodo config-manager push secrets [options] [host] [realm] [username] [password] | ||
|
|
||
| [Experimental] Import secrets. | ||
|
|
||
| Arguments: | ||
| host AM base URL, e.g.: https://cdk.iam.example.com/am. To use a | ||
| connection profile, just specify a unique substring or | ||
| alias. | ||
| realm Realm. Specify realm as '/' for the root realm or 'realm' | ||
| or '/parent/child' otherwise. (default: "alpha" for | ||
| Identity Cloud tenants, "/" otherwise.) | ||
| username Username to login with. Must be an admin user with | ||
| appropriate rights to manage authentication journeys/trees. | ||
| If given without a password, and it matches the username | ||
| already stored in the connection profile for the target | ||
| host, frodo uses that profile's stored password instead of | ||
| requiring it on the command line. | ||
| password Password. | ||
|
|
||
| Deployment: Cloud-only | ||
|
|
||
| Options: | ||
| -n, --name <name> Secret name; import only the specified secret | ||
| -p, --prune Prunes old versions that are still enabled before importing | ||
| the new version(s) | ||
| -h, --help Help | ||
| -hh, --help-more Help with all options. | ||
| -hhh, --help-all Help with all options, environment variables, and usage | ||
| examples. | ||
| " | ||
| `; |
This file contains hidden or 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
This file contains hidden or 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,10 @@ | ||
| import cp from 'child_process'; | ||
| import { promisify } from 'util'; | ||
|
|
||
| const exec = promisify(cp.exec); | ||
| const CMD = 'frodo config-manager push secrets --help'; | ||
| const { stdout } = await exec(CMD); | ||
|
|
||
| test("CLI help interface for 'config-manager push secrets' should be expected english", async () => { | ||
| expect(stdout).toMatchSnapshot(); | ||
| }); |
50 changes: 50 additions & 0 deletions
50
test/e2e/__snapshots__/config-manager-push-secrets.e2e.test.js.snap
This file contains hidden or 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,50 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`frodo config-manager push secrets "frodo config-manager push secrets --env-file test/e2e/env/configManager1.env -D test/e2e/exports/fr-config-manager/cloud ": should import the secrets into cloud" 1`] = `""`; | ||
|
|
||
| exports[`frodo config-manager push secrets "frodo config-manager push secrets --env-file test/e2e/env/configManager1.env -D test/e2e/exports/fr-config-manager/cloud ": should import the secrets into cloud" 2`] = ` | ||
| "Experimental feature in use: 'frodo config-manager push secrets'. This feature may change without notice. | ||
| ✔ Successfully read 3 secrets. | ||
| Error importing secret from "esv-prune-secrets.json" | ||
| No value found for placeholder "ESV_PRUNE_SECRETS" | ||
| Secret esv-fr-test-secret created version 4 | ||
| Secret esv-test-secret created version 8 | ||
| • 2 secrets imported. | ||
| Changes made to secrets: 2 updated, 0 unchanged | ||
| " | ||
| `; | ||
|
|
||
| exports[`frodo config-manager push secrets "frodo config-manager push secrets -n esv-fr-test-secret -E ESV_FR_TEST_SECRET="new fr version" -n esv-test-secret -E ESV_TEST_SECRET="new test version" -D test/e2e/exports/fr-config-manager/cloud": should import multiple specified secrets into cloud 1`] = `""`; | ||
|
|
||
| exports[`frodo config-manager push secrets "frodo config-manager push secrets -n esv-fr-test-secret -E ESV_FR_TEST_SECRET="new fr version" -n esv-test-secret -E ESV_TEST_SECRET="new test version" -D test/e2e/exports/fr-config-manager/cloud": should import multiple specified secrets into cloud 2`] = ` | ||
| "Experimental feature in use: 'frodo config-manager push secrets'. This feature may change without notice. | ||
| ✔ Successfully read 1 secrets. | ||
| Error importing secret from "esv-test-secret.json" | ||
| No value found for placeholder "ESV_TEST_SECRET_1" | ||
| • 0 secrets imported. | ||
| No changes, (0 secrets(s) already up to date) | ||
| " | ||
| `; | ||
|
|
||
| exports[`frodo config-manager push secrets "frodo config-manager push secrets -n esv-fr-test-secret -E ESV_FR_TEST_SECRET="test1" test/e2e/exports/fr-config-manager/cloud": should import the specified secret into cloud 1`] = `""`; | ||
|
|
||
| exports[`frodo config-manager push secrets "frodo config-manager push secrets -n esv-fr-test-secret -E ESV_FR_TEST_SECRET="test1" test/e2e/exports/fr-config-manager/cloud": should import the specified secret into cloud 2`] = ` | ||
| "Experimental feature in use: 'frodo config-manager push secrets'. This feature may change without notice. | ||
| ✔ Successfully read 1 secrets. | ||
| Secret esv-fr-test-secret created version 3 | ||
| • 1 secrets imported. | ||
| Changes made to secrets: 1 updated, 0 unchanged | ||
| " | ||
| `; | ||
|
|
||
| exports[`frodo config-manager push secrets "frodo config-manager push secrets -p -n esv-prune-secrets -E ESV_PRUNE_SECRETS=test3 -D test/e2e/exports/fr-config-manager/cloud": should import multiple specified secrets into cloud 1`] = `""`; | ||
|
|
||
| exports[`frodo config-manager push secrets "frodo config-manager push secrets -p -n esv-prune-secrets -E ESV_PRUNE_SECRETS=test3 -D test/e2e/exports/fr-config-manager/cloud": should import multiple specified secrets into cloud 2`] = ` | ||
| "Experimental feature in use: 'frodo config-manager push secrets'. This feature may change without notice. | ||
| ✔ Successfully read 1 secrets. | ||
| • Pruned 3 versions from secret esv-prune-secrets. | ||
| Secret esv-prune-secrets unchanged version 4 | ||
| • 1 secrets imported. | ||
| No changes, (1 secrets(s) already up to date) | ||
| " | ||
| `; |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.