Skip to content

Conversation

@skootrivir
Copy link

frodo config import ... --compare-and-delete command:

  1. exports config data from cloud as an object
  2. compares that object with master file/directory and saves comparing results in .txt file (log from export command blocks the result to be shown on terminal, so the result should be saved in local directory.
  3. deletes whatever added to the cloud compare to master file/directory
  4. import master file/directory back to cloud

frodo config import ... --compare-and-delete --dry-run command:

1.Exports config data from cloud as an object
2. compares that object with master file/directory and saves comparing results in .txt file (log from export command blocks the result to be shown on terminal, so the result should be saved in local directory.

--dry-run can only be used with --compare-and-delete flag.
--dry-run let --compare-and-delete flag to only export the cloud and compare it with the master.
--dry-run will prevent --compare-and-delete flag to delete and import

@phalestrivir phalestrivir self-requested a review April 30, 2025 23:13
…fig data from cloud into memory as an object and compares that with master file/directory, and deletes the differences, and imports master file/directory back to cloud.
@skootrivir skootrivir force-pushed the config-import-compareAndDelete branch from a670836 to 264a01d Compare May 12, 2025 19:49
Copy link
Collaborator

@phalestrivir phalestrivir left a comment

Choose a reason for hiding this comment

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

Make sure you rename everything to not use ‘cloud’, since in the future we may want to do this same functionality for other deployments like on-prem. We should probably discuss with @hfranklin if this is something we want to do now or save for later. If we save it for later, we should probably update the getTokens method in [config-import.ts](http://config-import.ts/) to only allow cloud deployments when doing --compare.

I'm also wondering if, since we are doing similar deleting and importing as what we are doing for PromoteOps, I think we should use the same function for deleting and importing in both places to reduce code redundancy and ensure that both PromoteOps and the compare delete for ConfigOps work the same way.

'Import all scripts including the default scripts.'
)
)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this extra new line since it wasn't there before

)
.addOption(
new Option(
'--delete-and-import',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was wondering if we should rename this command to something more concise, just as --sync or --reconcile, or maybe --sync-compare or --reconcile-compare so it's obvious that the flag is related to the --compare flag. It's probably fine to keep it as --delete-and-import for now though, but we may want to ask @hfranklin what he thinks makes the most sense here.

.addOption(
new Option(
'--delete-and-import',
'Deletes whatever added to the current cloud after comparison from --compare flag. Then it imports master config file/directory back to cloud. Only run when --compare flag is on.'
Copy link
Collaborator

Choose a reason for hiding this comment

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

This description is a little confusing to me. I think this might be a better description:

'Syncs changes found by using --compare from the master config file/directory to the current deployment. This includes importing any new/updated configuration, and deleting any configuration that is not in the master config.'

.addOption(
new Option(
'--compare',
'This export config data from the current tenant as an object, and it compares whatever changes between this object and the config data from the master file/directory.'
Copy link
Collaborator

Choose a reason for hiding this comment

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

This description can be more concise. How about this:

'Compares changes between config in the master file or directory (specified with -f or -D flags respectively) with config exported from the current deployment.'

We will also want to also update the descriptions for -f and -D to mention that they are also used to specify the location for the master config for the --compare flag.

/**
* Export from current tenant, compare with master directory, delete the differences and import master back
*/
export async function compareWithMasterDirectoryAndDeleteFromCloud(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function is very similar to compareWithMasterFileAndDeleteFromCloud. I would put all the same code from both into a helper function to reduce code redundancy.

await deleteServiceNextDescendentOnly(serviceId, globalConfig);
return true;
} catch (error) {
printError(error);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should return false in the event of an error

-D. Ignored with -i or -a.
-C, --clean Remove existing service(s) before
importing.
--compare-and-delete Export current cloud config data into
Copy link
Collaborator

Choose a reason for hiding this comment

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

Snapshots need to be updated with new flags.

"
`;

exports[`frodo config import "frodo config import -AD test/e2e/exports/all-separate/cloud --compare-and-delete --include-active-values" Import everything with secret values from directory "test/e2e/exports/all-separate/cloud" 1`] = `
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test failed, as it printed out the help menu. You'll want to debug and fix this. Same for anywhere else this happens

await exec(CMD, env);
fail("Command should've failed")
await exec(CMD, env);
fail("Command should've failed")
Copy link
Collaborator

@phalestrivir phalestrivir May 12, 2025

Choose a reason for hiding this comment

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

Revert these spacing changes, including all those in the rest of the file

@phalestrivir phalestrivir changed the base branch from trivir to main June 5, 2025 19:36
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