Skip to content

feat: Add config-manager pull iga-workflows command#102

Open
dallinjsevy wants to merge 1 commit into
mainfrom
feature/config-manager-pull-iga-workflows
Open

feat: Add config-manager pull iga-workflows command#102
dallinjsevy wants to merge 1 commit into
mainfrom
feature/config-manager-pull-iga-workflows

Conversation

@dallinjsevy

Copy link
Copy Markdown

No description provided.

Comment on lines +9 to +14
const { CLOUD_DEPLOYMENT_TYPE_KEY, FORGEOPS_DEPLOYMENT_TYPE_KEY } =
frodo.utils.constants;
const deploymentTypes = [
CLOUD_DEPLOYMENT_TYPE_KEY,
FORGEOPS_DEPLOYMENT_TYPE_KEY,
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgeops is not a supported deployment for IGA, only Cloud, so remove Forgeops from this.

Comment on lines +42 to +44
if (options.realm) {
realm = options.realm;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workflows are global configuration, not realm specific, so remove this

Comment on lines +45 to +53
if (await getTokens(false, true, deploymentTypes)) {
verboseMessage('Exporting config entity iga-workflows');
const outcome = await configManagerExportIgaWorkflows(
options.name,
options.includeImmutable
);
if (!outcome) process.exitCode = 1;
}
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this code to look something like this:

const getTokensIsSuccessful = await getTokens(
false,
true,
deploymentTypes
);
if (!getTokensIsSuccessful) process.exit(1);
verboseMessage('Importing email provider configuration.');
const outcome = await configManagerImportEmailProvider();
if (!outcome) process.exitCode = 1;

This is almost correct, although we need to make sure we are setting the exit code to 1 in the event that getTokens fails, which this example does.

realm = options.realm;
}
if (await getTokens(false, true, deploymentTypes)) {
verboseMessage('Exporting config entity iga-workflows');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would reword this message to be "Exporting IGA workflows...", since config entity is typically associated with IDM entities.

Comment on lines +21 to +30
let workflows = await readWorkflows();
if (name) {
workflows = workflows.filter((workflow) => workflow.name === name);
}
if (!includeImmutable) {
workflows = workflows.filter((workflow) => workflow.mutable);
}
workflows.forEach((workflow) => {
processIgaWorkflow(workflow, 'iga/workflows');
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify this to be:

(await readWorkflows())
.filter(w => (!name || w.name === name) && (includeImmutable || !w.mutable))
.forEach(processIgaWorkflow);

For processIgaWorkflow you will need to modify it to no longer receive the fileDir, which is fine since there's no reason to pass it in as a parameter since it's a constant.

try {
const workflowName = safeFileName(workflow.name);
const workflowPath = `${fileDir}/${workflowName}`;
if (Array.isArray(workflow.steps)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check isn't necessary (steps will always be an array, even if there are no steps in the workflow)

stepBody &&
typeof stepBody === 'object' &&
typeof stepBody.script === 'string' &&
stepBody.script.length > 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify stepBody.script.length > 0 to just stepBody.script, since strings are falsy if they are empty.

const CMD = 'frodo config-manager pull iga-workflows --help';
const { stdout } = await exec(CMD);

test("CLI help interface for 'config export' should be expected english", async () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'config export' should be config-manager pull iga-workflows

/*
FRODO_MOCK=record FRODO_NO_CACHE=1 FRODO_HOST=https://openam-trivir-fairfax.forgeblocks.com/am frodo config-manager pull iga-workflows -D igaTestDir01
FRODO_MOCK=record FRODO_NO_CACHE=1 FRODO_HOST=https://openam-trivir-fairfax.forgeblocks.com/am frodo config-manager pull iga-workflows -n test_workflow_4 -D igaTestDir02
FRODO_MOCK=record FRODO_NO_CACHE=1 FRODO_HOST=https://openam-trivir-fairfax.forgeblocks.com/am frodo config-manager pull iga-workflows -i -D igaTestDir03

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add another two tests

  1. With -i and -n together and try to export a non-mutable workflow (it should work)
  2. With only -n like in test 2 (you will need to use --name to differentiate from that test), and try to export a non-mutable workflow. It should fail indicating that the workflow was not found (fr-config-manager's wording is specifically Workflow BasicApplicationGrant not found). For this test, I would use the helper that I created like await testFail(CMD, env); to test that the command fails.

if (options.realm) {
realm = options.realm;
}
if (await getTokens(false, true, deploymentTypes)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before getTokens, I would add an if-statement checking if the tenant is an IGA tenant, and fail early if not, as I did for the Frodo workflow commands:

if (!state.getIsIGA()) {
printMessage(
'Command not supported for non-IGA cloud tenants',
'error'
);
process.exitCode = 1;
return;
}

return false;
}

async function processIgaWorkflow(workflow, fileDir) {

@phalestrivir phalestrivir Jul 13, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a function comment to this. I would also rename it to processIgaWorkflowForExport to help differentiate it since there is also a function for processing a workflow for import in your push PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants