From 297720123ca4ad2f3bfdfacc98910006ca810a86 Mon Sep 17 00:00:00 2001 From: Albin Gilles Date: Wed, 3 Feb 2016 08:55:57 +0100 Subject: [PATCH 1/3] Added possibility to give opts via symbols instead of string as key of the opts hash --- lib/docker/container.rb | 10 +++++----- lib/docker/image.rb | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/docker/container.rb b/lib/docker/container.rb index aaf2c98a8..d5f8c045f 100644 --- a/lib/docker/container.rb +++ b/lib/docker/container.rb @@ -132,7 +132,7 @@ def commit(options = {}) # Based on the link, the config passed as run, needs to be passed as the # body of the post so capture it, remove from the options, and pass it via # the post body - config = options.delete('run') + config = options.delete(:run) || options.delete('run') hash = Docker::Util.parse_json(connection.post('/commit', options, :body => config.to_json)) @@ -163,8 +163,8 @@ def rename(new_name) end def streaming_logs(opts = {}, &block) - stack_size = opts.delete('stack_size') || -1 - tty = opts.delete('tty') || opts.delete(:tty) || false + stack_size = opts.delete(:stack_size) || opts.delete('stack_size') || -1 + tty = opts.delete(:tty) || opts.delete('tty') || false msgs = Docker::MessagesStack.new(stack_size) excon_params = {response_block: Docker::Util.attach_for(block, msgs, tty)} @@ -196,7 +196,7 @@ def kill!(opts = {}) # but rescue from ServerErrors. [:stop, :restart].each do |method| define_method(:"#{method}!") do |opts = {}| - timeout = opts.delete('timeout') + timeout = opts.delete(:timeout) || opts.delete('timeout') query = {} query['t'] = timeout if timeout connection.post(path_for(method), query, :body => opts.to_json) @@ -271,7 +271,7 @@ def archive_in_stream(output_path, opts = {}, &block) # Create a new Container. def self.create(opts = {}, conn = Docker.connection) - name = opts.delete('name') + name = opts.delete(:name) || opts.delete('name') query = {} query['name'] = name if name resp = conn.post('/containers/create', query, :body => opts.to_json) diff --git a/lib/docker/image.rb b/lib/docker/image.rb index 3112ef747..476846cb8 100644 --- a/lib/docker/image.rb +++ b/lib/docker/image.rb @@ -49,8 +49,8 @@ def tag(opts = {}) # Given a path of a local file and the path it should be inserted, creates # a new Image that has that file. def insert_local(opts = {}) - local_paths = opts.delete('localPath') - output_path = opts.delete('outputPath') + local_paths = opts.delete(:localPath) || opts.delete('localPath') + output_path = opts.delete(:outputPath) || opts.delete('outputPath') local_paths = [ local_paths ] unless local_paths.is_a?(Array) From ddb7b7e23fa92d23355ac25914a03224a8f77016 Mon Sep 17 00:00:00 2001 From: Albin Gilles Date: Wed, 30 Mar 2016 07:54:58 +0200 Subject: [PATCH 2/3] Prioritize string over symbol --- lib/docker/container.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/docker/container.rb b/lib/docker/container.rb index d5f8c045f..6774578b1 100644 --- a/lib/docker/container.rb +++ b/lib/docker/container.rb @@ -132,7 +132,7 @@ def commit(options = {}) # Based on the link, the config passed as run, needs to be passed as the # body of the post so capture it, remove from the options, and pass it via # the post body - config = options.delete(:run) || options.delete('run') + config = options.delete('run') || options.delete(:run) hash = Docker::Util.parse_json(connection.post('/commit', options, :body => config.to_json)) @@ -163,8 +163,8 @@ def rename(new_name) end def streaming_logs(opts = {}, &block) - stack_size = opts.delete(:stack_size) || opts.delete('stack_size') || -1 - tty = opts.delete(:tty) || opts.delete('tty') || false + stack_size = opts.delete('stack_size') || opts.delete(:stack_size) || -1 + tty = opts.delete('tty') || opts.delete(:tty) || false msgs = Docker::MessagesStack.new(stack_size) excon_params = {response_block: Docker::Util.attach_for(block, msgs, tty)} @@ -196,7 +196,7 @@ def kill!(opts = {}) # but rescue from ServerErrors. [:stop, :restart].each do |method| define_method(:"#{method}!") do |opts = {}| - timeout = opts.delete(:timeout) || opts.delete('timeout') + timeout = opts.delete('timeout') || opts.delete(:timeout) query = {} query['t'] = timeout if timeout connection.post(path_for(method), query, :body => opts.to_json) @@ -271,7 +271,7 @@ def archive_in_stream(output_path, opts = {}, &block) # Create a new Container. def self.create(opts = {}, conn = Docker.connection) - name = opts.delete(:name) || opts.delete('name') + name = opts.delete('name') || opts.delete(:name) query = {} query['name'] = name if name resp = conn.post('/containers/create', query, :body => opts.to_json) From 4a0bab694a33274fbd8a5532a31840c157beb805 Mon Sep 17 00:00:00 2001 From: Albin Gilles Date: Wed, 30 Mar 2016 07:55:45 +0200 Subject: [PATCH 3/3] Prioritize string over symbol --- lib/docker/image.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/docker/image.rb b/lib/docker/image.rb index 476846cb8..3d4bece58 100644 --- a/lib/docker/image.rb +++ b/lib/docker/image.rb @@ -49,8 +49,8 @@ def tag(opts = {}) # Given a path of a local file and the path it should be inserted, creates # a new Image that has that file. def insert_local(opts = {}) - local_paths = opts.delete(:localPath) || opts.delete('localPath') - output_path = opts.delete(:outputPath) || opts.delete('outputPath') + local_paths = opts.delete('localPath') || opts.delete(:localPath) + output_path = opts.delete('outputPath') || opts.delete(:outputPath) local_paths = [ local_paths ] unless local_paths.is_a?(Array)