weixin_39603505 2020-11-21 19:39
浏览 0

Batched addition of arguments throughout.

Overview

Brief description of what this PR does, and why it is needed (use case)?

This PR... ~~- adds --output-directory to taskcat test run~~ - adds --profile as a root-level parameter. (Ex: taskcat --profile foo test run) - honors package_lambda: false - Adds decorators that allow us to further customize the argument behavior.

Law of Unintended Consequences

Adding --profile as a root-level argument means that it's passed to every subbcommand module. For now, simply adding *_args, **_kwargs to each module class settles it. However, this means that each subcommand may behave differently. We may want to centralize a bare-bones config object (OR - args) to pass-through so that when a new subcommand is added, it's not missed.

Would very much appreciate feedback on this caveat, as it directly impacts another PR that I have in the works.

Decorators

Two decorators are added - CliCore.dont_generate_parameter - CliCore.longform_param_required

These decorators allow us to turn on/off parameter generation, and enforce longform parameters.

On/off example is profile in taskcat._cli_modules.Test.run.

python
    .longform_param_required('custom_uid')
    .dont_generate_parameter('profile')
    def run(  # noqa: C901
        test_names: str = "ALL",
        regions: str = "ALL",
        input_file: str = "./.taskcat.yml",
        project_root: str = "./",
        no_delete: bool = False,
        lint_disable: bool = False,
        enable_sig_v2: bool = False,
        keep_failed: bool = False,
        output_directory: str = './taskcat_outputs',
        profile: str = "default"
    ):

It's passed from the global argparser instance, but generating another parameter conflicts because -p/--project-root conflicts with the default naming -p/--profile. Redefining this parameter isn't necessary, so we're passing it from the root-level parser, but not asking for it again.

The longform enforcer is, well, face-value. There are certain parameters that we may want to enforce the long-form of them.

  • Ex: taskcat test run --super-dangerous-action-yes-i-understand. In the current behavior, the arguments accepted would be -s/--super-dangerous-yes-i-understand.

Testing/Steps taken to ensure quality

How did you validate the changes in this PR? - Unit tests. - by hand.

How to test this PR Start after checking out this branch (bulleted) * Include test case, and expected output

该提问来源于开源项目:aws-quickstart/taskcat

  • 写回答

7条回答 默认 最新

  • weixin_39603505 2020-11-21 19:39
    关注

    /do-e2e-tests

    评论

报告相同问题?