saltstack-formulas / libvirt-formula

http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
19 stars 43 forks source link

refactor(libsaltcli): use `ssh` matching improvement (`__master_opts__`) #72

Closed myii closed 4 years ago

myii commented 4 years ago

PR progress checklist (to be filled in by reviewers)


What type of PR is this?

Primary type

Secondary type

Does this PR introduce a BREAKING CHANGE?

No.

Related issues and/or pull requests

Describe the changes you're proposing

@baby-gnu As discussed in the comment linked above. I've gone for the very simplest option so far, which we can discuss further if necessary.

Pillar / config required to test the proposed changes

Debug log showing how the proposed changes work

Documentation checklist

Testing checklist

Additional context

myii commented 4 years ago

I've kept it inside the {%- elif salt['config.get']('__cli') == 'salt-call' %} block, since that still evaluates as True for both ssh and local. What I'm protecting against is a future edit, where someone mistakenly believes they can reorder the block and introduce a regression, i.e.:

{%- if salt['config.get']('__cli') == 'salt-minion' %}
{%-   set cli = 'minion' %}
{%- elif salt['config.get']('__cli') == 'salt-call' %}
{%-    set cli = 'local' %}
{%- elif salt['config.get']('__master_opts__', {}).get('__cli') == 'salt-ssh' %}
{%-     set cli = 'ssh' %}
{%- else %}
{%-   set cli = 'unknown' %}
{%- endif %}
myii commented 4 years ago

Thanks, @baby-gnu.

saltstack-formulas-travis commented 4 years ago

:tada: This PR is included in version 3.7.2 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: