shipyrd 0.2.12 → 0.2.14
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 +4 -4
- data/lib/shipyrd/client.rb +15 -20
- data/lib/shipyrd/configuration.rb +59 -0
- data/lib/shipyrd/version.rb +1 -1
- data/lib/shipyrd.rb +14 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f51f6d4663e34e128254858cacb0c275bcf74e9f86b3b1d38bf4281cc75c327f
|
|
4
|
+
data.tar.gz: 4be800ad91fd2f15ee6b826eacf2dda9e31f3c3660fa86020e6de3903005b5c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b805ab9d7a8391f7a8884e79c199321b89bb42d7fc097601e5a683ba710e3d09d0ca387a977bbdfd250f1150c4d229e7dc823f6201ff882c48c3762ecb5c18e2
|
|
7
|
+
data.tar.gz: 2b6b6e8ad39023ed1c344f6f953312ccd767b66a31a5d9e738a286102426301c61fd9d4db05623a366720c0c6cb03fc139a915fa789387c380e40df140e73247
|
data/lib/shipyrd/client.rb
CHANGED
|
@@ -25,11 +25,11 @@ class Shipyrd::Client
|
|
|
25
25
|
SHIPYRD_SERVICE_VERSION
|
|
26
26
|
SHIPYRD_SUBCOMMAND
|
|
27
27
|
SHIPYRD_VERSION
|
|
28
|
-
]
|
|
28
|
+
].freeze
|
|
29
29
|
|
|
30
30
|
class DestinationBlocked < StandardError; end
|
|
31
31
|
|
|
32
|
-
def initialize(host:
|
|
32
|
+
def initialize(host: Shipyrd.configuration.host, api_key: Shipyrd.configuration.api_key, **options)
|
|
33
33
|
@host = parse_host(host)
|
|
34
34
|
@api_key = api_key
|
|
35
35
|
@logger = options[:logger] || Shipyrd::Logger.new
|
|
@@ -39,6 +39,7 @@ class Shipyrd::Client
|
|
|
39
39
|
def trigger(event)
|
|
40
40
|
return false unless valid_configuration
|
|
41
41
|
|
|
42
|
+
config = Shipyrd.configuration
|
|
42
43
|
uri = URI("#{host}/deploys.json")
|
|
43
44
|
headers = {
|
|
44
45
|
"Content-Type": "application/json",
|
|
@@ -48,17 +49,17 @@ class Shipyrd::Client
|
|
|
48
49
|
details = {
|
|
49
50
|
deploy: {
|
|
50
51
|
status: event,
|
|
51
|
-
recorded_at:
|
|
52
|
+
recorded_at: config.recorded_at,
|
|
52
53
|
performer: performer,
|
|
53
|
-
commit_message:
|
|
54
|
-
version:
|
|
55
|
-
service_version:
|
|
56
|
-
hosts:
|
|
57
|
-
command:
|
|
58
|
-
subcommand:
|
|
59
|
-
role:
|
|
60
|
-
destination:
|
|
61
|
-
runtime:
|
|
54
|
+
commit_message: config.commit_message || commit_message,
|
|
55
|
+
version: config.version,
|
|
56
|
+
service_version: config.service_version,
|
|
57
|
+
hosts: config.hosts,
|
|
58
|
+
command: config.command,
|
|
59
|
+
subcommand: config.subcommand,
|
|
60
|
+
role: config.role,
|
|
61
|
+
destination: config.destination,
|
|
62
|
+
runtime: config.runtime
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
|
|
@@ -96,7 +97,7 @@ class Shipyrd::Client
|
|
|
96
97
|
end
|
|
97
98
|
|
|
98
99
|
def performer
|
|
99
|
-
github_username.empty? ?
|
|
100
|
+
github_username.empty? ? Shipyrd.configuration.performer : "https://github.com/#{github_username}"
|
|
100
101
|
end
|
|
101
102
|
|
|
102
103
|
def github_username
|
|
@@ -106,7 +107,7 @@ class Shipyrd::Client
|
|
|
106
107
|
end
|
|
107
108
|
|
|
108
109
|
def commit_message
|
|
109
|
-
message = `git show -s --format=%s`.chomp
|
|
110
|
+
message = `git show -s --format=%s --no-show-signature`.chomp
|
|
110
111
|
|
|
111
112
|
if message.length >= 90
|
|
112
113
|
"#{message[0..90]}..."
|
|
@@ -137,10 +138,4 @@ class Shipyrd::Client
|
|
|
137
138
|
|
|
138
139
|
"https://#{host}"
|
|
139
140
|
end
|
|
140
|
-
|
|
141
|
-
private
|
|
142
|
-
|
|
143
|
-
def env_var(name)
|
|
144
|
-
ENV["SHIPYRD_#{name}"] || ENV["KAMAL_#{name}"]
|
|
145
|
-
end
|
|
146
141
|
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Shipyrd::Configuration
|
|
4
|
+
attr_writer :host, :api_key, :commit_message,
|
|
5
|
+
:recorded_at, :performer, :version, :service_version,
|
|
6
|
+
:hosts, :command, :subcommand, :role, :destination, :runtime
|
|
7
|
+
|
|
8
|
+
def host
|
|
9
|
+
@host || ENV["SHIPYRD_HOST"]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def api_key
|
|
13
|
+
@api_key || ENV["SHIPYRD_API_KEY"]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def commit_message
|
|
17
|
+
@commit_message || ENV["SHIPYRD_COMMIT_MESSAGE"]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def recorded_at
|
|
21
|
+
@recorded_at || ENV["SHIPYRD_RECORDED_AT"] || ENV["KAMAL_RECORDED_AT"]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def performer
|
|
25
|
+
@performer || ENV["SHIPYRD_PERFORMER"] || ENV["KAMAL_PERFORMER"]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def version
|
|
29
|
+
@version || ENV["SHIPYRD_VERSION"] || ENV["KAMAL_VERSION"]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def service_version
|
|
33
|
+
@service_version || ENV["SHIPYRD_SERVICE_VERSION"] || ENV["KAMAL_SERVICE_VERSION"]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def hosts
|
|
37
|
+
@hosts || ENV["SHIPYRD_HOSTS"] || ENV["KAMAL_HOSTS"]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def command
|
|
41
|
+
@command || ENV["SHIPYRD_COMMAND"] || ENV["KAMAL_COMMAND"]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def subcommand
|
|
45
|
+
@subcommand || ENV["SHIPYRD_SUBCOMMAND"] || ENV["KAMAL_SUBCOMMAND"]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def role
|
|
49
|
+
@role || ENV["SHIPYRD_ROLE"] || ENV["KAMAL_ROLE"]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def destination
|
|
53
|
+
@destination || ENV["SHIPYRD_DESTINATION"] || ENV["KAMAL_DESTINATION"]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def runtime
|
|
57
|
+
@runtime || ENV["SHIPYRD_RUNTIME"] || ENV["KAMAL_RUNTIME"]
|
|
58
|
+
end
|
|
59
|
+
end
|
data/lib/shipyrd/version.rb
CHANGED
data/lib/shipyrd.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "shipyrd/version"
|
|
4
|
+
require_relative "shipyrd/configuration"
|
|
4
5
|
require "uri"
|
|
5
6
|
require "net/http"
|
|
6
7
|
require "json"
|
|
@@ -9,4 +10,17 @@ require "shipyrd/client"
|
|
|
9
10
|
require "shipyrd/logger"
|
|
10
11
|
|
|
11
12
|
module Shipyrd
|
|
13
|
+
class << self
|
|
14
|
+
def configure
|
|
15
|
+
yield(configuration)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def configuration
|
|
19
|
+
@configuration ||= Shipyrd::Configuration.new
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def reset_configuration!
|
|
23
|
+
@configuration = nil
|
|
24
|
+
end
|
|
25
|
+
end
|
|
12
26
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shipyrd
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Hammond
|
|
@@ -25,6 +25,7 @@ files:
|
|
|
25
25
|
- Rakefile
|
|
26
26
|
- lib/shipyrd.rb
|
|
27
27
|
- lib/shipyrd/client.rb
|
|
28
|
+
- lib/shipyrd/configuration.rb
|
|
28
29
|
- lib/shipyrd/logger.rb
|
|
29
30
|
- lib/shipyrd/version.rb
|
|
30
31
|
- shipyrd.gemspec
|