kubernetes-deploy 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/kubernetes-deploy +13 -3
- data/lib/kubernetes-deploy/runner.rb +9 -8
- data/lib/kubernetes-deploy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2098811abec5fdb6147e4a50ac43ed38f8c6595
|
4
|
+
data.tar.gz: a4cccb2a49f08a40ec5a5f09124c2e87400e8f16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0764c379377b2ea2487eb927259e26c29019a13a19c270b770178b27b48d2933de5be049a92e9a490d555c4aec16e4265b8d0ee249fc6bd159a79254f54af5f7
|
7
|
+
data.tar.gz: 98610e19e49b68a0bce88e79c14472bc40f72bf3e7220baedb9853bf3935ff63e9f806d3c1f20b37d2f9d44694e67836ac634ce924fd1387a92c7e3e252dccb4
|
data/exe/kubernetes-deploy
CHANGED
@@ -15,18 +15,28 @@ require 'kubernetes-deploy'
|
|
15
15
|
require 'optparse'
|
16
16
|
|
17
17
|
skip_wait = false
|
18
|
+
template_dir = nil
|
18
19
|
ARGV.options do |opts|
|
19
|
-
opts.on("
|
20
|
+
opts.on("--skip-wait") { skip_wait = true }
|
21
|
+
opts.on("--template-dir=DIR") { |v| template_dir = v }
|
20
22
|
opts.parse!
|
21
23
|
end
|
22
24
|
|
25
|
+
if !template_dir && ENV.key?("ENVIRONMENT")
|
26
|
+
template_dir = "config/deploy/#{ENV["ENVIRONMENT"]}"
|
27
|
+
end
|
28
|
+
|
29
|
+
if !template_dir || template_dir.empty?
|
30
|
+
puts "Template directory is unknown. Either specify --template-dir argument or set $ENVIRONMENT to use config/deploy/$ENVIRONMENT as a default path."
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
|
23
34
|
KubernetesDeploy::Runner.with_friendly_errors do
|
24
35
|
runner = KubernetesDeploy::Runner.new(
|
25
36
|
namespace: ARGV[0],
|
26
37
|
context: ARGV[1],
|
27
|
-
environment: ENV['ENVIRONMENT'],
|
28
38
|
current_sha: ENV['REVISION'],
|
29
|
-
|
39
|
+
template_dir: template_dir,
|
30
40
|
wait_for_completion: !skip_wait,
|
31
41
|
)
|
32
42
|
runner.run
|
@@ -55,11 +55,12 @@ MSG
|
|
55
55
|
exit 1
|
56
56
|
end
|
57
57
|
|
58
|
-
def initialize(namespace:,
|
58
|
+
def initialize(namespace:, current_sha:, context:, wait_for_completion:, template_dir:)
|
59
59
|
@namespace = namespace
|
60
60
|
@context = context
|
61
61
|
@current_sha = current_sha
|
62
|
-
|
62
|
+
|
63
|
+
@template_dir = File.expand_path(template_dir)
|
63
64
|
# Max length of podname is only 63chars so try to save some room by truncating sha to 8 chars
|
64
65
|
@id = current_sha[0...8] + "-#{SecureRandom.hex(4)}" if current_sha
|
65
66
|
@wait_for_completion = wait_for_completion
|
@@ -119,7 +120,7 @@ MSG
|
|
119
120
|
|
120
121
|
def discover_resources
|
121
122
|
resources = []
|
122
|
-
Dir.foreach(@
|
123
|
+
Dir.foreach(@template_dir) do |filename|
|
123
124
|
next unless filename.end_with?(".yml.erb", ".yml")
|
124
125
|
|
125
126
|
split_templates(filename) do |tempfile|
|
@@ -139,7 +140,7 @@ MSG
|
|
139
140
|
end
|
140
141
|
|
141
142
|
def split_templates(filename)
|
142
|
-
file_content = File.read(File.join(@
|
143
|
+
file_content = File.read(File.join(@template_dir, filename))
|
143
144
|
rendered_content = render_template(filename, file_content)
|
144
145
|
YAML.load_stream(rendered_content) do |doc|
|
145
146
|
f = Tempfile.new(filename)
|
@@ -201,10 +202,10 @@ MSG
|
|
201
202
|
errors << "Current SHA must be specified"
|
202
203
|
end
|
203
204
|
|
204
|
-
if !File.directory?(@
|
205
|
-
errors << "Template
|
206
|
-
elsif Dir.entries(@
|
207
|
-
errors << "
|
205
|
+
if !File.directory?(@template_dir)
|
206
|
+
errors << "Template directory `#{@template_dir}` doesn't exist"
|
207
|
+
elsif Dir.entries(@template_dir).none? { |file| file =~ /\.yml(\.erb)?$/ }
|
208
|
+
errors << "`#{@template_dir}` doesn't contain valid templates (postfix .yml or .yml.erb)"
|
208
209
|
end
|
209
210
|
|
210
211
|
if @namespace.blank?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubernetes-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kir Shatrov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-01-
|
13
|
+
date: 2017-01-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|