Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft support for parsing slot results and appending text #52187

Merged
merged 13 commits into from
Apr 9, 2019

Conversation

mchugh19
Copy link
Contributor

@mchugh19 mchugh19 commented Mar 14, 2019

What does this PR do?

Extends slot syntax to support parsing resulting dictionaries and appending text. Note: the appending process only functions on slot results which are strings.

Next steps:

  • Since python structures are now injected with raw unicode: {u'shell': u'/bin/bash'} we could also force to json output if desired.

What issues does this PR fix or reference?

#50462
#46771

Previous Behavior

Using __slots__ with modules which return dictionaries required custom modules to parse result
Also, unable to append text

New Behavior

Support dictionary results by appending the slot function with period delimited dictionary keys to traverse
__slot__:salt:user.info(root).shell returns /bin/bash

Support appending data by using a tilde delimiter followed by text
__slot__:salt:user.info(root).shell ~ /appended~ returns /bin/bash/appended~

Tests written?

Yes

Commits signed with GPG?

No

Copy link
Contributor

@dwoz dwoz left a comment

Choose a reason for hiding this comment

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

@mchugh19 Can you please add a test or two that cover this?

@mchugh19
Copy link
Contributor Author

mchugh19 commented Mar 17, 2019

Tests have been added for the traverse and append functions.

In thinking about this a little bit more, the parsing for the append function looks for a tilde character and appends everything afterwards. It is possible that the slot text itself could contain that character as you might have cmd.run('ls ~user') or something. Should this behavior be updated to a more complicated regex, or maybe rather than just the single tilde character, the syntax could be forced to ~ with spaces on either side of the tilde? What do you all think it best?

Copy link
Contributor Author

@mchugh19 mchugh19 left a comment

Choose a reason for hiding this comment

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

Tests added

@mchugh19
Copy link
Contributor Author

mchugh19 commented Apr 2, 2019

@DmitryKuzmenko you should take a look here as well

@thatch45 thatch45 merged commit 166a33a into saltstack:develop Apr 9, 2019
@mchugh19 mchugh19 deleted the slot-extend branch July 4, 2019 14:23
mchugh19 pushed a commit to mchugh19/salt that referenced this pull request Oct 13, 2019
draft support for parsing slot results and appending text
@waynew waynew added the has master-port port to master has been created label Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has master-port port to master has been created
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants