]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
mgr/pybind/object_format: fix json-pretty being marked invalid 56963/head
authorAdam King <adking@redhat.com>
Wed, 17 Apr 2024 17:34:45 +0000 (13:34 -0400)
committerAdam King <adking@redhat.com>
Wed, 17 Apr 2024 17:34:45 +0000 (13:34 -0400)
commitcd988a01a0edf13882527f5526f1793d4dece437
tree1176a2df1e7fecdbe0594cd06c417cff16e37bb5
parentabadee66cdb5c4119a201a00d6b26b076f64e911
mgr/pybind/object_format: fix json-pretty being marked invalid

without this patch you'd get

```
[ceph: root@vm-00 /]# ceph nfs cluster info --format json-pretty

Error EINVAL: Unknown format name: json-pretty
```

this seems to be because valid formats are checked using
the class

```
class Format(str, enum.Enum):
    plain = "plain"
    json = "json"
    json_pretty = "json-pretty"
    yaml = "yaml"
    xml_pretty = "xml-pretty"
    xml = "xml"
```

and then

```
set(str(v) for v in Format.__members__)
```

but that resolves to

```
{'yaml', 'json_pretty', 'plain', 'xml', 'json', 'xml_pretty'}
```

and so json-pretty is marked as invalid. Note that it's also
impossible to pass json_pretty as the format as core ceph
blocks it with

invalid choice: 'json_pretty' (choose from 'json', 'json-pretty', 'xml', 'xml-pretty', 'plain', 'yaml')

Fixes: https://tracker.ceph.com/issues/65554
Signed-off-by: Adam King <adking@redhat.com>
src/pybind/mgr/object_format.py