diff --git a/mistral/db/v2/sqlalchemy/models.py b/mistral/db/v2/sqlalchemy/models.py index cd4cf791..85223f73 100644 --- a/mistral/db/v2/sqlalchemy/models.py +++ b/mistral/db/v2/sqlalchemy/models.py @@ -148,6 +148,7 @@ class Action(mb.MistralModelBase): id = mb.id_column() name = sa.Column(sa.String(200)) description = sa.Column(sa.Text()) + tags = sa.Column(st.JsonListType()) input = sa.Column(sa.String(240)) # Ad-hoc action properties. diff --git a/mistral/services/actions.py b/mistral/services/actions.py index 418a709a..caeb47e2 100644 --- a/mistral/services/actions.py +++ b/mistral/services/actions.py @@ -50,6 +50,7 @@ def create_action(action_spec, definition): values = { 'name': action_spec.get_name(), 'description': action_spec.get_description(), + 'tags': action_spec.get_tags(), 'definition': definition, 'spec': action_spec.to_dict(), 'is_system': False @@ -72,6 +73,7 @@ def create_or_update_action(action_spec, definition): values = { 'name': action_spec.get_name(), 'description': action_spec.get_description(), + 'tags': action_spec.get_tags(), 'definition': definition, 'spec': action_spec.to_dict(), 'is_system': False diff --git a/mistral/services/workflows.py b/mistral/services/workflows.py index 7471c2c2..01dc340d 100644 --- a/mistral/services/workflows.py +++ b/mistral/services/workflows.py @@ -47,6 +47,7 @@ def update_workflows(definition): def create_workflow(wf_spec, definition): values = { 'name': wf_spec.get_name(), + 'tags': wf_spec.get_tags(), 'definition': definition, 'spec': wf_spec.to_dict() } @@ -59,6 +60,7 @@ def create_workflow(wf_spec, definition): def create_or_update_workflow(wf_spec, definition): values = { 'name': wf_spec.get_name(), + 'tags': wf_spec.get_tags(), 'definition': definition, 'spec': wf_spec.to_dict() } diff --git a/mistral/tests/unit/services/test_action_service.py b/mistral/tests/unit/services/test_action_service.py index 072050f5..c97b25bd 100644 --- a/mistral/tests/unit/services/test_action_service.py +++ b/mistral/tests/unit/services/test_action_service.py @@ -32,6 +32,7 @@ ACTION_LIST = """ version: '2.0' action1: + tags: [test, v2] base: std.echo output='Hi' output: result: $ @@ -72,6 +73,7 @@ class ActionServiceTest(base.DbTestCase): action1_spec = spec_parser.get_action_spec(action1_db.spec) self.assertEqual('action1', action1_spec.get_name()) + self.assertListEqual(['test', 'v2'], action1_spec.get_tags()) self.assertEqual('std.echo', action1_spec.get_base()) self.assertDictEqual({'output': 'Hi'}, action1_spec.get_base_input()) @@ -103,6 +105,7 @@ class ActionServiceTest(base.DbTestCase): action1_spec = spec_parser.get_action_spec(action1_db.spec) self.assertEqual('action1', action1_spec.get_name()) + self.assertListEqual([], action1_spec.get_tags()) self.assertEqual('std.echo', action1_spec.get_base()) self.assertDictEqual({'output': 'Hi'}, action1_spec.get_base_input()) self.assertListEqual(['param1'], action1_spec.get_input()) diff --git a/mistral/tests/unit/services/test_workflow_service.py b/mistral/tests/unit/services/test_workflow_service.py index 694bc132..e4ab6eb7 100644 --- a/mistral/tests/unit/services/test_workflow_service.py +++ b/mistral/tests/unit/services/test_workflow_service.py @@ -31,6 +31,7 @@ WORKFLOW_LIST = """ version: '2.0' wf1: + tags: [test, v2] type: reverse input: - param1 @@ -86,6 +87,7 @@ class WorkflowServiceTest(base.DbTestCase): wf1_spec = spec_parser.get_workflow_spec(wf1_db.spec) self.assertEqual('wf1', wf1_spec.get_name()) + self.assertListEqual(['test', 'v2'], wf1_spec.get_tags()) self.assertEqual('reverse', wf1_spec.get_type()) # Workflow 2. @@ -116,5 +118,6 @@ class WorkflowServiceTest(base.DbTestCase): wf1_spec = spec_parser.get_workflow_spec(wf1_db.spec) self.assertEqual('wf1', wf1_spec.get_name()) + self.assertListEqual([], wf1_spec.get_tags()) self.assertEqual('reverse', wf1_spec.get_type()) self.assertListEqual(['param1', 'param2'], wf1_spec.get_input())