Skip to content

Commit

Permalink
Merge pull request zendesk#2927 from zendesk/grosser/valid
Browse files Browse the repository at this point in the history
PAAS-2064 allow opting out of label validation for services that match multiple deployments
  • Loading branch information
grosser authored Sep 10, 2018
2 parents a91fbed + f697760 commit d028b73
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugins/kubernetes/app/models/kubernetes/role_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ def validate_numeric_limits
def validate_project_and_role_consistent
labels = @elements.flat_map do |resource|
kind = resource[:kind]
allow_cross_match = resource.dig(:metadata, :annotations, :"samson/service_selector_across_roles") == "true"

label_paths = metadata_paths(resource).map { |p| p + [:labels] } +
case kind
when 'Service'
[
[:spec, :selector]
]
allow_cross_match ? [] : [[:spec, :selector]]
when 'PodDisruptionBudget'
[
[:spec, :selector, :matchLabels]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@
]
end

it "allows cross-matching services when opted in" do
role[1][:spec][:selector].delete(:role)
role[1][:metadata][:annotations] = {"samson/service_selector_across_roles": "true"}
errors.must_be_nil
end

it "reports missing label section" do
role.first[:spec][:template][:metadata].delete(:labels)
errors.must_equal [
Expand Down

0 comments on commit d028b73

Please sign in to comment.