Skip to content

Commit

Permalink
Remove role name uniqueness check
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahloui committed Sep 1, 2023
1 parent dcbe87b commit 342ca4f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 23 deletions.
7 changes: 0 additions & 7 deletions lib/cove/configuration/contracts/service_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@ class ServiceContract < Dry::Validation::Contract
end
end

role_names = []

rule(:roles).each do |index:|
if index == 0
role_names.clear
end
key([:roles, index, :name]).failure("#{value[:name]} is not a valid name. The name for each role must be unique.") if role_names.include?(value[:name])
role_names << value[:name]
if value[:ingress].present?
value[:ingress].each_with_index do |ingress, ingress_index|
source_key = key([:roles, index, :ingress, ingress_index, :source])
Expand Down
16 changes: 0 additions & 16 deletions spec/cove/configuration/contracts/service_contract_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,6 @@
expect(result.success?).to eq(true)
end

context "name" do
it "fails when a role does not have a name" do
contract = Cove::Configuration::Contracts::ServiceContract.new
result = contract.call(service_name: "a", image: "b", roles: [{container_count: 2}])
expect(result.errors[:roles][0][:name]).to be_present
expect(result.success?).to eq(false)
end

it "fails with duplicate role names" do
contract = Cove::Configuration::Contracts::ServiceContract.new
result = contract.call(service_name: "nginx", image: "nginx:1.23.4", roles: [{name: "web"}, {name: "web"}, {name: "web2"}])
expect(result.errors[:roles][1][:name]).to be_present
expect(result.success?).to eq(false)
end
end

context "container_count" do
it "succeeds when container_count is not included" do
contract = Cove::Configuration::Contracts::ServiceContract.new
Expand Down

0 comments on commit 342ca4f

Please sign in to comment.