minder icon indicating copy to clipboard operation
minder copied to clipboard

minder CLI's -oyaml output prints JSON tags

Open jhrozek opened this issue 1 year ago • 2 comments

Describe the issue

Some attributes have a different JSON and YAML tags, such as display name which has display_name in YAML and displayName in JSON. However, our -oyaml output seems to use the JSON tags which means that if you save the YAML to a file, try to modify and reupload it won't work.

To Reproduce

minder profile get -i 1991faab-68d4-443f-9015-2f8fb398d28f -oyaml
profile:
    alert: "on"
    context:
        project: d643f41b-3397-472f-8c01-1ea45e598427
    displayName: Let's make sure dependabot is enabled for python
    id: 1991faab-68d4-443f-9015-2f8fb398d28f
    name: dependabot-enabled-profile
    remediate: "on"
    repository:
        - def:
            apply_if_file: requirements.txt
            package_ecosystem: pypi
            schedule_interval: weekly
          name: dependabot_configured
          type: dependabot_configured

the example above should use display_name but uses displayName

What version are you using?

No response

jhrozek avatar Apr 05 '24 10:04 jhrozek

This part seems wrong:

Some attributes have a different JSON and YAML tags

Since JSON is valid YAML in general...

evankanderson avatar Jul 30 '24 13:07 evankanderson

It's a limitation on the JSON/YAML unmarshal. buf sets up JSON tags but not YAML in the golang structures it generates. They do have a library that's meant for YAML handling though https://github.com/bufbuild/protoyaml-go so we might wanna switch to that.

JAORMX avatar Jul 31 '24 06:07 JAORMX

This was fixed for ruletypes and profiles via https://github.com/mindersec/minder/pull/4936 and https://github.com/mindersec/minder/pull/4960

eleftherias avatar Dec 03 '24 15:12 eleftherias