]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
mgr/pybind/object_format: fix json-pretty being marked invalid 57770/head
authorAdam King <adking@redhat.com>
Wed, 17 Apr 2024 17:34:45 +0000 (13:34 -0400)
committerAdam King <adking@redhat.com>
Wed, 29 May 2024 12:48:14 +0000 (08:48 -0400)
commita190be87541c58f10052eb4dfbc4001bb3d4d148
treeeeb97b68520f8020f9c1fee0521488be786c7dc6
parent49fa1622ee1c9d889b2e76c494999e49ddbf2255
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>
(cherry picked from commit cd988a01a0edf13882527f5526f1793d4dece437)
src/pybind/mgr/object_format.py