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

[st2client/RFI] It's hard to set array of object in an action parameter. #3646

Closed
userlocalhost opened this issue Aug 4, 2017 · 3 comments
Closed

Comments

@userlocalhost
Copy link
Member

Background / Problem

We can easily set object type values in a action parameter by the past efforts of the Team, like this.

$ st2 run some_pack.action param_obj='foo=bar,hoge=fuga'

In the similar way, we can do it for array type values, as follows.

$ st2 run some_pack.action param_arr='foo,bar,baz'

But it's quite difficult to set 'array of object' value, like following.

$ st2 run some_pack.action param_arr_obj=['{"foo": "bar"}','{"hoge": "fuga"}']

(Even if only a white space after comma is not permitted)

Currently, I can seldom see the action that requiresarray of object type value in a parameter.
But I think this restriction prevents to make it.

Suggestion

One of an idea to improve it is permitting to specify values more than once only if the array type parameter, as follows.

$ st2 run some_pack.action \
    param_arr_obj='foo=bar'
    param_arr_obj='hoge=fuga'

Internally, the param_arr_obj transforms as follows.

[{'foo': 'bar'}, {'hoge': 'fuga'}]

In this solution, I think there are following advantages.

  • (User friendly) This easily makes array of object using past assets.
  • (Backward compatibility) This doesn't change current UI.

Could you please let me know what you think about it?

Thank you

@Mierdin
Copy link
Member

Mierdin commented Aug 5, 2017

I like the idea, though I would prefer to see different operators inside vs outside the dict definitions. I.e.:

$ st2 run some_pack.action \
    param_arr_obj='foo:bar'
    param_arr_obj='hoge:fuga'

I am imagining that in more complex scenarios, it would be difficult to keep track of the equal signs.

@userlocalhost
Copy link
Member Author

Thank you for your reply!
I should be able to make a PR for it based on your comment.

@LindsayHill
Copy link
Contributor

Addressed by #3670

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants