From 57b8bf558dc221817b7105477a460b9ec8d3b279 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Fri, 29 Mar 2024 13:48:31 -0400 Subject: [PATCH] Set the Workflow description to ASL Comment --- .../configuration_script_source.rb | 18 +++++++++++++++++- manageiq-providers-workflows.gemspec | 2 +- .../configuration_script_source_spec.rb | 1 + spec/support/fake_workflows_repo.rb | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/models/manageiq/providers/workflows/automation_manager/configuration_script_source.rb b/app/models/manageiq/providers/workflows/automation_manager/configuration_script_source.rb index f4268df..3643cda 100644 --- a/app/models/manageiq/providers/workflows/automation_manager/configuration_script_source.rb +++ b/app/models/manageiq/providers/workflows/automation_manager/configuration_script_source.rb @@ -76,8 +76,24 @@ def sync_from_content(to_delete) end def create_workflow_from_payload(name, payload) + floe_workflow = + begin + Floe::Workflow.new(payload) + rescue Floe::InvalidWorkflowError + nil + end + + description = floe_workflow&.comment + configuration_script_payloads.find_or_initialize_by(:name => name).tap do |wf| - wf.update!(:name => name, :manager_id => manager_id, :type => self.class.module_parent::Workflow.name, :payload => payload, :payload_type => "json") + wf.update!( + :name => name, + :description => description, + :manager_id => manager_id, + :type => self.class.module_parent::Workflow.name, + :payload => payload, + :payload_type => "json" + ) end end end diff --git a/manageiq-providers-workflows.gemspec b/manageiq-providers-workflows.gemspec index 9550dfc..246cfd3 100644 --- a/manageiq-providers-workflows.gemspec +++ b/manageiq-providers-workflows.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency "floe", "~> 0.9.0" + spec.add_dependency "floe", "~> 0.10.0" spec.add_development_dependency "manageiq-style" spec.add_development_dependency "simplecov", ">= 0.21.2" diff --git a/spec/models/manageiq/providers/workflows/automation_manager/configuration_script_source_spec.rb b/spec/models/manageiq/providers/workflows/automation_manager/configuration_script_source_spec.rb index a0eb4be..8e8c40d 100644 --- a/spec/models/manageiq/providers/workflows/automation_manager/configuration_script_source_spec.rb +++ b/spec/models/manageiq/providers/workflows/automation_manager/configuration_script_source_spec.rb @@ -195,6 +195,7 @@ def files_in_repository(git_repo_dir) expect(record.configuration_script_payloads.first).to have_attributes( :name => "hello_world.asl", + :description => "hello world", :payload => a_string_including("\"Comment\": \"hello world\""), :payload_type => "json" ) diff --git a/spec/support/fake_workflows_repo.rb b/spec/support/fake_workflows_repo.rb index 167991e..9d43550 100644 --- a/spec/support/fake_workflows_repo.rb +++ b/spec/support/fake_workflows_repo.rb @@ -14,7 +14,7 @@ def file_content(full_path) def dummy_workflow_data_for(_filename) <<~WORKFLOW_DATA - {"Comment": "hello world"} + {"Comment": "hello world", "States": {"Start": {"Type": "Succeed"}}, "StartAt": "Start"} WORKFLOW_DATA end end