vidar 0.1.6 → 0.2.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 +4 -4
- data/.ruby-version +1 -0
- data/Gemfile.lock +6 -2
- data/lib/vidar.rb +2 -2
- data/lib/vidar/cli.rb +7 -9
- data/lib/vidar/config.rb +21 -1
- data/lib/vidar/interpolation.rb +1 -1
- data/lib/vidar/slack_notification.rb +23 -13
- data/lib/vidar/version.rb +1 -1
- data/vidar.gemspec +1 -0
- metadata +18 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1cd6a83c0201682b8366247dca55e395e3bdd7012c58c59555258e91a199300b
|
|
4
|
+
data.tar.gz: 52ba79dd94564548fae2690c21672ee6c4d56c7034692af2b247541b9e8e22ba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 86c304b21aaa052552ea618cf01aa5d8bf9790342912b6354f79e40053ca572520fca3104986919763e3c230874d318691b1d6e28d6e455eea690a99e49e6bf5
|
|
7
|
+
data.tar.gz: 7333853d537aacf960accd63f7c6e8b97f53a40dbca2a9ff0041677be743860a14eee1549bada27ddfe22c78787beeb4bdc442cb27573399e0e4b345e3c60297
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby-2.6.4
|
data/Gemfile.lock
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
vidar (0.
|
|
4
|
+
vidar (0.2.0)
|
|
5
5
|
colorize
|
|
6
|
+
faraday
|
|
6
7
|
thor (~> 0.20)
|
|
7
8
|
|
|
8
9
|
GEM
|
|
@@ -12,8 +13,11 @@ GEM
|
|
|
12
13
|
coderay (1.1.2)
|
|
13
14
|
colorize (0.8.1)
|
|
14
15
|
diff-lcs (1.3)
|
|
16
|
+
faraday (0.15.4)
|
|
17
|
+
multipart-post (>= 1.2, < 3)
|
|
15
18
|
jaro_winkler (1.5.3)
|
|
16
19
|
method_source (0.9.2)
|
|
20
|
+
multipart-post (2.1.1)
|
|
17
21
|
parallel (1.17.0)
|
|
18
22
|
parser (2.6.4.0)
|
|
19
23
|
ast (~> 2.4.0)
|
|
@@ -61,4 +65,4 @@ DEPENDENCIES
|
|
|
61
65
|
vidar!
|
|
62
66
|
|
|
63
67
|
BUNDLED WITH
|
|
64
|
-
2.0.
|
|
68
|
+
2.0.2
|
data/lib/vidar.rb
CHANGED
data/lib/vidar/cli.rb
CHANGED
|
@@ -19,7 +19,7 @@ module Vidar
|
|
|
19
19
|
Run.docker "pull #{Config.get!(:image)}:builder 2> /dev/null || true"
|
|
20
20
|
Run.docker "pull #{Config.get!(:image)}:release 2> /dev/null || true"
|
|
21
21
|
Log.info "Docker images:"
|
|
22
|
-
|
|
22
|
+
Log.info Run.docker("images")
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
desc "build", "Builds docker stages"
|
|
@@ -62,7 +62,7 @@ module Vidar
|
|
|
62
62
|
method_option :revision, default: nil
|
|
63
63
|
def deploy
|
|
64
64
|
revision = options[:revision] || Config.get!(:revision)
|
|
65
|
-
Log.info "Current
|
|
65
|
+
Log.info "Current cluster_name: #{Config.get!(:cluster_name)} ###"
|
|
66
66
|
|
|
67
67
|
Log.info "Set kubectl image..."
|
|
68
68
|
Run.kubectl "set image deployments,cronjobs *=#{Config.get!(:image)}:#{revision} --all"
|
|
@@ -95,8 +95,8 @@ module Vidar
|
|
|
95
95
|
|
|
96
96
|
desc "monitor_deploy_status", "Checks is deployment has finished and sends post-deploy notification"
|
|
97
97
|
def monitor_deploy_status
|
|
98
|
-
Log.info "Current
|
|
99
|
-
Log.info "Checking is all containers on #{Config.get!(:
|
|
98
|
+
Log.info "Current cluster_name: #{Config.get!(:cluster_name)} ###"
|
|
99
|
+
Log.info "Checking is all containers on #{Config.get!(:cluster_name)} in #{Config.get!(:namespace)} are ready..."
|
|
100
100
|
|
|
101
101
|
sleep(2)
|
|
102
102
|
error = false
|
|
@@ -111,24 +111,22 @@ module Vidar
|
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
-
return unless Config.get(:slack_webhook_url)
|
|
115
|
-
|
|
116
114
|
slack_notification = SlackNotification.new(
|
|
117
115
|
webhook_url: Config.get!(:slack_webhook_url),
|
|
118
116
|
github: Config.get!(:github),
|
|
119
117
|
revision: Config.get!(:revision),
|
|
120
118
|
revision_name: Config.get!(:revision_name),
|
|
121
|
-
|
|
119
|
+
cluster_name: Config.get!(:cluster_name),
|
|
122
120
|
cluster_url: Config.get!(:cluster_url)
|
|
123
121
|
)
|
|
124
122
|
|
|
125
123
|
if error
|
|
126
124
|
Log.error "ERROR: Some of containers are not ready."
|
|
127
|
-
slack_notification.error
|
|
125
|
+
slack_notification.error if slack_notification.configured?
|
|
128
126
|
exit(1)
|
|
129
127
|
else
|
|
130
128
|
Log.info "OK: All containers are ready."
|
|
131
|
-
slack_notification.success
|
|
129
|
+
slack_notification.success if slack_notification.configured?
|
|
132
130
|
end
|
|
133
131
|
end
|
|
134
132
|
end
|
data/lib/vidar/config.rb
CHANGED
|
@@ -8,7 +8,17 @@ module Vidar
|
|
|
8
8
|
current_branch: -> { `git rev-parse --abbrev-ref HEAD`.strip.tr("/", "-") },
|
|
9
9
|
revision: -> { `git rev-parse HEAD`.strip },
|
|
10
10
|
revision_name: -> { `git show --pretty=format:"%s (%h)" -s HEAD`.strip },
|
|
11
|
-
|
|
11
|
+
cluster_name: -> {
|
|
12
|
+
cluster_names = get(:cluster_names).to_s
|
|
13
|
+
current_context = `kubectl config current-context`.strip
|
|
14
|
+
|
|
15
|
+
if cluster_names.empty?
|
|
16
|
+
current_context
|
|
17
|
+
else
|
|
18
|
+
names_in_context = current_context.scan(Regexp.new(cluster_names))
|
|
19
|
+
names_in_context.flatten.first || current_context
|
|
20
|
+
end
|
|
21
|
+
}
|
|
12
22
|
}.freeze
|
|
13
23
|
|
|
14
24
|
class << self
|
|
@@ -28,6 +38,16 @@ module Vidar
|
|
|
28
38
|
@loaded
|
|
29
39
|
end
|
|
30
40
|
|
|
41
|
+
def cluster_name
|
|
42
|
+
cluster_names = get(:cluster_names).to_s
|
|
43
|
+
current_context = `kubectl config current-context`.strip
|
|
44
|
+
|
|
45
|
+
return current_context if cluster_names.empty?
|
|
46
|
+
|
|
47
|
+
names_in_context = current_context.scan(Regexp.new(cluster_names))
|
|
48
|
+
names_in_context.flatten.first || current_context
|
|
49
|
+
end
|
|
50
|
+
|
|
31
51
|
def get(key)
|
|
32
52
|
load unless loaded?
|
|
33
53
|
value = @data[key.to_s] || DEFAULT_OPTIONS[key.to_sym]&.call
|
data/lib/vidar/interpolation.rb
CHANGED
|
@@ -3,32 +3,42 @@ module Vidar
|
|
|
3
3
|
SUCCESS_COLOR = "good".freeze
|
|
4
4
|
ERROR_COLOR = "danger".freeze
|
|
5
5
|
|
|
6
|
-
def initialize(webhook_url:, github:, revision:, revision_name:,
|
|
7
|
-
@webhook_url
|
|
8
|
-
@github
|
|
9
|
-
@revision
|
|
6
|
+
def initialize(webhook_url:, github:, revision:, revision_name:, cluster_name:, cluster_url:)
|
|
7
|
+
@webhook_url = webhook_url
|
|
8
|
+
@github = github
|
|
9
|
+
@revision = revision
|
|
10
10
|
@revision_name = revision_name
|
|
11
|
-
@
|
|
12
|
-
@cluster_url
|
|
11
|
+
@cluster_name = cluster_name
|
|
12
|
+
@cluster_url = cluster_url
|
|
13
|
+
@connection = Faraday.new
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def configured?
|
|
17
|
+
!webhook_url.to_s.empty?
|
|
13
18
|
end
|
|
14
19
|
|
|
15
20
|
def error
|
|
16
21
|
message = "Failed deploy of #{github_link} to #{cluster_link} :fire: <!channel>"
|
|
17
|
-
|
|
22
|
+
perform_with data(message: message, color: ERROR_COLOR)
|
|
18
23
|
end
|
|
19
24
|
|
|
20
25
|
def success
|
|
21
26
|
message = "Successful deploy of #{github_link} to #{cluster_link}"
|
|
22
|
-
|
|
27
|
+
perform_with data(message: message, color: SUCCESS_COLOR)
|
|
23
28
|
end
|
|
24
29
|
|
|
25
|
-
def
|
|
26
|
-
|
|
30
|
+
def perform_with(data)
|
|
31
|
+
p data
|
|
32
|
+
connection.post do |req|
|
|
33
|
+
req.url webhook_url
|
|
34
|
+
req.headers['Content-Type'] = 'application/json'
|
|
35
|
+
req.body = data.to_json
|
|
36
|
+
end
|
|
27
37
|
end
|
|
28
38
|
|
|
29
39
|
private
|
|
30
40
|
|
|
31
|
-
attr_reader :webhook_url, :github, :revision, :revision_name, :
|
|
41
|
+
attr_reader :webhook_url, :github, :revision, :revision_name, :cluster_name, :cluster_url, :connection
|
|
32
42
|
|
|
33
43
|
def data(message:, color:)
|
|
34
44
|
{
|
|
@@ -41,7 +51,7 @@ module Vidar
|
|
|
41
51
|
"fallback": message
|
|
42
52
|
}
|
|
43
53
|
]
|
|
44
|
-
}
|
|
54
|
+
}
|
|
45
55
|
end
|
|
46
56
|
|
|
47
57
|
def github_url
|
|
@@ -53,7 +63,7 @@ module Vidar
|
|
|
53
63
|
end
|
|
54
64
|
|
|
55
65
|
def cluster_link
|
|
56
|
-
"<#{cluster_url}|#{
|
|
66
|
+
"<#{cluster_url}|#{cluster_name}>"
|
|
57
67
|
end
|
|
58
68
|
end
|
|
59
69
|
end
|
data/lib/vidar/version.rb
CHANGED
data/vidar.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vidar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Krzysztof Knapik
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2019-09-
|
|
12
|
+
date: 2019-09-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: colorize
|
|
@@ -25,6 +25,20 @@ dependencies:
|
|
|
25
25
|
- - ">="
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
27
|
version: '0'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: faraday
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '0'
|
|
35
|
+
type: :runtime
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '0'
|
|
28
42
|
- !ruby/object:Gem::Dependency
|
|
29
43
|
name: thor
|
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -135,6 +149,7 @@ files:
|
|
|
135
149
|
- ".gitignore"
|
|
136
150
|
- ".rspec"
|
|
137
151
|
- ".rubocop.yml"
|
|
152
|
+
- ".ruby-version"
|
|
138
153
|
- ".travis.yml"
|
|
139
154
|
- Gemfile
|
|
140
155
|
- Gemfile.lock
|
|
@@ -177,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
177
192
|
- !ruby/object:Gem::Version
|
|
178
193
|
version: '0'
|
|
179
194
|
requirements: []
|
|
180
|
-
rubygems_version: 3.0.
|
|
195
|
+
rubygems_version: 3.0.6
|
|
181
196
|
signing_key:
|
|
182
197
|
specification_version: 4
|
|
183
198
|
summary: K8s deployment tools based on thor
|