summaryrefslogtreecommitdiff
path: root/oslo_policy/sphinxpolicygen.py
Commit message (Collapse)AuthorAgeFilesLines
* Only pass exclude-deprecated when True3.12.1whoami-rajat2022-04-281-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The '--exclude-deprecated' parameter should only be passed to oslo.config to parse when it is True. The final generated sphinx syntax is[1] where [--exclude-deprecated] doesn't require True/False value and only should be passed when True. The change introducing this[2] causes parsing issue in oslo.config[3] while checking <bool>.startswith (we pass True/False value) and even after that while calling argparse[4] with following error[5]. [1] usage: sphinx-build [-h] [--config-dir DIR] [--config-file PATH] [--exclude-deprecated] [--format FORMAT] [--namespace NAMESPACE] [--noexclude-deprecated] [--output-file OUTPUT_FILE] [2] https://review.opendev.org/c/openstack/oslo.policy/+/830514 [3] https://opendev.org/openstack/oslo.config/src/branch/master/oslo_config/cfg.py#L2937 [4] https://opendev.org/openstack/oslo.config/src/branch/master/oslo_config/cfg.py#L2960 [5] > /usr/lib/python3.8/argparse.py(1781)parse_args() -> if argv: (Pdb) > /usr/lib/python3.8/argparse.py(1782)parse_args() -> msg = _('unrecognized arguments: %s') (Pdb) > /usr/lib/python3.8/argparse.py(1783)parse_args() -> self.error(msg % ' '.join(argv)) (Pdb) TypeError: sequence item 0: expected str instance, bool found > /usr/lib/python3.8/argparse.py(1783)parse_args() -> self.error(msg % ' '.join(argv)) Handler <function generate_sample at 0x7fc0d6697d30> for event 'builder-inited' threw an exception (exception: sequence item 0: expected str instance, bool found) Closes-Bug: #1970725 Change-Id: I95745b8d1cbdb6a7cf442d431a998b7e3ff600e4
* make deprecated rule examples explicitJulia Kreger2022-02-221-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | Deprecated rules can be confusing and downright unfriendly when evaluating a generated sample output and seeing legacy rules being aliased to new rules. Technically this is also invalid and results in a broken sample file with overriding behavior. Under normal circumstances, this wouldn't be a big deal, but with the Secure RBAC effort, projects also performed some further delineation of RBAC policies instead of performing a 1:1 mapping. As a result of the policy enforcement model, a prior deprecated rule was required, which meant the prior deprecated rule would be reported multiple times in the output. Since we don't have an extra flag in the policy-in-code definitions of policies, all we can *really* do is both clarify the purpose and meaning of the entry, not enable the alias by default in sample output (as it is a sample! not an override of code!), and provide projects as well as operators with a knob to exclude deprecated policy inclusion into examples and sample output. Closes-Bug: #1945336 Change-Id: I6d02eb4d8f94323a806fab991ba2f1c3bbf71d04
* Mark sphinx extensions thread safeSean McGinnis2020-04-131-0/+4
| | | | | | | | | | This adds the return of some metadata to our sphinx extension setup to indicate they are thread safe. This is needed to allow consuming projects to do multithreaded docs builds. In some cases, this can save a noticeable amount of time in job execution. Change-Id: I104271bc706fc33247548a147db0af05aa88737d Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
* Don't parse cli args on the global object in sphinxpolicygen3.0.2Ben Nemec2020-03-201-1/+8
| | | | | | | | | | | | | | | | | | | sphinxpolicygen is calling the generate_sample cli entrypoint when we aren't actually the command being run. This can cause problems if the consuming project has cli args that get registered on import of their modules because we may have parsed args before those modules get imported. This results in an exception because oslo.config won't allow cli args to be registered after they've been parsed once. This change makes use of the existing parameter to generate_sample that allows us to pass in a local config object on which to register the cli args. This way we can parse them without affecting the global config object. This was the only place I could find that we were doing something like this so I believe it should eliminate the problem. Change-Id: I8e9f28b0a15d1ed092d72b983be74fe281708fbe
* Update sphinx extension loggingSean McGinnis2018-10-161-3/+7
| | | | | | | | | Sphinx 1.6 deprecated using the application object to perform logging and it will be removed in the upcoming 2.0 release. This updates our extensions to use the recommended sphinx.util.logging instead. Change-Id: Ia9edbfd551d260b798818940e4d156957f382324 Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
* make the sphinxpolicygen extension handle multiple input/output filesDoug Hellmann2018-04-301-3/+13
| | | | | | | | | | | Some projects have multiple policy files for different parts of their API. Make the sample generator extension support this by letting the policy_generator_config_file option be set to a list of tuples mapping the config file to the output file base name, as we do in the sample generator in oslo.config. Change-Id: I0c7fa409a1ed0f49d65c9b90b71317066f6d3505 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
* Add sphinx extension to build sample policyStephen Finucane2016-09-281-0/+73
Provide a way to include a sample policy file in a project's documentation. This harnesses the same generator utilities used in standard policy file generation. Change-Id: I4b04044c18ea9f2b1d55785686982af9032a8495