]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
mgr/pybind/object_format: fix json-pretty being marked invalid 59458/head
authorAdam King <adking@redhat.com>
Wed, 17 Apr 2024 17:34:45 +0000 (13:34 -0400)
committerAdam King <adking@redhat.com>
Tue, 27 Aug 2024 14:10:17 +0000 (10:10 -0400)
commit742e542ef9e5f198adc2495c5225dc1ae096a6b2
tree6f29c6c20e344f90939978ee868e990b7b7c549f
parentfe43f1c9f9e2945dda7244d8acbd33fb921449af
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