Skip to content

Commit

Permalink
Revert "No error is raised if job level property does not have a defa…
Browse files Browse the repository at this point in the history
…ult and is"

This reverts commit 0a1a3cf.
  • Loading branch information
Dolores "Spike" Boshington committed Mar 12, 2016
1 parent cc678e1 commit e628c2a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
12 changes: 12 additions & 0 deletions bosh-director/lib/bosh/director/deployment_plan/planner_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ def process_link_properties(scoped_properties, default_properties, link_property
if default_properties.has_key?('properties') && default_properties['properties'].has_key?(link_property)
if default_properties['properties'][link_property].has_key?('default')
previous_property_in_loop[property_path.last()] = default_properties['properties'][link_property]['default']
else
e = Exception.new("Link property #{link_property} in template #{default_properties['template_name']} has no default value or value supplied by the deployment manifest")
errors.push(e)
end
else
e = Exception.new("Link property #{link_property} in template #{default_properties['template_name']} is not defined in release spec")
Expand All @@ -202,6 +205,15 @@ def process_link_properties(scoped_properties, default_properties, link_property
else
previous_property_in_loop[property_path.last()] = current_property_in_loop
end

# if use_defaults && !default_properties.has_key?("properties") && !default_properties['properties'][link_property].has_key?('default')
# e = Exception.new("Property #{link_property} in template #{default_properties['template_name']} has no default value or value supplied by the deployment manifest")
# errors.push(e)
# elsif use_defaults
# previous_property_in_loop[property_path.last()] = default_properties['properties'][link_property]['default']
# else
# previous_property_in_loop[property_path.last()] = current_property_in_loop
# end
end
return mapped_properties
end
Expand Down
24 changes: 4 additions & 20 deletions bosh-director/spec/unit/deployment_plan/planner_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,14 @@ module DeploymentPlan
end

context 'when template properties_json has the value "null"' do
it 'should not throw an error' do
it 'should not throw an error ' do
allow(DeploymentPlan::Job).to receive(:parse).and_return(job1)
allow(template1).to receive(:release).and_return(release)
allow(template1).to receive(:template_scoped_properties).and_return({})
allow(job1).to receive(:all_properties).and_return({})
allow(DeploymentPlan::LinkPath).to receive(:new).and_return(skipped_link_path)
allow(skipped_link_path).to receive(:parse)
expect(DeploymentPlan::LinkPath).to receive(:new).and_return(skipped_link_path)
expect(skipped_link_path).to receive(:parse)
expect(job1).to_not receive(:add_link_path)

templateModel = Models::Template.where(name: 'provides_template').first
templateModel.properties_json = 'null'
Expand All @@ -339,23 +340,6 @@ module DeploymentPlan
planner
end
end

context 'when link property has no default value and no value is set in the deployment manifest' do
it 'should not throw an error' do
allow(DeploymentPlan::Job).to receive(:parse).and_return(job1)
allow(template1).to receive(:release).and_return(release)
allow(template1).to receive(:template_scoped_properties).and_return({})
allow(job1).to receive(:all_properties).and_return({})
allow(DeploymentPlan::LinkPath).to receive(:new).and_return(skipped_link_path)
allow(skipped_link_path).to receive(:parse)

templateModel = Models::Template.where(name: 'provides_template').first
templateModel.properties = {"a" => {}}
templateModel.save

planner
end
end
end
end
end
Expand Down

0 comments on commit e628c2a

Please sign in to comment.