Skip to content
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

Added new command to easily add json value into yaml file #93

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

lstocchi
Copy link
Contributor

@lstocchi lstocchi commented Sep 1, 2019

PLEASE DON'T MERGE
This is a possible workaround to add json string into yaml file in azure devops. In this way user can add their json without worrying about double quotes escaping.
Possible solution for #35

@lstocchi
Copy link
Contributor Author

lstocchi commented Sep 2, 2019

This new command allows the user to add a json string to the yaml file and pass it to the ToolRunner without any issue or caring about double quotes escaping.

An example can be found below:

-task: oc-cmd-json@2
  inputs:
    openshiftService: 'My Openshift'
    version: 'v3.11.0'
    cmd: 'oc patch dc testwildfly -p=-json1'
    json: '{"-json1":{"spec":{"template":{"spec":{"containers":[{"name":"testwildfly","imagePullPolicy":"IfNotPresent"}]}}}}}'

In this case the string -json1 is replaced by using the value in the json object.
Currently there is no limitation in naming json keys.
The json object could have multiple key-value pairs.
The cmd string could have same json key repeated multiple times.

The only drawback that this PR doesn't solve is that the user need to use a specific syntax to deal with oc command arguments and json. By using the classic format (found in most oc tutorial)

'oc patch dc testwildfly -p -json1'

it will results in the following error

Error from server (BadRequest): json: cannot unmarshal string into Go value of type map[string]interface {}

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.

1 participant