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

Breaking from 2 to 3 (array and comments) #364

Closed
mfouilleul opened this issue Feb 20, 2020 · 5 comments
Closed

Breaking from 2 to 3 (array and comments) #364

mfouilleul opened this issue Feb 20, 2020 · 5 comments
Labels

Comments

@mfouilleul
Copy link

mfouilleul commented Feb 20, 2020

I have a breaking change in the version 3 with array and comment, can you help debug this, maybe there is a flag which can help me.

The file 1.txt

# any class that implements the SeedProvider interface and has a
# constructor that takes a Map<String, String> of parameters will do.
seed_provider:
    # Addresses of hosts that are deemed contact points.
    # Cassandra nodes use this list of hosts to find each other and learn
    # the topology of the ring.  You must change this if you are running
    # multiple nodes!
    - class_name: org.apache.cassandra.locator.SimpleSeedProvider
      parameters:
          # seeds is actually a comma-delimited list of addresses.
          # Ex: "<ip1>,<ip2>,<ip3>"
          - seeds: "127.0.0.1"

The file 2.txt

authenticator: PasswordAuthenticator
authorizer: org.apache.cassandra.auth.CassandraAuthorizer

I want to merge the both,

With the version 2, the result is:

docker run --rm -it  mikefarah/yq:2 sh
/workdir # yq m 1.txt 2.txt
authenticator: PasswordAuthenticator
authorizer: org.apache.cassandra.auth.CassandraAuthorizer
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
  parameters:
  - seeds: 127.0.0.1

With the version 3, the result is:

# yq m 1.txt 2.txt
# any class that implements the SeedProvider interface and has a
# constructor that takes a Map<String, String> of parameters will do.
seed_provider:
- # Addresses of hosts that are deemed contact points.
  # Cassandra nodes use this list of hosts to find each other and learn
  # the topology of the ring.  You must change this if you are running
  # multiple nodes!
  class_name: org.apache.cassandra.locator.SimpleSeedProvider
  parameters:
  - # seeds is actually a comma-delimited list of addresses.
    # Ex: "<ip1>,<ip2>,<ip3>"
    seeds: "127.0.0.1"

My issue is the integration of the comment inside the array:

- # seeds is actually a comma-delimited list of addresses.
    # Ex: "<ip1>,<ip2>,<ip3>"
    seeds: "127.0.0.1"

The format - seeds: is necessary in the official cassandra's docker-entrypoint.

Thanks!

@mfouilleul
Copy link
Author

Btw, I agree that the generated YAML is valid.

@mikefarah
Copy link
Owner

I see - this is how the underlying yaml parser library encodes the yaml (https://godoc.org/gopkg.in/yaml.v3). It's annoying it doesn't keep the comments in the right place. I'd raise an issue and link it here (there may already be one?)

Like you say, the yaml is valid (and should be equivalant) - but I'm guessing cassandra doesn't like it?

Failing a yaml.v3 fix - the only thing I can think of is adding a strip comments flag that will remove all the comments...

@mikefarah
Copy link
Owner

Yep found an existing issue here:

go-yaml/yaml#459

@mikefarah
Copy link
Owner

There is now a strip comments feature in yq to circumvent this issue:

https://mikefarah.gitbook.io/yq/usage/output-format#strip-comments

@mikefarah
Copy link
Owner

This has been fixed in 3.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants