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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe05ac43ce5668b78154fd7cc4e5c62d44513de0
4
- data.tar.gz: 67cf8f77d37ec6b3c9ba1cbf73bc4c7185e4e7a0
3
+ metadata.gz: f2098811abec5fdb6147e4a50ac43ed38f8c6595
4
+ data.tar.gz: a4cccb2a49f08a40ec5a5f09124c2e87400e8f16
5
5
  SHA512:
6
- metadata.gz: 9a9503f71c75a1640c46e42ef007ca942218553c68a05718c4892e162daaf7b18eb5a05b216337a2cdaced51a1ecdcad20a5845820348af58576cbb8375e630e
7
- data.tar.gz: 70d15573a44990b7b2e819569165f553a120f90bf7f57277118e7df63f678646a2c7afa77b92043597eb20f823b546a47e1ea5060a99259a7fdf75f4486a1aae
6
+ metadata.gz: 0764c379377b2ea2487eb927259e26c29019a13a19c270b770178b27b48d2933de5be049a92e9a490d555c4aec16e4265b8d0ee249fc6bd159a79254f54af5f7
7
+ data.tar.gz: 98610e19e49b68a0bce88e79c14472bc40f72bf3e7220baedb9853bf3935ff63e9f806d3c1f20b37d2f9d44694e67836ac634ce924fd1387a92c7e3e252dccb4
@@ -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("-w", "--skip-wait") { skip_wait = true }
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
- template_folder: ENV['K8S_TEMPLATE_FOLDER'],
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:, environment:, current_sha:, context:, wait_for_completion:, template_folder: nil)
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
- @template_path = File.expand_path('./' + (template_folder || "config/deploy/#{environment}"))
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(@template_path) do |filename|
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(@template_path, filename))
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?(@template_path)
205
- errors << "Template path #{@template_path} doesn't exist"
206
- elsif Dir.entries(@template_path).none? { |file| file =~ /\.yml(\.erb)?$/ }
207
- errors << "#{@template_path} doesn't contain valid templates (postfix .yml or .yml.erb)"
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?
@@ -1,3 +1,3 @@
1
1
  module KubernetesDeploy
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.2
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-27 00:00:00.000000000 Z
13
+ date: 2017-01-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport