redhat-cop / openshift-applier

Used to apply OpenShift objects to an OpenShift Cluster
Apache License 2.0
102 stars 61 forks source link

Action: Patch needs to support yaml containing string values. #111

Closed etsauer closed 5 years ago

etsauer commented 5 years ago

What does this PR do?

I ran into a scneario this week where our patch support fails to handle patch file that contain quotes strings, e.g.:

spec:
  tags:
    - name: "2.7"
      importPolicy:
        scheduled: true

This PR adds a test of this scenario, as well as a fix to the role to handle it better.

How should this be tested?

molecule test

Is there a relevant Issue open for this?

n/a

Who would you like to review this?

cc: @redhat-cop/openshift-applier

etsauer commented 5 years ago

@oybed I added a test showing that json still works as well. The only thing functionally that we are doing is a {yaml|json} to json conversion of the contents of the file, so that we don't have to deal with complex escaping of \n and \t characters in the string.

etsauer commented 5 years ago

I should also mention that the current implementation of patch ONLY works for YAML. if you run the tests I added aginst the role in master, you'll see that even the simple tests we had will fail if you use a json formatted patch file.