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

Adds Docker watcher ability to use images without tags #221

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion lib/synapse/service_watcher/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def containers
end
# Discover containers that match the image/port we're interested in and have the port mapped to the host
cnts = cnts.find_all do |cnt|
cnt["Image"].rpartition(":").first == @discovery["image_name"] \
cnt["Image"].split(":", 2).first == @discovery["image_name"] \
and cnt["Ports"].has_key?(@discovery["container_port"].to_s()) \
and cnt["Ports"][@discovery["container_port"].to_s()].length > 0
end
Expand Down
8 changes: 8 additions & 0 deletions spec/lib/synapse/service_watcher_docker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,13 @@ def add_arg(name, value)
expect(subject.send(:containers)).to eql([{"name"=>"mainserver", "host"=>"server1.local", "port"=>"49153"}])
end
end

context 'finds images without tags' do
let(:docker_data) { [{"Ports" => "0.0.0.0:49153->6379/tcp, 0.0.0.0:49154->6390/tcp", "Image" => "mycool/image"}, {"Ports" => "0.0.0.0:49155->6379/tcp", "Image" => "wrong/image"}] }
it do
expect(Docker::Util).to receive(:parse_json).and_return(docker_data)
expect(subject.send(:containers)).to eql([{"name"=>"mainserver", "host"=>"server1.local", "port"=>"49153"}])
end
end
end
end