Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

users are not able to choose workdir-root if they run tmt clean command #2807

Open
skycastlelily opened this issue Apr 2, 2024 · 5 comments
Labels
command | clean tmt clean command

Comments

@skycastlelily
Copy link
Collaborator

As def run doesn't accept a @workdir_root_options and workdir_root is hard coded to context.params['workdir_root'] = tmt.utils.WORKDIR_ROOT:https://github.com/teemtee/tmt/blob/main/tmt/cli.py#L1784, gonna to send a merge request to add the support

@happz
Copy link
Collaborator

happz commented Apr 2, 2024

Seems to be more complicated:

I'd propose to:

  • update effective_workdir_root to accept one optional parameter, the value of CLI option. The CLI option should not have a default set - it should deliver None when not set, and effective_workdir_root should deliver the default value unless overridden. Something like this:

    def effective_workdir_root(workdir_root_option: Optional[str] = None) -> Path:
        if workdir_root_option:
            return Path(workdir_root_option)
    
        if 'TMT_WORKDIR_ROOT' in os.environ:
            return Path(os.environ['TMT_WORKDIR_ROOT'])
    
        return WORKDIR_ROOT
  • then we can switch all users of tmt.utils.WORKDIR_ROOT, like that clean command, to use effective_workdir_root. Code with access to CLI options - clean, clean runs, etc. - would add in workdir_root value, the rest wouldn't, everyone's happy and using one way to infer a workdir root.

  • clean itself probably does not have to have its own --workdir-root option - context.params['workdir_root'] = tmt.utils.effective_workdir_root(workdir_root_option=context.params.get('workdir_root') ) should do the trick, use option passed to the subcommand from clean command code.

Edit: clean does deserve its own option, as it can be run on its own. Needs to go through effective_workdir_root anyway, cannot use workdir_root parameter directly.

@skycastlelily
Copy link
Collaborator Author

skycastlelily commented Apr 2, 2024 via email

@psss psss added the command | clean tmt clean command label Aug 9, 2024
@psss
Copy link
Collaborator

psss commented Aug 9, 2024

Seems the approach is outlined, @skycastlelily would you be willing to work on this for 1.36.

@skycastlelily
Copy link
Collaborator Author

skycastlelily commented Aug 9, 2024 via email

@skycastlelily
Copy link
Collaborator Author

Here is the mr for this issue: #2850 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command | clean tmt clean command
Projects
None yet
Development

No branches or pull requests

3 participants