Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not blow up with strange error when file is missing in repo or inv… #2202

Merged
merged 1 commit into from
Aug 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,12 @@ def verify_kubernetes_templates!
end

# make sure each set of templates is valid
configs = roles.map { |r| r.fetch(:role).role_config_file(@job.commit).primary }.compact
configs = roles.map do |r|
role = r.fetch(:role)
config = role.role_config_file(@job.commit)
raise Samson::Hooks::UserError, "Error parsing #{role.config_file}" unless config
config.primary
end.compact
Kubernetes::RoleVerifier.verify_group(configs)
end
end
Expand Down
2 changes: 1 addition & 1 deletion plugins/kubernetes/app/models/kubernetes/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def role_config_file(reference)
begin
RoleConfigFile.new(raw_template, config_file)
rescue Samson::Hooks::UserError
return
nil
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,16 @@ def worker_is_unstable
end
e.message.must_include "Missing env variables FOO, BAR"
end

it "fails before building when role config is missing" do
GitRepository.any_instance.stubs(:file_content).with('kubernetes/resque_worker.yml', commit, anything).
returns(nil)

e = assert_raises Samson::Hooks::UserError do
refute execute
end
e.message.must_include "Error parsing kubernetes/resque_worker.yml"
end
end

describe "role settings" do
Expand Down