Skip to content

Allow cp functions to derive saltenv from config#61564

Merged
garethgreenaway merged 1 commit into
saltstack:masterfrom
nicholasmhughes:add-cp-function-get-saltenv
Feb 8, 2022
Merged

Allow cp functions to derive saltenv from config#61564
garethgreenaway merged 1 commit into
saltstack:masterfrom
nicholasmhughes:add-cp-function-get-saltenv

Conversation

@nicholasmhughes
Copy link
Copy Markdown
Contributor

What does this PR do?

This PR allows the cp module functions to derive saltenv from config if not explicitly set as a keyword argument to the function. See issue for details.

What issues does this PR fix or reference?

Fixes: #61562

Previous Behavior

On minions with a saltenv set:

# /etc/salt/minion.d/saltenv.conf

saltenv: dev

The cp functions would not detect that saltenv and default to "base":

# returns files from the base env (if configured on the master)

salt-call cp.list_master

This often leads to user confusion or surprise because they expect the minion to be "in" a given environment.

New Behavior

The cp functions will now detect the saltenv from the configuration files and use that unless explicitly set:

# returns files from the dev env (if configured as previously shown)

salt-call cp.list_master

# the saltenv can still be overridden

salt-call cp.list_master saltenv=prod

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

@nicholasmhughes nicholasmhughes requested a review from a team as a code owner February 1, 2022 14:37
@nicholasmhughes nicholasmhughes requested review from MKLeb and garethgreenaway and removed request for a team and garethgreenaway February 1, 2022 14:37
@nicholasmhughes
Copy link
Copy Markdown
Contributor Author

re-run pr-centos-8-x86_64-py3-pytest

@nicholasmhughes nicholasmhughes force-pushed the add-cp-function-get-saltenv branch from 1352476 to a94f360 Compare February 3, 2022 18:09
@nicholasmhughes
Copy link
Copy Markdown
Contributor Author

@MKLeb can you take a look and see if this is a reasonable approach? Thanks!

@garethgreenaway garethgreenaway merged commit 2bd6323 into saltstack:master Feb 8, 2022
@nicholasmhughes nicholasmhughes deleted the add-cp-function-get-saltenv branch February 8, 2022 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] cp module doesn't use configured saltenv

3 participants