-
Notifications
You must be signed in to change notification settings - Fork 2
Promotion tool2 #23
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
Promotion tool2 #23
Changes from all commits
357197a
30f94f7
4ced311
ebd24cf
67b3e0f
25bccc3
fdc8d8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IDM delete command is not necessary for the promotion, this should be in a separate PR |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { Option } from 'commander'; | ||
|
|
||
| import { getTokens } from '../../ops/AuthenticateOps'; | ||
| import { deleteConfigEntityById } from '../../ops/IdmOps'; | ||
| import { FrodoCommand } from '../FrodoCommand'; | ||
|
|
||
| export default function setup() { | ||
| const program = new FrodoCommand('frodo idm delete'); | ||
|
|
||
| interface ServiceDeleteOptions { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Left over dead code from copying the service command. |
||
| id?: string; | ||
| type?: string; | ||
| insecure?: boolean; | ||
| verbose?: boolean; | ||
| debug?: boolean; | ||
| curlirize?: boolean; | ||
| all?: boolean; | ||
| global?: boolean; | ||
| } | ||
|
|
||
| program | ||
| .description('Delete AM services.') | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update descriptions to be descriptive of idm and not services |
||
| .addOption(new Option('-i, --id <id>', 'Id of Service to be deleted.')) | ||
| .action( | ||
| async ( | ||
| host: string, | ||
| realm: string, | ||
| user: string, | ||
| password: string, | ||
| options: ServiceDeleteOptions, | ||
| command | ||
| ) => { | ||
| command.handleDefaultArgsAndOpts( | ||
| host, | ||
| realm, | ||
| user, | ||
| password, | ||
| options, | ||
| command | ||
| ); | ||
|
|
||
| // const globalConfig = options.global ?? false; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dead code |
||
|
|
||
| if (options.id && (await getTokens())) { | ||
| const outcome = await deleteConfigEntityById(options.id); | ||
| if (!outcome) process.exitCode = 1; | ||
| } else { | ||
| program.help(); | ||
| process.exitCode = 1; | ||
| } | ||
| } | ||
| ); | ||
|
|
||
| return program; | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IDM delete command is not necessary for the promotion, this should be in a separate PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The full delete is not necessary but I did have to pull inn the command from the library |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IdP delete command is not necessary for the promotion, this should be in a separate PR |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { state } from '@rockcarver/frodo-lib'; | ||
| import { Option } from 'commander'; | ||
|
|
||
| import { getTokens } from '../../ops/AuthenticateOps'; | ||
| import { deleteSocialIdentityProviderById } from '../../ops/IdpOps'; | ||
| import { printMessage, verboseMessage } from '../../utils/Console'; | ||
| import { FrodoCommand } from '../FrodoCommand'; | ||
|
|
||
| export default function setup() { | ||
| const program = new FrodoCommand('frodo idp delete'); | ||
|
|
||
| program | ||
| .description('Delete (social) identity providers.') | ||
| .addOption(new Option('-i, --idp-id <idp-id>', 'Id/name of a provider.')) | ||
| .action( | ||
| // implement command logic inside action handler | ||
| async (host, realm, user, password, options, command) => { | ||
| command.handleDefaultArgsAndOpts( | ||
| host, | ||
| realm, | ||
| user, | ||
| password, | ||
| options, | ||
| command | ||
| ); | ||
| if ((await getTokens()) && options.idpId) { | ||
| verboseMessage( | ||
| `Deleting idp ${options.idpId} in realm "${state.getRealm()}"...` | ||
| ); | ||
| const outcome = await deleteSocialIdentityProviderById(options.idpId); | ||
| if (!outcome) process.exitCode = 1; | ||
| } else { | ||
| printMessage( | ||
| 'Unrecognized combination of options or no options...', | ||
| 'error' | ||
| ); | ||
| program.help(); | ||
| process.exitCode = 1; | ||
| } | ||
| } | ||
| // end command logic inside action handler | ||
| ); | ||
|
|
||
| return program; | ||
| } |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IdP delete command is not necessary for the promotion, this should be in a separate PR |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OAuth client delete command is not necessary for the promotion, this should be in a separate PR. Additionally, might as well implement the -a flag too, and --no-deep if applicable. |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OAuth client delete command is not necessary for the promotion, this should be in a separate PR |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| import { FrodoError } from '@rockcarver/frodo-lib'; | ||
| import { Option } from 'commander'; | ||
|
|
||
| import { getTokens } from '../../ops/AuthenticateOps'; | ||
| import { compareExportToDirectory } from '../../ops/PromoteOps'; | ||
| import { verboseMessage } from '../../utils/Console.js'; | ||
| import { FrodoCommand } from '../FrodoCommand'; | ||
|
|
||
| const deploymentTypes = ['cloud', 'forgeops']; | ||
|
|
||
| export default function setup() { | ||
| const program = new FrodoCommand('promote'); | ||
|
|
||
| program | ||
| .description('Prepares a tenant to be promoted') | ||
| .addHelpText( | ||
| 'after', | ||
| 'This is used to compare two directories and automatically import and delete' + | ||
| 'configurations so the tenant can be promoted. It will compare a master export to a current export' + | ||
| 'and make the changes based off that diff. A file will be generated to show what has changed. \n' + | ||
| `Usage Examples:\n` + | ||
| '\n' + | ||
| 'frodo promote -M ./master -E ./export [testTenant]\n' + | ||
| '\n' + | ||
| 'This will run the promote command making the changes from master to the export, with the master being the one we are going to.' + | ||
| '\n' + | ||
| '\n' + | ||
| 'frodo promote --what-if -M ./master -E ./export [testTenant]\n' + | ||
| '\n' + | ||
| 'This will output the changes that would be made if the promote was run but will not do those changes' | ||
| ) | ||
| .addOption( | ||
| new Option( | ||
| '-E, --frodo-export-dir <directory>', | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd lean towards lowercase flags when possible. |
||
| 'The directory where the frodo export is located.' | ||
| ) | ||
| ) | ||
| .addOption( | ||
| new Option( | ||
| '--what-if', | ||
| 'Runs a what if of the comparison, so it wont do any changes' | ||
| ).default(false, 'false') | ||
| ) | ||
| .addOption( | ||
| new Option( | ||
| '-M, --master-dir <directory>', | ||
| 'The directory where the master configurations is located.' | ||
| ) | ||
| ) | ||
| .addOption( | ||
| new Option( | ||
| '--propmt-prune', | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spelling |
||
| 'Will prompt for Frodo Journey Prune on all realms' | ||
| ).default(false, 'false') | ||
| ) | ||
| .addOption( | ||
| new Option('--no-prune', 'Will stop prune from running').default( | ||
| false, | ||
| 'false' | ||
| ) | ||
| ) | ||
| .addOption( | ||
| new Option( | ||
| '-S --effect-secrets', | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spelling |
||
| 'Will effect the secrets, otherwise we will not change the secrets but will compare them' | ||
| ).default(false, 'false') | ||
| ) | ||
| .addOption( | ||
| new Option( | ||
| '-W --wait-secrets', | ||
| 'When secrets are effected we need to run a refresh on the enviornment. This will cause the command to wait until the refresh is finished.' | ||
| ).default(false, 'false') | ||
| ) | ||
| .addOption( | ||
| new Option( | ||
| '-P --print-diff', | ||
| 'Outputs the diff to a file in the directory where the command was run.' | ||
| ).default(false, 'false') | ||
| ) | ||
| .addOption( | ||
| new Option( | ||
| '--target <host url>', | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this necessary? The promotion staging should all be for the single environment for now. |
||
| 'Host URL of the environment to perform secret value encryption. The URL must resolve to an existing connection profile. Use this option to generate an export that can be imported into the target environment without requiring admin access to the source environment.' | ||
| ) | ||
| ) | ||
| .action( | ||
| async (host, realm, user, password, options, command) => { | ||
| command.handleDefaultArgsAndOpts( | ||
| host, | ||
| realm, | ||
| user, | ||
| password, | ||
| options, | ||
| command | ||
| ); | ||
| if ( | ||
| (await getTokens(false, true, deploymentTypes)) && | ||
| options.masterDir && | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reorder to validate option prior to making the request for tokens |
||
| options.frodoExportDir | ||
| ) { | ||
| verboseMessage('Comparing export...'); | ||
| verboseMessage('comparing'); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This second verbose message is not needed, first one should suffice |
||
| const outcome = await compareExportToDirectory( | ||
| options.masterDir, | ||
| options.frodoExportDir, | ||
| options.whatIf, | ||
| options.effectSecrets, | ||
| options.waitSecrets, | ||
| options.promptPrune, | ||
| options.noPrune, | ||
| options.printDiff | ||
| ); | ||
| verboseMessage('done'); | ||
| if (!outcome) process.exitCode = 1; | ||
| } else { | ||
| new FrodoError('need to designate a master dir and export directory'); | ||
| } | ||
| } | ||
| //end command logic inside action handler | ||
| //"/home/trivir/Frodo/golden1-git/identity-cloud-config" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete this comment with the file path |
||
| ); | ||
|
|
||
| return program; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be devDependencies?