jarl 0.8.3 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61631bf03f69db561a1d8a9c69dbf83a9126ffb6
4
- data.tar.gz: 4f1cc485a811a7ebc7c908c8d638894b76318077
3
+ metadata.gz: e8ca764b83d720d8c5b54eec8db4fc5177c6f2f3
4
+ data.tar.gz: a605b6f8e2f8447eabad0a23b4cad4b0a46b246f
5
5
  SHA512:
6
- metadata.gz: 585653b90b50cd05586c2af13b51516c1391f214e9efb2dfe689f9382499bdd051f98355da1ab6306537242db54d247f44f3d45f1f13280562e0f2679e3e9c32
7
- data.tar.gz: d49cbd4277bf2b99b6863c5b21ed7d666b5f5bd1b37460fdef4edbd3fbe7cbe2fa9c14756a6c962e9e01240831fc6e8a9fec56f2e3dcd5c96ceabb9c9f3dd338
6
+ metadata.gz: 12099f11b9fe1be9c35b467d5f5ab3590fee1df75e90bf20d411faaa7790d87c611a8a5fdc8c6dd294345399525fa629814a44b8ba8bd48889142305fedc9e9b
7
+ data.tar.gz: 9ddeebf7fe96b833fb7544fca4d7e3c35cddacf46bb91526716f9d1a86a94f5f7eae69f7ff0ed9fb580849a8a6d0730ce3c33dd07666001633c81b072dbf9cc0
@@ -1,7 +1,7 @@
1
1
  module Jarl
2
2
  class Application
3
3
  attr_reader :group, :name, :hostname, :base_path
4
- attr_reader :image, :scale, :volumes, :ports, :environment, :entrypoint, :command
4
+ attr_reader :image, :scale, :volumes, :ports, :environment, :entrypoint, :command, :logging
5
5
  attr_reader :serial
6
6
 
7
7
  # Create Application object from application definition:
@@ -46,6 +46,17 @@ module Jarl
46
46
  if @command && !@command.is_a?(String)
47
47
  fail "Application '#{self}' has invalid 'command' definition, String is expected"
48
48
  end
49
+ @logging = (params['logging'] || {}).map { |k, v| [k.to_sym, v] }.to_h
50
+ unless @logging.is_a?(Hash)
51
+ fail "Application '#{self}' has invalid 'logging' definition, Hash is expected"
52
+ end
53
+ @logging = @logging.map { |k, v| [k.to_sym, v] }.to_h # .symbolize_keys
54
+ if @logging[:driver] && !@logging[:driver].is_a?(String)
55
+ fail "Application '#{self}' has invalid 'logging:driver' definition, String is expected"
56
+ end
57
+ if @logging[:options] && !@logging[:options].is_a?(Hash)
58
+ fail "Application '#{self}' has invalid 'logging:options' definition, Hash is expected"
59
+ end
49
60
  @serial = self.class.next_serial
50
61
  @hostname = @name
51
62
  end
@@ -115,7 +126,8 @@ module Jarl
115
126
  volumes: volumes,
116
127
  ports: ports,
117
128
  environment: environment,
118
- command: (execute_command || command || '') + ' ' + args.join(' ')
129
+ command: (execute_command || command || '') + ' ' + args.join(' '),
130
+ logging: logging
119
131
  )
120
132
  end
121
133
 
@@ -197,7 +209,8 @@ module Jarl
197
209
  volumes: application.volumes,
198
210
  ports: application.ports,
199
211
  environment: application.environment,
200
- command: application.command
212
+ command: application.command,
213
+ logging: application.logging
201
214
  )
202
215
  end
203
216
 
@@ -98,11 +98,9 @@ module Docker
98
98
  raise unless e.to_s =~ /Command failed/
99
99
  end
100
100
 
101
- # Start container defined by params
101
+ # Construct options string for running a container
102
102
  #
103
- def self.start(params)
104
- container_name = params[:name]
105
- Docker::Container.clean_containers(container_name)
103
+ def self.run_options(params)
106
104
  opts = []
107
105
  opts << params[:volumes].map do |v|
108
106
  "-v #{v}"
@@ -113,7 +111,23 @@ module Docker
113
111
  opts << params[:environment].map do |k, v|
114
112
  "-e #{k}='#{v}'"
115
113
  end.join(' ')
116
- docker_cmd = "docker run -d #{opts.join(' ')} " \
114
+ if params[:logging] && params[:logging][:driver]
115
+ opts << "--log-driver #{params[:logging][:driver]}"
116
+ end
117
+ if params[:logging] && params[:logging][:options]
118
+ opts << params[:logging][:options].map do |k, v|
119
+ "--log-opt #{k}='#{v}'"
120
+ end.join(' ')
121
+ end
122
+ opts.join(' ')
123
+ end
124
+
125
+ # Start container defined by params
126
+ #
127
+ def self.start(params)
128
+ container_name = params[:name]
129
+ Docker::Container.clean_containers(container_name)
130
+ docker_cmd = "docker run -d #{run_options(params)} " \
117
131
  " --hostname #{params[:hostname]} " \
118
132
  " --name #{container_name} #{params[:image]} #{params[:command]}"
119
133
  # puts docker_cmd
@@ -125,17 +139,7 @@ module Docker
125
139
  def self.execute(params)
126
140
  container_name = "#{params[:name]}.execute"
127
141
  Docker::Container.clean_containers(container_name)
128
- opts = []
129
- opts << params[:volumes].map do |v|
130
- "-v #{v}"
131
- end.join(' ')
132
- opts << params[:ports].map do |p|
133
- "-p #{p}"
134
- end.join(' ')
135
- opts << params[:environment].map do |k, v|
136
- "-e #{k}='#{v}'"
137
- end.join(' ')
138
- docker_cmd = "docker run -t -i --rm #{opts.join(' ')} " \
142
+ docker_cmd = "docker run -t -i --rm #{run_options(params)} " \
139
143
  " --hostname #{params[:hostname]} " \
140
144
  " --name #{container_name} #{params[:image]} #{params[:command]}"
141
145
  # puts docker_cmd
@@ -1,3 +1,3 @@
1
1
  module Jarl
2
- VERSION = '0.8.3'
2
+ VERSION = '0.9.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jarl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Kukushkin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2017-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 2.4.5.1
114
+ rubygems_version: 2.5.2
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: Jarl, docker container management tool