inventory-server 0.0.3 → 0.0.4

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: 74a1c94c1fee7d286ad01c8857a3f0f403dbea37
4
- data.tar.gz: fac998a8d0b204d1d5eac6aab28d4c51522c1232
3
+ metadata.gz: 595a004bb77d3fdca856383c3d152fd56661116b
4
+ data.tar.gz: 94473b188763f55c6b0fc01f273081eecaa4d985
5
5
  SHA512:
6
- metadata.gz: 1e4816b1f1bd5367aef0f8644cfcb8efb41244a021c8eb98e3759fd4f7a6c892f31245e99a92710ba1e78c0c151f2b91a01c1ca43b416d5203f9b72ba082065d
7
- data.tar.gz: e8b49299152502b73bd08b9c2a3645fcf89336822c3ead118206a210c145c8d69bc506994a484e52f20770a04f14590ccdac73d0dd2a2ca4a77ae6ce329de383
6
+ metadata.gz: a7a68d033a11a1749a7aefc7e33507ca594547dc06de24e047495e3cef0a31cacff3ef1887e2ae64aaa07dc8de0bb49d45188c005eecdc8a4cb8cccd4e1c1301
7
+ data.tar.gz: 66c8c902a5fec61afb29d5b4d0832d8ee98176095c85a1955df0ad7e5a6de07bc8f9cebe7a131bd27a48044bd07865f4a952f0a6ff1edb121dbc185523c80f15
data/Dockerfile CHANGED
@@ -1,11 +1,11 @@
1
1
  FROM centos
2
2
  MAINTAINER Filirom1 <filirom1@gmail.com>
3
3
 
4
- ADD . /app
5
-
6
4
  RUN yum install -y epel-release
7
5
  RUN yum install -y patch tar git ruby ruby-devel rubygem-bundler make gcc gcc-c++ zlib-devel libxml2-devel nginx
8
6
 
7
+ ADD . /app
8
+
9
9
  RUN cd /app && bundle install
10
10
 
11
11
  RUN cp /app/docker/unicorn/unicorn.conf /etc/nginx/conf.d/unicorn.conf && \
@@ -19,4 +19,5 @@ RUN mkdir -p /var/log/inventory && chmod o+rwX /var/log/inventory && \
19
19
  VOLUME ["/var/log/nginx", "/var/log/inventory"]
20
20
 
21
21
  EXPOSE 80
22
+ WORKDIR /app
22
23
  CMD ["/app/docker/unicorn/run-unicorn.sh"]
data/Dockerfile-passenger CHANGED
@@ -1,8 +1,6 @@
1
1
  FROM centos
2
2
  MAINTAINER Filirom1 <filirom1@gmail.com>
3
3
 
4
- ADD . /app
5
-
6
4
  RUN yum install -y epel-release
7
5
  RUN yum install -y patch tar git ruby ruby-devel rubygem-bundler make gcc gcc-c++ zlib-devel libxml2-devel httpd \
8
6
  http://puias.math.ias.edu/data/puias/unsupported/7/x86_64/mod_passenger-4.0.18-9.5.sdl7.x86_64.rpm \
@@ -10,9 +8,12 @@ RUN yum install -y patch tar git ruby ruby-devel rubygem-bundler make gcc gcc-c+
10
8
  http://puias.math.ias.edu/data/puias/unsupported/7/x86_64/rubygem-passenger-native-4.0.18-9.5.sdl7.x86_64.rpm \
11
9
  http://puias.math.ias.edu/data/puias/unsupported/7/x86_64/rubygem-passenger-native-libs-4.0.18-9.5.sdl7.x86_64.rpm
12
10
 
11
+ ADD . /app
12
+
13
13
  RUN cd /app && bundle install
14
14
  RUN cp /app/docker/passenger/passenger.conf /etc/httpd/conf.d/passenger.conf
15
15
  RUN mkdir -p /var/log/inventory && chmod o+rwX /var/log/inventory
16
16
 
17
17
  EXPOSE 80
18
+ WORKDIR /app
18
19
  CMD ["/app/docker/passenger/run-httpd.sh"]
data/Dockerfile-unicorn CHANGED
@@ -1,11 +1,11 @@
1
1
  FROM centos
2
2
  MAINTAINER Filirom1 <filirom1@gmail.com>
3
3
 
4
- ADD . /app
5
-
6
4
  RUN yum install -y epel-release
7
5
  RUN yum install -y patch tar git ruby ruby-devel rubygem-bundler make gcc gcc-c++ zlib-devel libxml2-devel nginx
8
6
 
7
+ ADD . /app
8
+
9
9
  RUN cd /app && bundle install
10
10
 
11
11
  RUN cp /app/docker/unicorn/unicorn.conf /etc/nginx/conf.d/unicorn.conf && \
@@ -19,4 +19,5 @@ RUN mkdir -p /var/log/inventory && chmod o+rwX /var/log/inventory && \
19
19
  VOLUME ["/var/log/nginx", "/var/log/inventory"]
20
20
 
21
21
  EXPOSE 80
22
+ WORKDIR /app
22
23
  CMD ["/app/docker/unicorn/run-unicorn.sh"]
@@ -63,7 +63,7 @@ module Inventory
63
63
  def self.env()
64
64
  hash = {}
65
65
  ENV.each {|key, value|
66
- next unless key.start_with? 'INVENTORY_'
66
+ next unless key.is_a? String and key.start_with? 'INVENTORY_'
67
67
  key = key.gsub 'INVENTORY_', ''
68
68
  key = key.downcase
69
69
  hash[key] = value
@@ -37,12 +37,12 @@ module Inventory
37
37
  InventoryLogger.logger.context_id = id
38
38
 
39
39
  request.body.rewind
40
- settings.middlewares.call(:id => id, :body => request.body.read, :config => settings.config)
41
- {:id => id, :ok => true, :status => 200}.to_json
40
+ result = settings.middlewares.call({ :id => id, :body => request.body.read, :config => settings.config })
41
+ return {:id => id}.merge!(result).to_json
42
42
  end
43
43
 
44
44
  error 400..500 do
45
- {:id => env[:id], :ok => false, :status => status, :message => env['sinatra.error']}.to_json
45
+ {:id => env[:id], :message => env['sinatra.error']}.to_json
46
46
  end
47
47
  end
48
48
  end
@@ -1,5 +1,5 @@
1
1
  module Inventory
2
2
  module Server
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
data/plugins/index.rb CHANGED
@@ -44,6 +44,7 @@ module Inventory
44
44
  end
45
45
  end
46
46
  @app.call(env)
47
+ facts
47
48
  end
48
49
 
49
50
  private
@@ -1,11 +1,17 @@
1
1
  require 'inventory/server/config'
2
2
 
3
3
  RSpec.describe Inventory::Server::Config do
4
- before do
5
- ENV['INVENTORY_FAILED_FACTS_DIR'] = "./log/"
6
- end
7
-
8
4
  context "without configuration" do
5
+ before do
6
+ # remove env env configuration
7
+ ENV.each{|key|
8
+ next unless key.is_a? String and key.start_with? 'INVENTORY_'
9
+ ENV[key] = nil
10
+ }
11
+ # avoid mkdir exception
12
+ expect(FileUtils).to receive(:mkdir_p).with(any_args)
13
+ end
14
+
9
15
  it "should should use default configuration" do
10
16
  config = Inventory::Server::Config.generate({})
11
17
  expect(config[:smtp_port]).to eq 2525
@@ -13,6 +19,10 @@ RSpec.describe Inventory::Server::Config do
13
19
  end
14
20
 
15
21
  context "with etc configuration" do
22
+ before do
23
+ ENV['INVENTORY_FAILED_FACTS_DIR'] = "./log/"
24
+ end
25
+
16
26
  before(:each) do
17
27
  expect(Inventory::Server::Config).to receive(:etc).and_return({:smtp_port => 2424})
18
28
  end
@@ -15,6 +15,7 @@ RSpec.describe Inventory::Server::HTTPServer do
15
15
  middleware = lambda { |env|
16
16
  executed += 1
17
17
  raise 'my custom error message' if trigger_error
18
+ {"fact1" => 12}
18
19
  }
19
20
 
20
21
  # Proc.new is needed because Sinatra use lambda for lazy loading
@@ -33,7 +34,7 @@ RSpec.describe Inventory::Server::HTTPServer do
33
34
  it "should do the processing" do
34
35
  post '/api/v1/facts/MY_UUID', {"key" => "value"}
35
36
  expect(last_response).to be_ok
36
- expect(last_response.body).to eq('{"id":"MY_UUID","ok":true,"status":200}')
37
+ expect(last_response.body).to eq('{"id":"MY_UUID","fact1":12}')
37
38
  expect(executed).to eq 1
38
39
  end
39
40
 
@@ -42,7 +43,7 @@ RSpec.describe Inventory::Server::HTTPServer do
42
43
  post '/api/v1/facts/MY_UUID', {"key" => "value"}
43
44
  expect(last_response).to_not be_ok
44
45
  expect(last_response.status).to eq 500
45
- expect(last_response.body).to eq('{"id":"MY_UUID","ok":false,"status":500,"message":"my custom error message"}')
46
+ expect(last_response.body).to eq('{"id":"MY_UUID","message":"my custom error message"}')
46
47
  expect(executed).to eq 1
47
48
  end
48
49
 
@@ -51,7 +52,7 @@ RSpec.describe Inventory::Server::HTTPServer do
51
52
  post '/api/v1/facts/', {"key" => "value"}
52
53
  expect(last_response).to_not be_ok
53
54
  expect(last_response.status).to eq 404
54
- expect(last_response.body).to eq('{"id":null,"ok":false,"status":404,"message":"Sinatra::NotFound"}')
55
+ expect(last_response.body).to eq('{"id":null,"message":"Sinatra::NotFound"}')
55
56
  expect(executed).to eq 0
56
57
  end
57
58
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inventory-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Filirom1
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: midi-smtp-server