dapp 0.14.6 → 0.14.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ee0f2f7ee5e578d580869bfc319b4af1ae4b16f
4
- data.tar.gz: cb5c44af2606334738cbe16fc3d2eb7554c72729
3
+ metadata.gz: c3e4aaab14d65724ea60299ceadd6e9b7c7af8ef
4
+ data.tar.gz: 09ddd9cf4d499ad1afe387d935e7338371f7f6f1
5
5
  SHA512:
6
- metadata.gz: e0a945624dfd7e3eeec6cad93d278043d87856d19a425f2320924a767ac1d3bbc4c682b1272fde7f0ff3ef3d6aa3ead8c59c1f64ced73e8d3850deb19c9f390a
7
- data.tar.gz: 49fd0b79fb89443b69d84fff5c9e57cf0cbb9a0d67fc67e9b4cd766ebae45756a0b68983234302b53e54c5bb5618a9bcd1bf0dde3467e8d9fa2577f29c6a20b9
6
+ metadata.gz: bc13b2da565927801e877745305c7f8b8ce24c3fbe7b8ecd5a116a33dcfe9f74c68bab163597f9822017b6398938d81275ab31ed30da3c75bb795624ff408e13
7
+ data.tar.gz: 8a7dce36cf64f25f11cc4f57a6edf0c7aee1e061c56f77f4fdfb8af00764e388487b5a98ff85c2b5f8556eb1f71edaf045f8b2fc886313730b0c5be8db3cc19e
@@ -38,7 +38,8 @@ en:
38
38
  file_not_exist: "File `%{path}` doesn't exist!"
39
39
  helm_directory_not_exist: "Helm directory doesn't exist in project!"
40
40
  values_file_not_found: "Values file `%{path}` not found!"
41
- secret_values_file_not_found: "Secret values file `%{path}` not found!"
41
+ secret_file_not_found: "Secret file `%{path}` not found!"
42
+ secret_file_empty: "Secret file `%{path}` can't be empty!"
42
43
  user_containers_detected: "User containers have been using images!\n%{ids}"
43
44
  incorrect_yaml_structure: "Incorrect YAML structure in `%{path}`!"
44
45
  editor_not_found: "Editor not found!"
@@ -8,35 +8,32 @@ module Dapp
8
8
  end
9
9
 
10
10
  def kube_release_name
11
- "#{name}-#{kube_namespace}"
11
+ "#{name}-#{kube_namespace}".slugify
12
12
  end
13
13
 
14
14
  def kube_namespace
15
15
  kubernetes.namespace
16
16
  end
17
17
 
18
- def kube_helm_encode_json(secret, json)
19
- encode_json = proc do |value|
20
- case value
21
- when Array then value.map { |v| encode_json.call(v) }
22
- when Hash then kube_helm_encode_json(secret,value)
23
- else
24
- secret.nil? ? '' : secret.generate(value)
18
+ { encode: :generate, decode: :extract }.each do |type, secret_method|
19
+ define_method "kube_helm_#{type}_json" do |secret, json|
20
+ change_json_value = proc do |value|
21
+ case value
22
+ when Array then value.map { |v| change_json_value.call(v) }
23
+ when Hash then send(:"kube_helm_#{type}_json", secret, value)
24
+ when '' then ''
25
+ else
26
+ secret.nil? ? '' : secret.public_send(secret_method, value)
27
+ end
28
+
29
+ json.each { |k, v| json[k] = change_json_value.call(v) }
25
30
  end
26
31
  end
27
- json.each { |k, v| json[k] = encode_json.call(v) }
28
32
  end
29
33
 
30
- def kube_helm_decode_json(secret, json)
31
- decode_value = proc do |value|
32
- case value
33
- when Array then value.map { |v| decode_value.call(v) }
34
- when Hash then kube_helm_decode_json(secret,value)
35
- else
36
- secret.nil? ? '' : secret.extract(value)
37
- end
38
- end
39
- json.each { |k, v| json[k] = decode_value.call(v) }
34
+ def kube_secret_file_validate!(file_path)
35
+ raise Error::Command, code: :secret_file_not_found, data: { path: File.expand_path(file_path) } unless File.exist?(file_path)
36
+ raise Error::Command, code: :secret_file_empty, data: { path: File.expand_path(file_path) } if File.read(file_path).strip.empty?
40
37
  end
41
38
 
42
39
  def secret_key_should_exist!
@@ -63,7 +63,8 @@ module Dapp
63
63
  def kube_helm_decode_secret_files
64
64
  return unless kube_chart_secret_path.directory?
65
65
  Dir.glob(kube_chart_secret_path.join('**/*')).each do |entry|
66
- next unless File.file?(entry)
66
+ next if File.directory?(entry)
67
+ kube_secret_file_validate!(entry)
67
68
  secret_relative_path = Pathname(entry).subpath_of(kube_chart_secret_path)
68
69
  secret_data = secret.extract(IO.binread(entry).chomp("\n"))
69
70
  File.open(kube_tmp_chart_secret_path(secret_relative_path), 'wb:ASCII-8BIT', 0400) {|f| f.write secret_data}
@@ -189,7 +190,7 @@ module Dapp
189
190
  @kube_chart_secret_values_files ||= [].tap do |files|
190
191
  files << kube_chart_secret_values_path if kube_chart_secret_values_path.file?
191
192
  files.concat(options[:helm_secret_values_options].map { |p| Pathname(p).expand_path }.each do |f|
192
- raise Error::Command, code: :secret_values_file_not_found, data: { path: f } unless f.file?
193
+ kube_secret_file_validate!(f)
193
194
  end)
194
195
  end
195
196
  end
@@ -8,7 +8,7 @@ module Dapp
8
8
 
9
9
  with_kube_tmp_chart_dir do
10
10
  decoded_data = begin
11
- raise Error::Command, code: :file_not_exist, data: { path: File.expand_path(file_path) } unless File.exist?(file_path)
11
+ kube_secret_file_validate!(file_path)
12
12
 
13
13
  if options[:values]
14
14
  kube_extract_secret_values(file_path)
@@ -8,7 +8,7 @@ module Dapp
8
8
 
9
9
  data = begin
10
10
  if file_path
11
- raise Error::Command, code: :file_not_exist, data: { path: File.expand_path(file_path) } unless File.exist?(file_path)
11
+ kube_secret_file_validate!(file_path)
12
12
 
13
13
  if options[:values]
14
14
  kube_extract_secret_values(file_path)
@@ -8,7 +8,7 @@ module Dapp
8
8
 
9
9
  data = begin
10
10
  if file_path
11
- raise Error::Command, code: :file_not_exist, data: { path: File.expand_path(file_path) } unless File.exist?(file_path)
11
+ kube_secret_file_validate!(file_path)
12
12
 
13
13
  if options[:values]
14
14
  kube_secret_values(file_path)
@@ -8,12 +8,13 @@ module Dapp
8
8
 
9
9
  secret_values_paths << kube_chart_path('secret-values.yaml') if kube_chart_path('secret-values.yaml').file?
10
10
  secret_values_paths.each do |file_path|
11
- raise Error::Command, code: :file_not_exist, data: { path: File.expand_path(file_path) } unless File.exist?(file_path)
11
+ kube_secret_file_validate!(file_path)
12
12
  regenerated_data[file_path] = kube_regenerate_secret_values(file_path)
13
13
  end
14
14
 
15
15
  Dir.glob(kube_chart_secret_path('**/*'), File::FNM_DOTMATCH).each do |file_path|
16
16
  next if File.directory?(file_path)
17
+ kube_secret_file_validate!(file_path)
17
18
  regenerated_data[file_path] = kube_regenerate_secret_file(file_path)
18
19
  end
19
20
 
@@ -1,4 +1,4 @@
1
1
  module Dapp
2
- VERSION = '0.14.6'.freeze
2
+ VERSION = '0.14.7'.freeze
3
3
  BUILD_CACHE_VERSION = 16
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.6
4
+ version: 0.14.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Stolyarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-28 00:00:00.000000000 Z
11
+ date: 2017-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -166,6 +166,26 @@ dependencies:
166
166
  - - "~>"
167
167
  - !ruby/object:Gem::Version
168
168
  version: 0.1.6
169
+ - !ruby/object:Gem::Dependency
170
+ name: slugify
171
+ requirement: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - "~>"
174
+ - !ruby/object:Gem::Version
175
+ version: '1.0'
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: 1.0.6
179
+ type: :runtime
180
+ prerelease: false
181
+ version_requirements: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - "~>"
184
+ - !ruby/object:Gem::Version
185
+ version: '1.0'
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: 1.0.6
169
189
  - !ruby/object:Gem::Dependency
170
190
  name: bundler
171
191
  requirement: !ruby/object:Gem::Requirement
@@ -686,7 +706,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
686
706
  version: 2.5.0
687
707
  requirements: []
688
708
  rubyforge_project:
689
- rubygems_version: 2.6.11
709
+ rubygems_version: 2.6.13
690
710
  signing_key:
691
711
  specification_version: 4
692
712
  summary: Build docker packaged apps using chef or shell