Class: ConcourseCorrelator
- Inherits:
-
Object
- Object
- ConcourseCorrelator
- Defined in:
- lib/preflight_check/concourse_correlator.rb
Instance Method Summary collapse
- #build_utilized_resource_list(jobs) ⇒ Object
- #dep_is_defined_as_resource(dep, resources) ⇒ Object
- #mark_missing_dependencies(job, resources) ⇒ Object
- #process_jobs(jobs:, resources:) ⇒ Object
Instance Method Details
#build_utilized_resource_list(jobs) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/preflight_check/concourse_correlator.rb', line 24 def build_utilized_resource_list(jobs) utilized_resource_names = [] jobs.each do |job| job.dependencies.each do |dep| utilized_resource_names << dep.name end end utilized_resource_names end |
#dep_is_defined_as_resource(dep, resources) ⇒ Object
45 46 47 |
# File 'lib/preflight_check/concourse_correlator.rb', line 45 def dep_is_defined_as_resource(dep, resources) resources.find { |resource| resource.name == dep.name } end |
#mark_missing_dependencies(job, resources) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/preflight_check/concourse_correlator.rb', line 34 def mark_missing_dependencies(job, resources) job.dependencies.each do |dep| if dep_is_defined_as_resource(dep, resources) dep.defined = true else job.mark_as_failed dep.defined = false end end end |
#process_jobs(jobs:, resources:) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/preflight_check/concourse_correlator.rb', line 4 def process_jobs(jobs:, resources:) jobs.each { |job| mark_missing_dependencies(job, resources) } used_resources = build_utilized_resource_list(jobs) failed_resources = [] resources.each do |resource| consumed_resource = used_resources.find do |used_resource_name| used_resource_name == resource.name end if consumed_resource.nil? failed_resources << resource end end failed_jobs = jobs.reject(&:success?) ValidatorResult.new(failed_jobs: failed_jobs, failed_resources: failed_resources) end |