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:
Erik Johnson 2018-02-22 09:19:41 -06:00
parent e2c4702e0c
commit 2a185855ea
No known key found for this signature in database
GPG key ID: 5E5583C437808F3F

View file

@ -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,