StackStorm / StackStorm/st2

Rule should match if optional action parameters are not specified in payload

Open
#3,217 20 comments 2 reactions 1 assignee View on GitHub

@Kami is already working on this.

Since Feb 21, 2017.

bug status:to be verified
Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

/opt/stackstorm/packs/my_application/actions/deploy.yaml

---
name: 'deploy'
description: 'Workflow to deploy an application'
runner_type: 'mistral-v2'
entry_point: 'workflows/deploy.yaml'
enabled: true
parameters:
  repo_url:
    description: The repository URL of the (compiled) application
    required: true
    position: 0
  server_application:
    description: The application/purpose of a server to deploy this application to
    required: true
    position: 1
  server_role:
    description: The role of a server to deploy this application to. Possible values are "tomcat", "apache", "postgres", "rabbitmq", etc
    required: true
    position: 2
  server_environment:
    description: The environment of a server to deploy this application to. Possible values are "prd", "acc", "tst" or "dev"
    required: true
    position: 3
  target_dir:
    description: The target directory for the application code
    position: 4
  pre_update_command:
    description: 'This command is executed locally before code is updated'
    position: 5
  post_update_command:
    description: 'This command is executed locally after code is updated'
    position: 6

/opt/stackstorm/packs/my_application/triggers/deploytrigger.yaml

---
name: deploytrigger
description: 'Application deployment trigger.'

/opt/stackstorm/packs/my_application/rules/deploy.yaml

---
name: deploy
description: "Deployment rule that can be called for an application deployment from Jenkins or something similar."
enabled: true

trigger:
  type: my_application.deploytrigger

action:
  ref: "my_application.deploy"
  parameters:
    repo_url: "{{trigger.repo_url}}"
    server_application: "{{trigger.server_application}}"
    server_role: "{{trigger.server_role}}"
    server_environment: "{{trigger.server_environment}}"
    target_dir: "{{trigger.target_dir}}"
    pre_update_command: "{{trigger.pre_update_command}}"
    post_update_command: "{{trigger.post_update_command}}"

/tmp/trigger-instance.yaml

---
trigger: "my_application.deploytrigger"
payload:
  repo_url: "ssh://git@bitbucket.org/my/helloworldapp.git"
  server_application: "shared"
  server_role: "apache"
  server_environment: "tst"
  target_dir: "/srv/helloworldapp"
  pre_update_command: ~
  post_update_command: ~

A rule DOES match if I run the rule tester with all the workflow/action parameters defined in the trigger instance payload:

st2-rule-tester --config-file /etc/st2/st2.conf --rule=/opt/stackstorm/packs/my_application/rules/deploy.yaml --trigger-instance=/tmp/trigger-instance.yaml --debug --verbose

However if I DON'T specify the optional workflow parameters "target_dir", "pre_update_command" and "post_update_command" there is NO rule match. It would be nice if optional workflow/action parameters are not required in the trigger payload.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.