Class: Aspera::Plugins::Orchestrator::WorkflowChecker
- Inherits:
-
Object
- Object
- Aspera::Plugins::Orchestrator::WorkflowChecker
- Defined in:
- lib/aspera/plugins/orchestrator/workflow_checker.rb
Overview
Check of an Orchestrator workflow file (.yml) or package (.wkf), before import.
Orchestrator 4.1.6 does not validate the graph on import (import_workflow, import_with_constraints): an invalid workflow is imported,
then fails to publish, or at run time. These checks follow the rules of the designer (Whiteboard#parse_workflow).
With the specifications of plugins (plugins.yml of the plugin documentation), action templates and inputs of steps are also checked:
attributes and their values, required inputs, inputs and outputs that the plugin does not have with its template.
Not checked: availability of plugins on the server.
The interface is that of a REST operation, so that it can be replaced by a call to Orchestrator when one exists:
- request: the fields of
import_workflow:file_name(import_file_name) andcontent(import_file, bytes), and the specifications of plugins (specs), that Orchestrator would not need - response: a Hash (JSON compatible)
valid:trueif there is no issue with severityerrorfile_name: name of the checked fileissues: list of Hashseverity:error(the workflow will not import, publish or run correctly) orwarningcode: stable identifier of the rule, for programs, e.g.graph.step_orphanfile: file of the package where the issue is (absent for a single.ymlfile)path: where in the file, e.g.graph/Step[Say hello]message: description for humans
The file is parsed without instantiating Ruby objects.
Constant Summary collapse
- ERROR =
'error'- WARNING =
'warning'
Instance Attribute Summary collapse
-
#issues ⇒ Object
readonly
Returns the value of attribute issues.
Class Method Summary collapse
-
.check(file_name:, content:, specs: nil) ⇒ Hash
Response, see class description.
Instance Method Summary collapse
-
#initialize(file_name, specs = nil) ⇒ WorkflowChecker
constructor
A new instance of WorkflowChecker.
- #run(content) ⇒ Object
Constructor Details
#initialize(file_name, specs = nil) ⇒ WorkflowChecker
Returns a new instance of WorkflowChecker.
102 103 104 105 106 107 108 109 110 |
# File 'lib/aspera/plugins/orchestrator/workflow_checker.rb', line 102 def initialize(file_name, specs = nil) @file_name = file_name @specs = specs @issues = [] # file of the package being checked @member = nil # attributes of the action templates of the workflow being checked, by key <StepType>__<N> @template_attributes = {} end |
Instance Attribute Details
#issues ⇒ Object (readonly)
Returns the value of attribute issues.
98 99 100 |
# File 'lib/aspera/plugins/orchestrator/workflow_checker.rb', line 98 def issues @issues end |
Class Method Details
.check(file_name:, content:, specs: nil) ⇒ Hash
Returns Response, see class description.
87 88 89 90 91 92 93 94 95 |
# File 'lib/aspera/plugins/orchestrator/workflow_checker.rb', line 87 def check(file_name:, content:, specs: nil) checker = new(file_name, specs) checker.run(content) { 'valid' => checker.issues.none? { |issue| issue['severity'].eql?(ERROR) }, 'file_name' => file_name, 'issues' => checker.issues } end |
Instance Method Details
#run(content) ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/aspera/plugins/orchestrator/workflow_checker.rb', line 113 def run(content) case File.extname(@file_name) when '.yml' then check_yaml(content) when '.wkf' then check_package(content) else add(ERROR, 'file.extension', 'file', "extension must be yml or wkf: #{@file_name}") end end |