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

Add header options for starting workflow via CLI (#2862) #3341

Merged
merged 4 commits into from
Jun 17, 2020

Conversation

vytautas-karpavicius
Copy link
Contributor

What changed?
This change exposes three new optional parameters for starting a workflow:

  • header_key
  • header_value
  • header_file

They allow setting header values in JSON format which are propogated
via workflow context. Values can be provides either directly or with a
file. If multiple keys and values are used, they separated by a space.
Count of keys and values must be equal, otherwise error is returned.

Why?
It was not possible to set header values via CLI when starting a workflow.

How did you test it?
Tested locally with:

./cadence --domain mickey workflow start --tasklist mini --workflow_type pluto --execution_timeout 1 --header_key='aaa bbb ccc ddd eee fff ggg hhh' --header_value='1 3.3 "text" true [] {} [1,2,3] {"inner":"a"}'

Verified that headers were set on local server:

header.fields.ggg.0     1
header.fields.ggg.1     2
header.fields.ggg.2     3
header.fields.hhh.inner a
header.fields.aaa       1
header.fields.bbb       3.3
header.fields.ccc       text
header.fields.ddd       true

Potential risks

It was not possible to set header values via CLI when starting a workflow.

This change exposes three new optional parameters for starting a workflow:
- header_key
- header_value
- header_file

They allow setting header values in JSON format which are propogated
via workflow context. Values can be provides either directly or with a
file. If multiple keys and values are used, they separated by a space.
Count of keys and values must be equal, otherwise error is returned.
@@ -311,6 +316,35 @@ func processSearchAttr(c *cli.Context) map[string][]byte {
return fields
}

func processHeader(c *cli.Context) map[string][]byte {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks similar to processMemo, can we try refactor to reduce duplicates?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, refactored them.

@vytautas-karpavicius vytautas-karpavicius changed the title Add header options for starting workflow via CLI Add header options for starting workflow via CLI (#2862) Jun 16, 2020
@vytautas-karpavicius vytautas-karpavicius linked an issue Jun 16, 2020 that may be closed by this pull request
@coveralls
Copy link

coveralls commented Jun 16, 2020

Coverage Status

Coverage increased (+0.5%) to 67.632% when pulling 640ff2f on cli-workflow-start-header-support into fb6e4e0 on master.

@vytautas-karpavicius vytautas-karpavicius merged commit 30bd2b5 into master Jun 17, 2020
@vytautas-karpavicius vytautas-karpavicius deleted the cli-workflow-start-header-support branch June 17, 2020 08:12
yux0 pushed a commit to yux0/cadence that referenced this pull request May 4, 2021
…) (cadence-workflow#3341)

It was not possible to set header values via CLI when starting a workflow.

This change exposes three new optional parameters for starting a workflow:
- header_key
- header_value
- header_file

They allow setting header values in JSON format which are propagated
via workflow context. Values can be provides either directly or with a
file. If multiple keys and values are used, they separated by a space.
Count of keys and values must be equal, otherwise error is returned.
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

Successfully merging this pull request may close these issues.

CLI start workflow needs header support
3 participants