Closed bartwalczak1 closed 6 years ago
I was able to reproduce the problem and have had the time to dig into this issue a little deeper. The err-stackstorm plugin calls match
via StackStorm's API and reports the actionalias doesn't exist. The bug on the plugins side is, it should have reported duplicate matches found. It should be a minor change to fix it so it reports the correct error.
Here is the test environment configuration and execution output: https://gist.github.com/nzlosh/c6d357f7891ee4080977536071dda296. You can see in the end of the gist that even st2
CLI fails to match when 4 variables are supplied.
I used the actionalias code from StackStorm to make a test script which helps visualise the matching logic.
Action Alias Tester
-------------------
Format: 'test {{arg1}}'
Text: 'test hello'
Result: {'arg1': 'hello'}
Format: 'test {{key1}} {{value1}}'
Text: 'test hello world'
Result: {'key1': 'hello', 'value1': 'world'}
Format: 'test {{key1}} {{value1}}'
Text: 'test k1 v1 k2 v2'
Result: {'key1': 'k1', 'value1': 'v1 k2 v2'}
Format: 'test {{key1}} {{value1}} {{ key2 }} {{ value2 }}'
Text: 'test k1 v1 k2 v2'
Result: {'key2': 'k2', 'key1': 'k1', 'value2': 'v2', 'value1': 'v1'}
Format: 'test {{key1}} {{value1}} {{ key2 }} {{ value2 }}'
Text: 'test k1 v1 k2 v2 k3=v3'
Result: {'k3': 'v3', 'key2': 'k2', 'key1': 'k1', 'value2': 'v2', 'value1': 'v1'}
Do you think it's possible to use extra Key-Value Parameters as describe here and just have a single format? E.g.
format: get ip {{tag_key}} {{tag_value}}
User input: 'get ip ec2_tag_cluster qa-blue tag_key2=a tag_value2=b'
Another option would be to use a fixed keyword between the two tags:
Format: 'test {{key1}} {{value1}} and {{ key2 }} {{ value2 }}'
Text: 'test k1 v1 and k2 v2'
Result: {'key2': 'k2', 'key1': 'k1', 'value2': 'v2', 'value1': 'v1'}
After thinking on it a bit more the 2nd option will still generate two matches, so adding the and keyword isn't a solution. It looks like Key-Value Parameters is the reliable way to setup the action alias.
Closing this issue since action aliases are working as designed.
I am trying to put multiple formats in single alias
following this --> https://docs.stackstorm.com/chatops/aliases.html#multiple-formats-in-a-single-alias
here's alias I've put together
when I hit
!st2 get ip ec2_tag_cluster qa-blue
I am getting result, but when I hit!st2 get ip ec2_tag_cluster qa-blue a b
I am getting
st2 command 'get ip ec2_tag_cluster qa-blue a b' not found. Check help with !st2help
in st2help I can see two formats listed