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 +4 -4
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/bin/compose-hook +5 -2
- data/bin/compose-payload +6 -6
- data/lib/compose_hook/webhook.rb +5 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d427520abbe59d4d4aa9b24270c7d54a2c5e286062c29710333f7ff55c32880b
|
4
|
+
data.tar.gz: 4300439a695628b7741d9b52fa3de99d4d48f766e5c6821415966763b71a6fdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a460dd5dd9a6c3d1e543c895089a2a994e7ea0256e5773d8578009996fee3c28f33471ee984d2d28d105107eab06408ebe14df7465d81e3f24f96997d64fba0
|
7
|
+
data.tar.gz: 56b536867cf8a10d78d0b89e7c9b42263e8de99842376e9281baa4e39fdd116b108e60d8c05599d540f5585b95ac8f41c9f8a71dfa0293c77865d817adbcff79
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.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
|
7
|
+
require "compose-hook"
|
8
8
|
|
9
|
-
|
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
|
8
|
-
require
|
7
|
+
require "faraday"
|
8
|
+
require "compose-hook"
|
9
9
|
|
10
|
-
abort
|
10
|
+
abort "Usage: payload *service* *image* *url*" unless ARGV.length == 3
|
11
11
|
|
12
|
-
secret = ENV[
|
13
|
-
abort
|
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
|
-
|
25
|
+
raise unless response.status == 200
|
data/lib/compose_hook/webhook.rb
CHANGED
@@ -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
|
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 {
|
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.
|
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-
|
13
|
+
date: 2020-02-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|