Closed zuazo closed 8 years ago
Great improvement! Thanks for contributing. Merging...
@zuazo :
Gem version 1.0.3 was released. It's already available in RubyGems.
Thanks for the support so far o/
@mauricioklein thanks!
It seems that inadvertently you have released the new gem with the old 1.0.2
code. The tag in GitHub is OK, but not the version uploaded to RubyGems:
diff -uNr ~/src/docker-compose-api/lib/docker-compose/models/compose_container.rb ~/.rvm/gems/ruby-2.1.2@docker-compose-api/gems/docker-compose-api-1.0.3/lib/docker-compose/models/compose_container.rb
--- ~/src/docker-compose-api/lib/docker-compose/models/compose_container.rb 2015-12-28 14:59:11.896477068 +0100
+++ ~/.rvm/gems/ruby-2.1.2@docker-compose-api/gems/docker-compose-api-1.0.3/lib/docker-compose/models/compose_container.rb 2015-12-28 16:23:50.775503014 +0100
@@ -15,7 +15,7 @@
ports: prepare_ports(hash_attributes[:ports]),
volumes: hash_attributes[:volumes],
command: ComposeUtils.format_command(hash_attributes[:command]),
- environment: prepare_environment(hash_attributes[:environment])
+ environment: hash_attributes[:environment]
}.reject{ |key, value| value.nil? }
# Docker client variables
@@ -101,8 +101,7 @@
links = []
@dependencies.each do |dependency|
- link_name = @attributes[:links][dependency.attributes[:label]]
- links << "#{dependency.stats['Id']}:#{link_name}"
+ links << "#{dependency.stats['Id']}:#{dependency.attributes[:label]}"
end
links
@@ -127,14 +126,6 @@
end
#
- # Forces the environment structure to use the array format.
- #
- def prepare_environment(env_entries)
- return env_entries unless env_entries.is_a?(Hash)
- env_entries.to_a.map { |x| x.join('=') }
- end
-
- #
# Check if a given image already exists in host
#
def image_exists(image_name)
@@ -165,7 +156,7 @@
# Stop the container
#
def stop
- @container.stop unless @container.nil?
+ @container.kill unless @container.nil?
end
#
@@ -204,11 +195,4 @@
def running?
@container.nil? ? false : self.stats['State']['Running']
end
-
- #
- # Check if the container exists or not
- #
- def exist?
- !@container.nil?
- end
end
Binary files ~/src/docker-compose-api/lib/docker-compose/models/.compose_container.rb.swp and ~/.rvm/gems/ruby-2.1.2@docker-compose-api/gems/docker-compose-api-1.0.3/lib/docker-compose/models/.compose_container.rb.swp differ
diff -uNr ~/src/docker-compose-api/lib/docker-compose/models/compose.rb ~/.rvm/gems/ruby-2.1.2@docker-compose-api/gems/docker-compose-api-1.0.3/lib/docker-compose/models/compose.rb
--- ~/src/docker-compose-api/lib/docker-compose/models/compose.rb 2015-12-28 14:59:11.896477068 +0100
+++ ~/.rvm/gems/ruby-2.1.2@docker-compose-api/gems/docker-compose-api-1.0.3/lib/docker-compose/models/compose.rb 2015-12-28 16:23:50.775503014 +0100
@@ -58,27 +58,16 @@
end
#
- # Kill a container
+ # Stop a container
#
# This method accepts an array of labels.
- # If labels is informed, only those containers with label present in array will be killed.
- # Otherwise, all containers are killed
+ # If labels is informed, only those containers with label present in array will be stopped.
+ # Otherwise, all containers are stopped
#
def kill(labels = [])
call_container_method(:kill, labels)
end
- #
- # Delete a container
- #
- # This method accepts an array of labels.
- # If labels is informed, only those containers with label present in array will be deleted.
- # Otherwise, all containers are deleted
- #
- def delete(labels = [])
- call_container_method(:delete, labels)
- end
-
private
def call_container_method(method, labels = [])
diff -uNr ~/src/docker-compose-api/lib/docker-compose/utils/compose_utils.rb ~/.rvm/gems/ruby-2.1.2@docker-compose-api/gems/docker-compose-api-1.0.3/lib/docker-compose/utils/compose_utils.rb
--- ~/src/docker-compose-api/lib/docker-compose/utils/compose_utils.rb 2015-12-28 14:59:11.896477068 +0100
+++ ~/.rvm/gems/ruby-2.1.2@docker-compose-api/gems/docker-compose-api-1.0.3/lib/docker-compose/utils/compose_utils.rb2015-12-28 16:23:50.775503014 +0100
@@ -62,8 +62,6 @@
# Generate a pair key:hash with
# format {service:label}
#
- # The label will be the conainer name if not specified.
- #
def self.format_links(links_array)
links = {}
@@ -74,7 +72,7 @@
case parts.length
when 1
- links[parts[0]] = parts[0]
+ links[parts[0]] = SecureRandom.hex
when 2
links[parts[0]] = parts[1]
Hello @zuazo !
Yes, it seems like that. I've released a new version (1.0.4), with your PR's. It's already available in RubyGems. Thanks for the warning and sorry about the mistake.
PS: Please let me know if you face any other problem.
@mauricioklein thanks for your quick response!
Add a simple
#delete
method:Other tiny fixes included in this PR:
Compose#kill
documentation.Compose#stop
callsContainer#stop
instead ofContainer#kill
.