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

Fix yaml <-> json roundtrip #1482

Merged
merged 3 commits into from
Mar 9, 2021
Merged

Fix yaml <-> json roundtrip #1482

merged 3 commits into from
Mar 9, 2021

Conversation

carolynvs
Copy link
Member

@carolynvs carolynvs commented Mar 4, 2021

What does this change

I had a bug report for problems parsing a --yes flag as a bool instead of a string, causing the flag to be passed as --true.

install:
- exec:
    description: "use a yes flag"
    command: az
    arguments:
    - something
    flags:
      yes: ""

This is fixed in v3 of the yaml package, becauase it uses a newer version of yaml that doesn't interpret yes/no as boolean keys.

This version bump does change the indentation strategy of serializing to yaml but other than impacting our test strings, it's still valid yaml, just uses more spaces.

What issue does it fix

Fixes #1483 where null wasn't being handled properly and other reports of roundtrip problem between yaml to json.

Notes for the reviewer

I'm not sure if using v3 gives us any other capabilities. We were actually using it already in one of our packages because of it's node manipulation. This just has us use the same version everywhere.

Checklist

  • Unit Tests
  • Documentation
  • Schema (porter.yaml)

I had a bug report for problems parsing a --yes flag as a bool instead
of a string, causing the flag to be passed as --true.

install:
- exec:
    description: "use a yes flag"
    command: az
    arguments:
    - something
    flags:
      yes: ""

This is fixed in v3 of the yaml package, becauase it uses a newer
version of yaml that doesn't interpret yes/no as boolean keys.

This version bump does change the indentation strategy of serializing to
yaml but other than impacting our test strings, it's still valid yaml,
just uses more spaces.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
@carolynvs carolynvs added this to In Progress in Porter and Mixins via automation Mar 4, 2021
* null keys should marhsal as "null"
* null values should marshal as nil/null

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
@carolynvs carolynvs changed the title Upgrade to gopkg.in/yaml.v3 Fix yaml <-> json roundtrip Mar 4, 2021
@carolynvs carolynvs marked this pull request as ready for review March 4, 2021 16:25
@@ -6,8 +6,10 @@ import (
"io/ioutil"

"get.porter.sh/porter/pkg/context"
//"get.porter.sh/porter/pkg/yaml"
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this line can be removed?

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
@carolynvs carolynvs merged commit 1df624a into getporter:main Mar 9, 2021
Porter and Mixins automation moved this from In Progress to Done Mar 9, 2021
@carolynvs carolynvs deleted the bool-flags branch March 9, 2021 21:06
joshuabezaleel pushed a commit to joshuabezaleel/porter that referenced this pull request Mar 14, 2021
* Upgrade to gopkg.in/yaml.v3

I had a bug report for problems parsing a --yes flag as a bool instead
of a string, causing the flag to be passed as --true.

install:
- exec:
    description: "use a yes flag"
    command: az
    arguments:
    - something
    flags:
      yes: ""

This is fixed in v3 of the yaml package, becauase it uses a newer
version of yaml that doesn't interpret yes/no as boolean keys.

This version bump does change the indentation strategy of serializing to
yaml but other than impacting our test strings, it's still valid yaml,
just uses more spaces.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>

* Fix yaml <-> json roundtrip for null

* null keys should marhsal as "null"
* null values should marshal as nil/null

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>

* Remove unused import

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

null values in custom definitions become the string "<nil>" once published
2 participants