CF-CLI-Create-Service-Push-Plugin icon indicating copy to clipboard operation
CF-CLI-Create-Service-Push-Plugin copied to clipboard

Add possibility to substitute variables in a referenced json config

Open MeikelVielhauer opened this issue 1 year ago • 2 comments

When providing a config as a reference via the parameters attribute you are not able to substitute the configuration with variables (--var KEY=VALUE). It only works for directly maintained inline json objects like this:

create-services:
  - name: "name"
     parameters: "{\"param1\": ((KEY))}"

It would be great to have an opportunity to substitute values in a referenced configuration file.

MeikelVielhauer avatar Apr 14 '23 10:04 MeikelVielhauer

Do you mean you are trying to do this?

Have a create service manifest yml:

create-services:
  - name: "name"
     parameters: "((PARAM))"

and allow inputs like this on the commandline

cf cspush ....  --var PARAM="{\"param1\": abcd}"

dawu415 avatar Apr 14 '23 20:04 dawu415

Thanks for your fast response!

What I mean is when providing a whole configuration file via parameters e.g. this:

create-services:
  - name: "name"
    parameters: "./configuration.json"

Assume the configuration.json looks somewhat like this:

{
  "clientId": ((CLIENTID))
}

Currently, I have not seen that there is an opportunity to substitute variables inside a given configuration file because the file reference will get prompted into cf create-service -c ./configuration.json.

Maybe we could add a flag like subsituteVarsInFile and then you read the file -> substitute -> prompt the json as oneline object into the create-service command:

create-services:
  - name: "name"
    parameters: "./configuration.json"
    subsituteVarsInFile: true

Then you would now be able to call your plugin like this: cf cspush .... --var CLIENTID="abc"

the result will be then: cf create-service ..... -c "{\"clientId\": abc}"

This would make life easier when you are trying to work with configuration files and even wanna substitute some values.

MeikelVielhauer avatar Apr 17 '23 08:04 MeikelVielhauer