mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Better solution for fixing the opts munging in pillar.show_pillar runner
The pillarenv argument to the `Pillar` class is only used as an override of what is in the opts. Therefore, it should default to None unless passed in the kwargs. This also removes the need for a deepcopy of the opts, since we're no longer making changes to the opts before passing them to the `Pillar` constructor.
This commit is contained in:
parent
e2c4702e0c
commit
2a185855ea
1 changed files with 4 additions and 9 deletions
|
@ -3,7 +3,6 @@
|
|||
Functions to interact with the pillar compiler on the master
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
import copy
|
||||
|
||||
# Import salt libs
|
||||
import salt.pillar
|
||||
|
@ -83,27 +82,23 @@ def show_pillar(minion='*', **kwargs):
|
|||
pillar = runner.cmd('pillar.show_pillar', [])
|
||||
print(pillar)
|
||||
'''
|
||||
# Don't stomp on the master opts
|
||||
opts = copy.deepcopy(__opts__)
|
||||
|
||||
saltenv = 'base'
|
||||
pillarenv = opts['pillarenv'] if 'pillarenv' in opts else None
|
||||
id_, grains, _ = salt.utils.minions.get_minion_data(minion, opts)
|
||||
pillarenv = __opts__.get('pillarenv')
|
||||
id_, grains, _ = salt.utils.minions.get_minion_data(minion, __opts__)
|
||||
if grains is None:
|
||||
grains = {'fqdn': minion}
|
||||
|
||||
for key in kwargs:
|
||||
if key == 'pillarenv':
|
||||
opts['pillarenv'] = kwargs[key]
|
||||
if key == 'saltenv':
|
||||
saltenv = kwargs[key]
|
||||
elif key == 'pillarenv':
|
||||
# pillarenv overridden on CLI
|
||||
pillarenv = kwargs[key]
|
||||
else:
|
||||
grains[key] = kwargs[key]
|
||||
|
||||
pillar = salt.pillar.Pillar(
|
||||
opts,
|
||||
__opts__,
|
||||
grains,
|
||||
id_,
|
||||
saltenv,
|
||||
|
|
Loading…
Add table
Reference in a new issue