uber / prototool

Your Swiss Army Knife for Protocol Buffers
MIT License
5.05k stars 345 forks source link

`--config-data` is partial to accepting JSON config data only, and not YAML #575

Open sakshamsaxena opened 3 years ago

sakshamsaxena commented 3 years ago

I have a YAML like this:

protoc:
  version: 3.8.0
lint:
  group: uber2
generate:
  go_options:
    import_path: my-app/src/api/grpc
  plugins:
    - name: gogofaster
      type: gogo
      flags: plugins=grpc
      output: generated_model

This is quite biased as the import path is fixed here. Usually I have to generate it for the server app and client app which are different (and currently non-standardised). So I keep another copy of this with a different import_path.

I wanted to use prototool generate to generate for both the configs that are in YAML. However, when I run

prototool generate service_definition.proto --config-data "$(cat prototool-custom-1.yaml)"

i get the following error

prototool generate service_definition.proto --config-data "protoc:   version: 3.8.0 lint:   group: uber2 generate:   go_options:     import_path: my-app/src/api/grpc   plugins:     - name: gogofaster       type: gogo       flags: plugins=grpc       output: generated_model"
invalid character 'p' looking for beginning of value

This suggests that it is unable to parse YAML.

I checked #224 and noticed that the test cases also have JSON config as test data, so I'm guessing there's a gap here in what the expectations are and what the outcome is. I could not understand the code much, and am on a time crunch, so any insights on a workaround, or an acknowledgment that this is a bug, would be appreciated.

Thanks!