compose-hook 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3491bcf7a0049e4ff7bfa1ba0db224ed10f40050c3bede86d09b770fad954da
4
- data.tar.gz: fc05d1cc28ac4cacb2d1df76587fc915fa4074bc2798153f81628fc9e8e78d53
3
+ metadata.gz: d427520abbe59d4d4aa9b24270c7d54a2c5e286062c29710333f7ff55c32880b
4
+ data.tar.gz: 4300439a695628b7741d9b52fa3de99d4d48f766e5c6821415966763b71a6fdf
5
5
  SHA512:
6
- metadata.gz: 0bd14948077b984c891ffe561a640902b0d05cebc671edeb841cd5d78b02043deeeb03da02fd019c3dfae6357784c44780f0701e26d55d92e90896d7fc8e8fcd
7
- data.tar.gz: f81395406a042fbe05dd04d8c80a8a5b98d2ab7cbff321bece6968d2a4820f37494ebea4c2fabb70da287c3e80ccb924359f7e6f5c4722ced8bbe4060b1330ff
6
+ metadata.gz: 6a460dd5dd9a6c3d1e543c895089a2a994e7ea0256e5773d8578009996fee3c28f33471ee984d2d28d105107eab06408ebe14df7465d81e3f24f96997d64fba0
7
+ data.tar.gz: 56b536867cf8a10d78d0b89e7c9b42263e8de99842376e9281baa4e39fdd116b108e60d8c05599d540f5585b95ac8f41c9f8a71dfa0293c77865d817adbcff79
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- compose-hook (0.1.1)
4
+ compose-hook (0.1.2)
5
5
  faraday
6
6
  jwt (~> 2.2)
7
7
  puma
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/bin/compose-hook CHANGED
@@ -4,6 +4,9 @@
4
4
 
5
5
  $LOAD_PATH << File.join(File.dirname(__FILE__), "../lib")
6
6
 
7
- require 'compose-hook'
7
+ require "compose-hook"
8
8
 
9
- run ComposeHook::WebHook.run!
9
+ port = ENV["COMPOSE_HOOK_PORT"] || 1337
10
+ host = ENV["COMPOSE_HOOK_HOST"] || "0.0.0.0"
11
+
12
+ run ComposeHook::WebHook.run!(port: port, bind: host)
data/bin/compose-payload CHANGED
@@ -4,13 +4,13 @@
4
4
 
5
5
  $LOAD_PATH << File.join(File.dirname(__FILE__), "../lib")
6
6
 
7
- require 'faraday'
8
- require 'compose-hook'
7
+ require "faraday"
8
+ require "compose-hook"
9
9
 
10
- abort 'Usage: payload *service* *image* *url*' unless ARGV.length == 3
10
+ abort "Usage: payload *service* *image* *url*" unless ARGV.length == 3
11
11
 
12
- secret = ENV['WEBHOOK_JWT_SECRET']
13
- abort 'WEBHOOK_JWT_SECRET not set' if secret.to_s.empty?
12
+ secret = ENV["WEBHOOK_JWT_SECRET"]
13
+ abort "WEBHOOK_JWT_SECRET not set" if secret.to_s.empty?
14
14
  coder = ComposeHook::Payload.new(secret: secret)
15
15
 
16
16
  jwt = coder.generate!(service: ARGV[0], image: ARGV[1])
@@ -22,4 +22,4 @@ end
22
22
 
23
23
  pp response.body
24
24
 
25
- fail unless response.status == 200
25
+ raise unless response.status == 200
@@ -6,16 +6,15 @@ class ComposeHook::WebHook < Sinatra::Base
6
6
 
7
7
  attr_accessor :config, :secret, :decoder
8
8
 
9
- CONFIG_PATH = "compose/docker-compose.yml"
10
- STAGES_PATH = "/home/deploy/webhook/stages.yml"
11
-
12
9
  set :show_exceptions, false
13
10
 
14
- def initialize
11
+ def initialize(app=nil)
15
12
  super
16
13
 
17
14
  @secret = ENV["WEBHOOK_JWT_SECRET"]
18
- raise "WEBHOOK_JWT_SECRET is not set" if @secret.to_s.empty?
15
+ raise "WEBHOOK_JWT_SECRET is not set" if secret.to_s.empty?
16
+ raise "CONFIG_PATH is not set" if ENV["CONFIG_PATH"].to_s.empty?
17
+ raise "File #{ENV['CONFIG_PATH']} not found" unless File.exist?(ENV["CONFIG_PATH"])
19
18
 
20
19
  @config = YAML.load_file(ENV["CONFIG_PATH"])
21
20
  raise "The config file is empty or non-existent" if @config.empty?
@@ -60,7 +59,7 @@ class ComposeHook::WebHook < Sinatra::Base
60
59
  service = decoded["service"]
61
60
  image = decoded["image"]
62
61
  hostname = request.host
63
- deployment = config.find { |d| d["domain"] == hostname }
62
+ deployment = config.find {|d| d["domain"] == hostname }
64
63
  service_file = find_service(service, File.join(deployment["path"], deployment["subpath"]))
65
64
 
66
65
  return answer(400, "service is not specified") unless service
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compose-hook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danylo P.
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-02-20 00:00:00.000000000 Z
13
+ date: 2020-02-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday