Skip to content

Drop plan environment from the default command environment#4613

Open
happz wants to merge 1 commit intomainfrom
prepare-command-environment-drop-plan-psoiler
Open

Drop plan environment from the default command environment#4613
happz wants to merge 1 commit intomainfrom
prepare-command-environment-drop-plan-psoiler

Conversation

@happz
Copy link
Contributor

@happz happz commented Feb 26, 2026

When guests execute commands, plan environment is passed to all commands. This spoils the order of precedence. Patch removes this environment source, which is only used when Guest.execute() did not provide any environment of its own.

Pull Request Checklist

  • implement the feature

When guests execute commands, plan environment is passed to all
commands. This spoils the order of precedence. Patch removes this
environment source, which is only used when `Guest.execute()` did not
provide any environment of its own.
@happz happz added this to planning Feb 26, 2026
@happz happz added area | environment Environment variables handling code | no functional change "No Functional Change" intended. Patch should not change tmt's behavior in any way. labels Feb 26, 2026
@github-project-automation github-project-automation bot moved this to backlog in planning Feb 26, 2026
@happz happz moved this from backlog to implement in planning Feb 26, 2026
@happz happz added the ci | full test Pull request is ready for the full test execution label Feb 26, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request updates the logic for preparing command environments to respect precedence. The review suggests simplifying environment creation in tmt/guest/__init__.py for better readability. Additionally, the GuestLocal.execute method in tmt/steps/provision/local.py still needs updating for consistency.

Comment on lines +2107 to +2112
environment = tmt.utils.Environment()

environment.update(
self.environment,
self.parent.plan.environment,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Simplify environment creation for better readability. The custom update() method accepting multiple arguments is less conventional than using copy() and a subsequent update().

Suggested change
environment = tmt.utils.Environment()
environment.update(
self.environment,
self.parent.plan.environment,
)
environment = self.environment.copy()
environment.update(self.parent.plan.environment)

Copy link
Contributor

@LecrisUT LecrisUT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not technically a "no functional change" since it changes how Guest.environment is injected (previously it was not?), but it should have been the case so 👍

Comment on lines +2098 to +2100
When the environment is unset, construct a basic environment
from the plan and run. Otherwise, the environment is left
unmodified.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you link this more directly to :param: environment? "When the environment is unset" is a bit too vague

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area | environment Environment variables handling ci | full test Pull request is ready for the full test execution code | no functional change "No Functional Change" intended. Patch should not change tmt's behavior in any way.

Projects

Status: implement

Development

Successfully merging this pull request may close these issues.

2 participants