rockcarver / frodo-cli

A CLI to manage ForgeRock platform deployments supporting Identity Cloud tenants, ForgeOps deployments, and classic deployments.
MIT License
19 stars 18 forks source link

Reading esv variables via cli is not machine processable #217

Closed ashleyfrieze closed 1 year ago

ashleyfrieze commented 1 year ago

Frodo CLI version

0.23.0

Describe the issue

We have a CI pipeline which deploys all our variables to FR Identity Cloud. We iterate over the variables and use frodo to set them. However, if nothing's actually changed, we could skip this entirely, or at least rely on Frodo to skip the apply command.

Therefore, we looked at the output of this command:

npx frodo esv variable describe --variable-id my-awsome-variable https://openam-foo-euw2-staging.id.forgerock.io/am

The output is in human, not machine-readable format:

image

As such we couldn't process the output as part of some conditional logic to determine whether to call the command to create the variable with a different value.

Let's say there was a command line switch --read-value to just output the value of the variable, or --json to ask for output rendered in json, rather than a human-readable table, this would be significantly more useful.

vscheuber commented 1 year ago

@ashleyfrieze , a --json option would be handy, I agree! describe was never intended to be machine processable but I like that you are trying to use it that way. I'll look into it asap!

Feel free to put up a PR if you like to write some code yourself? :)

jgdtech commented 1 year ago

I agree, I have used the output and generated my own json file with {"Name":"esv-...","Value":"value"} and then did a command in bash like: for file in $(ls -1 *.json); do echo $file name=$(cat $file|jq -r '.Name') value=$(cat $file|jq -r '.Value') frodo esv variable create -i $name --value "$value" substr done

ashleyfrieze commented 1 year ago

@jgdtech I don't know whether you're using ID Cloud or a self-installed AM. With ID cloud the consequence of deploying new variables is that there's some sort of restart required. This, in turn, makes the deployment take a long time.

If the variables haven't changed since the last time, then there's no reason to deploy. Similarly, iterating over the variables we wish to add doesn't allow unused variables to be removed.

So, I'm probably going to end up scripting the deployment against frodo lib... though the CLI should also be machine readable where possible.