dapp 0.17.4 → 0.18.0

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
- SHA1:
3
- metadata.gz: 383aa5782985c5ec53607b5c9d802cb1213cdbc4
4
- data.tar.gz: a5c8847516cb0359fb82c17731ddd56244860214
2
+ SHA256:
3
+ metadata.gz: d6f675f931b5b79d8637e493f875973f718547a6f77978bd1d8b3e5bc6c606c3
4
+ data.tar.gz: fe73c28ca5d6962a19deb01778b420f23c5169bcf5fd1aa31a2e65c460c49bfc
5
5
  SHA512:
6
- metadata.gz: 065aa5ccf4a7cd01db71db4a05364db97cc3177fc3781920a95d000c963c3286bffd193e5ee45e91e3b0ed6e52ab682b32c812d7fd9d6e53a07fbba08a4253f5
7
- data.tar.gz: a30bf5b6583baa077adf31c316b3796bf0688aa5d722eadea1a4bcf580208087d7dce1cc9507ca1ff783a1c4f56813408e040e5d6d1108250f926cb539f52280
6
+ metadata.gz: 2589954a540ca69262a3af36ae7e7532e7830a5b59feafd2dce0b32b66798eef968aad7518610556815fe26654fb332dce94c424865b39461e297d25a82da77e
7
+ data.tar.gz: 218644c687bc41cb81977a08ffdf6ebbdc64411e9d4b34bfeb4766f2378eafbb7ffec58a71b19d9e759bbd3c7eea230a0fe5c82d694ae5d601ead60627d9b093
data/bin/dapp CHANGED
@@ -2,71 +2,42 @@
2
2
  # -*- mode: ruby -*-
3
3
  # vi: set ft=ruby :
4
4
 
5
- def with_dapp_running_lock(&blk)
6
- return yield
7
-
8
- file = nil
9
-
10
- begin
11
- file = ::File.open("/tmp/dapp-running.lock", ::File::RDWR | ::File::CREAT, 0777)
12
-
13
- if ARGV[0] == 'update'
14
- unless file.flock(::File::LOCK_EX | ::File::LOCK_NB)
15
- puts "There are other active dapp processes, exiting without update"
16
- exit(0)
17
- end
18
- else
19
- file.flock(::File::LOCK_SH)
20
- end
21
-
22
- yield
23
- ensure
24
- file.close if file
25
- end
26
- end
27
-
28
- with_dapp_running_lock do
29
- require 'rubygems'
30
- require 'dapp'
5
+ require 'rubygems'
6
+ require 'dapp'
31
7
 
8
+ begin
32
9
  begin
33
10
  begin
34
- begin
35
- Dapp::CLI.new.run
36
- rescue Dapp::Error::Base => e
37
- unless (message = Dapp::Helper::NetStatus.before_error_message(e)).empty?
38
- $stderr.puts(message)
39
- end
40
-
41
- raise
42
- end
43
- rescue ::SystemExit
44
- raise
45
- rescue ::Exception => e
46
- "/tmp/dapp-stacktrace-#{SecureRandom.uuid}.out".tap do |filename|
47
- ::File.open(filename, 'w') do |dapp_stacktrace|
48
- dapp_stacktrace.write "#{e.backtrace.join("\n")}\n"
49
- end
50
- $stderr.puts "\033[1m\033[90mStacktrace dumped to #{filename}\033[0m"
51
- end
52
-
53
- if Dapp::CLI.dapp_object
54
- Dapp::CLI.dapp_object.sentry_exception(e)
11
+ Dapp::CLI.new.run
12
+ rescue Dapp::Error::Base => e
13
+ unless (message = Dapp::Helper::NetStatus.before_error_message(e)).empty?
14
+ $stderr.puts(message)
55
15
  end
56
16
 
57
17
  raise
58
18
  end
59
- rescue Dapp::Error::Shellout => e
60
- $stderr.puts(Dapp::Helper::NetStatus.message(e))
61
- exit 1
62
- rescue Dapp::Error::Base, NetStatus::Exception => e
63
- $stderr.puts(Dapp::Dapp.paint_string(Dapp::Helper::NetStatus.message(e), :warning))
64
- exit 1
65
- rescue Interrupt => _e
66
- $stderr.puts(Dapp::Dapp.paint_string('Interrupted', :warning))
67
- exit 1
68
- rescue Errno::EACCES => _e
69
- $stderr.puts(Dapp::Dapp.paint_string('Permission denied!', :warning))
70
- exit 1
19
+ rescue ::SystemExit
20
+ raise
21
+ rescue ::Exception => e
22
+ "/tmp/dapp-stacktrace-#{SecureRandom.uuid}.out".tap do |filename|
23
+ ::File.open(filename, 'w') do |dapp_stacktrace|
24
+ dapp_stacktrace.write "#{e.backtrace.join("\n")}\n"
25
+ end
26
+ $stderr.puts "\033[1m\033[90mStacktrace dumped to #{filename}\033[0m"
27
+ end
28
+
29
+ raise
71
30
  end
31
+ rescue Dapp::Error::Shellout => e
32
+ $stderr.puts(Dapp::Helper::NetStatus.message(e))
33
+ exit 1
34
+ rescue Dapp::Error::Base, NetStatus::Exception => e
35
+ $stderr.puts(Dapp::Dapp.paint_string(Dapp::Helper::NetStatus.message(e), :warning))
36
+ exit 1
37
+ rescue Interrupt => _e
38
+ $stderr.puts(Dapp::Dapp.paint_string('Interrupted', :warning))
39
+ exit 1
40
+ rescue Errno::EACCES => _e
41
+ $stderr.puts(Dapp::Dapp.paint_string('Permission denied!', :warning))
42
+ exit 1
72
43
  end
@@ -50,7 +50,7 @@ en:
50
50
  cannot_run_ssh_agent: "Cannot run ssh-agent"
51
51
  ssh_key_not_found: "Ssh key `%{path}` not exist!"
52
52
  docker_not_found: "Docker not found!"
53
- docker_version: "Required docker version: >= %{version}!"
53
+ docker_version: "Required docker version (`%{version}`): `%{min_version}` <= VERSION <= `%{max_version}`!"
54
54
  dapp_config_file_incorrect: "%{message}"
55
55
  yaml_file_incorrect: "Yaml file `%{file}`: `%{message}`"
56
56
  yaml_incorrect: "`%{message}`"
@@ -24,8 +24,6 @@ require 'openssl'
24
24
  require 'etc'
25
25
  require 'zlib'
26
26
  require 'slugify'
27
- require 'sentry-raven'
28
- require 'toml-rb'
29
27
 
30
28
  require 'dapp/version'
31
29
  require 'dapp/core_ext/hash'
@@ -36,7 +34,6 @@ require 'dapp/helper/sha256'
36
34
  require 'dapp/helper/net_status'
37
35
  require 'dapp/helper/tar'
38
36
  require 'dapp/helper/yaml'
39
- require 'dapp/helper/url'
40
37
  require 'dapp/prctl'
41
38
  require 'dapp/error/base'
42
39
  require 'dapp/error/dapp'
@@ -52,7 +49,6 @@ require 'dapp/config/config'
52
49
  require 'dapp/config/error/config'
53
50
  require 'dapp/dapp/lock'
54
51
  require 'dapp/dapp/ssh_agent'
55
- require 'dapp/dapp/sentry'
56
52
  require 'dapp/dapp/git_artifact'
57
53
  require 'dapp/dapp/dappfile'
58
54
  require 'dapp/dapp/chef'
@@ -37,10 +37,6 @@ BANNER
37
37
  show_options: true,
38
38
  exit: 0
39
39
 
40
- class << self
41
- attr_accessor :dapp_object
42
- end
43
-
44
40
  def initialize(*args)
45
41
  super(*args)
46
42
 
@@ -58,9 +58,6 @@ module Dapp
58
58
 
59
59
  def run_dapp_command(run_method, *args)
60
60
  dapp = ::Dapp::Dapp.new(*args)
61
- ::Dapp::CLI.dapp_object = dapp
62
- dapp.sentry_message("Manual usage: `#{self.run_method}` command") unless ENV['CI']
63
-
64
61
  begin
65
62
  if block_given?
66
63
  yield dapp
@@ -70,16 +67,12 @@ module Dapp
70
67
  end
71
68
  end
72
69
 
73
- def run_method
74
- class_to_lowercase
75
- end
76
-
77
70
  def run(_argv = ARGV)
78
71
  raise
79
72
  end
80
73
 
81
74
  def cli_options(**kwargs)
82
- config.merge(dapp_command: run_method, **kwargs)
75
+ config.merge(**kwargs)
83
76
  end
84
77
  end
85
78
  end
@@ -6,14 +6,48 @@ module Dapp
6
6
  spec = Gem::Specification.find do |s|
7
7
  File.fnmatch(File.join(s.full_gem_path, '*'), __FILE__)
8
8
  end
9
- Gem.install(spec.name, approximate_recommendation(spec.version))
9
+ unless (latest_version = latest_beta_version(spec)).nil?
10
+ try_lock do
11
+ Gem.install(spec.name, latest_version)
12
+ end
13
+ end
10
14
  rescue Gem::FilePermissionError => e
11
15
  raise Errno::EACCES, e.message
12
16
  end
13
17
 
14
- # get latest beta-version
15
- def approximate_recommendation(version)
16
- [version.approximate_recommendation, 0].join('.')
18
+ def latest_beta_version(current_spec)
19
+ minor_version = current_spec.version.approximate_recommendation
20
+ url = "https://rubygems.org/api/v1/versions/#{current_spec.name}.json"
21
+ response = Excon.get(url)
22
+ if response.status == 200
23
+ JSON.parse(response.body)
24
+ .reduce([]) { |versions, spec| versions << Gem::Version.new(spec['number']) }
25
+ .reject { |spec_version| minor_version != spec_version.approximate_recommendation || current_spec.version >= spec_version }
26
+ .first
27
+ else
28
+ warn "Cannot get `#{url}`: got bad http status `#{response.status}`"
29
+ end
30
+ end
31
+
32
+ def try_lock
33
+ old_umask = File.umask(0)
34
+ file = nil
35
+
36
+ begin
37
+ begin
38
+ file = ::File.open('/tmp/dapp-update-running.lock', ::File::RDWR | ::File::CREAT, 0777)
39
+ ensure
40
+ File.umask(old_umask)
41
+ end
42
+
43
+ if file.flock(::File::LOCK_EX | ::File::LOCK_NB)
44
+ yield
45
+ else
46
+ puts 'There are other active dapp update process, exiting without update'
47
+ end
48
+ ensure
49
+ file.close unless file.nil?
50
+ end
17
51
  end
18
52
  end
19
53
  end
@@ -12,13 +12,10 @@ module Dapp
12
12
  include Logging::Paint
13
13
 
14
14
  include SshAgent
15
- include Sentry
16
-
17
15
  include Helper::Sha256
18
- extend Helper::Trivia
16
+ extend Helper::Trivia
19
17
  include Helper::Trivia
20
18
  include Helper::Tar
21
- include Helper::Url
22
19
 
23
20
  include Deps::Gitartifact
24
21
  include Deps::Base
@@ -38,18 +35,6 @@ module Dapp
38
35
  self.class.options
39
36
  end
40
37
 
41
- def settings
42
- @settings ||= begin
43
- settings_path = File.join(self.class.home_dir, "settings.toml")
44
-
45
- if File.exists? settings_path
46
- TomlRB.load_file(settings_path)
47
- else
48
- {}
49
- end
50
- end
51
- end
52
-
53
38
  def name
54
39
  @name ||= begin
55
40
  if git_url
@@ -90,18 +75,15 @@ module Dapp
90
75
  self.class.tmp_base_dir
91
76
  end
92
77
 
93
- def build_dir
94
- @build_dir ||= begin
78
+ def build_path(*path)
79
+ @build_path ||= begin
95
80
  if option_build_dir
96
81
  Pathname.new(option_build_dir)
97
82
  else
98
83
  path('.dapp_build')
99
84
  end.expand_path.tap(&:mkpath)
100
85
  end
101
- end
102
-
103
- def build_path(*path)
104
- make_path(build_dir, *path)
86
+ make_path(@build_path, *path)
105
87
  end
106
88
 
107
89
  def local_git_artifact_exclude_paths(&blk)
@@ -147,10 +129,6 @@ module Dapp
147
129
  end
148
130
 
149
131
  class << self
150
- def home_dir
151
- File.join(Dir.home, ".dapp")
152
- end
153
-
154
132
  def options
155
133
  @options ||= {}
156
134
  end
@@ -161,10 +139,14 @@ module Dapp
161
139
  docker_bin = res.stdout.strip
162
140
 
163
141
  current_docker_version = shellout!("#{docker_bin} --version").stdout.strip
164
- required_docker_version = '1.10.0'
165
-
166
- if Gem::Version.new(required_docker_version) >= Gem::Version.new(current_docker_version[/(\d+\.)+\d+/])
167
- raise Error::Dapp, code: :docker_version, data: { version: required_docker_version }
142
+ required_min_docker_version = '1.10.0'
143
+ required_max_docker_version = '17.09.0'
144
+
145
+ if Gem::Version.new(required_min_docker_version) > Gem::Version.new(current_docker_version[/(\d+\.)+\d+/]) ||
146
+ Gem::Version.new(required_max_docker_version) < Gem::Version.new(current_docker_version[/(\d+\.)+\d+/])
147
+ raise Error::Dapp, code: :docker_version, data: { min_version: required_min_docker_version,
148
+ max_version: required_max_docker_version,
149
+ version: current_docker_version[/(\d+\.)+\d+/] }
168
150
  end
169
151
 
170
152
  [].tap do |cmd|
@@ -20,6 +20,10 @@ module Dapp::Dimg::CLI
20
20
  end
21
21
  end
22
22
  end
23
+
24
+ def run_method
25
+ class_to_lowercase
26
+ end
23
27
  end
24
28
  end
25
29
  end
@@ -3,13 +3,11 @@ module Dapp
3
3
  module Config
4
4
  module Directive
5
5
  class GitArtifactRemote < GitArtifactLocal
6
- include ::Dapp::Helper::Url
7
-
8
6
  attr_reader :_url, :_name, :_branch, :_commit
9
7
 
10
8
  def initialize(url, **kwargs, &blk)
11
9
  @_url = url
12
- @_name = git_url_to_name(url)
10
+ @_name = url.gsub(%r{.*?([^\/ ]+)\.git}, '\\1')
13
11
 
14
12
  super(**kwargs, &blk)
15
13
  end
@@ -75,7 +75,7 @@ module Dapp
75
75
  if (scheme = URI.parse(url).scheme).nil?
76
76
  :noname
77
77
  else
78
- scheme
78
+ scheme.to_sym
79
79
  end
80
80
  rescue URI::InvalidURIError
81
81
  :ssh
@@ -5,20 +5,20 @@ module Dapp
5
5
  module ChartCreate
6
6
  def kube_chart_create
7
7
  with_kube_tmp_chart_dir do
8
- FileUtils.cp_r kube_chart_path, kube_tmp_chart_path(name) if kube_chart_path.directory? && !options[:force]
8
+ FileUtils.cp_r kube_chart_path, kube_chart_path_for_helm(name) if kube_chart_path.directory? && !options[:force]
9
9
 
10
- shellout!("helm create #{name}", cwd: kube_tmp_chart_path)
10
+ shellout!("helm create #{name}", cwd: kube_chart_path_for_helm)
11
11
  kube_create_chart_samples
12
12
 
13
13
  FileUtils.rm_rf kube_chart_path
14
- FileUtils.mv kube_tmp_chart_path(name), kube_chart_path
14
+ FileUtils.mv kube_chart_path_for_helm(name), kube_chart_path
15
15
  end
16
16
  end
17
17
 
18
18
  def kube_create_chart_samples
19
- kube_tmp_chart_path(name, 'secret-values.yaml').tap { |f| FileUtils.touch(f) unless f.file? }
20
- kube_tmp_chart_path(name, kube_chart_secret_dir_name).tap { |dir| FileUtils.mkdir(dir) unless dir.directory? }
21
- kube_tmp_chart_path(name, 'templates', '_envs.tpl').tap do |f|
19
+ kube_chart_path_for_helm(name, 'secret-values.yaml').tap { |f| FileUtils.touch(f) unless f.file? }
20
+ kube_chart_path_for_helm(name, kube_chart_secret_dir_name).tap { |dir| FileUtils.mkdir(dir) unless dir.directory? }
21
+ kube_chart_path_for_helm(name, 'templates', '_envs.tpl').tap do |f|
22
22
  f.write begin
23
23
  <<-EOF
24
24
  {{- define "common_envs" }}
@@ -39,7 +39,7 @@ module Dapp
39
39
  EOF
40
40
  end unless f.file?
41
41
  end
42
- kube_tmp_chart_path(name, 'templates', 'backend.yaml').tap do |f|
42
+ kube_chart_path_for_helm(name, 'templates', 'backend.yaml').tap do |f|
43
43
  f.write begin
44
44
  <<-EOF
45
45
  apiVersion: extensions/v1beta1
@@ -58,12 +58,14 @@ module Dapp
58
58
  def with_kube_tmp_chart_dir
59
59
  yield if block_given?
60
60
  ensure
61
- FileUtils.rm_rf(kube_tmp_chart_path)
61
+ FileUtils.rm_rf(@kube_tmp_helm_chart_dir) if @kube_tmp_helm_chart_dir
62
62
  end
63
63
 
64
- def kube_tmp_chart_path(*path)
65
- @kube_tmp_path ||= Dir.mktmpdir('dapp-helm-chart-', tmp_base_dir)
66
- make_path(@kube_tmp_path, *path).expand_path.tap { |p| p.parent.mkpath }
64
+ def kube_chart_path_for_helm(*path)
65
+ chart_dir = ENV['DAPP_HELM_CHART_DIR'] || begin
66
+ @kube_tmp_helm_chart_dir ||= Dir.mktmpdir('dapp-helm-chart-', tmp_base_dir)
67
+ end
68
+ make_path(chart_dir, *path).expand_path.tap { |p| p.parent.mkpath }
67
69
  end
68
70
 
69
71
  def secret
@@ -26,7 +26,7 @@ module Dapp
26
26
  repo: repo,
27
27
  image_version: image_version,
28
28
  namespace: kube_namespace,
29
- chart_path: kube_tmp_chart_path,
29
+ chart_path: kube_chart_path_for_helm,
30
30
  set: self.options[:helm_set_options],
31
31
  values: [*kube_values_paths, *kube_tmp_chart_secret_values_paths],
32
32
  deploy_timeout: self.options[:timeout] || 300
@@ -38,7 +38,7 @@ module Dapp
38
38
  end
39
39
 
40
40
  def kube_copy_chart
41
- FileUtils.cp_r("#{kube_chart_path}/.", kube_tmp_chart_path)
41
+ FileUtils.cp_r("#{kube_chart_path}/.", kube_chart_path_for_helm)
42
42
  end
43
43
 
44
44
  def kube_helm_decode_secrets
@@ -89,10 +89,10 @@ module Dapp
89
89
  {{- define "dapp_secret_file" -}}
90
90
  {{- $relative_file_path := index . 0 -}}
91
91
  {{- $context := index . 1 -}}
92
- {{- $context.Files.Get (print "#{kube_tmp_chart_secret_path.subpath_of(kube_tmp_chart_path)}/" $relative_file_path) -}}
92
+ {{- $context.Files.Get (print "#{kube_tmp_chart_secret_path.subpath_of(kube_chart_path_for_helm)}/" $relative_file_path) -}}
93
93
  {{- end -}}
94
94
  EOF
95
- kube_tmp_chart_path('templates/_dapp_helpers.tpl').write(cont)
95
+ kube_chart_path_for_helm('templates/_dapp_helpers.tpl').write(cont)
96
96
  end
97
97
 
98
98
  def kube_flush_hooks_jobs(release)
@@ -144,14 +144,7 @@ module Dapp
144
144
  end
145
145
 
146
146
  watch_hooks_thr = Thread.new do
147
- watch_hooks.each {|job|
148
- begin
149
- Kubernetes::Manager::Job.new(self, job.name).watch_till_done!
150
- rescue ::Exception => e
151
- sentry_exception(e, extra: {"job-spec" => job.spec})
152
- raise
153
- end
154
- }
147
+ watch_hooks.each {|job| Kubernetes::Manager::Job.new(self, job.name).watch_till_done!}
155
148
  end
156
149
 
157
150
  deployment_managers = release.deployments.values
@@ -180,7 +173,7 @@ module Dapp
180
173
  end
181
174
 
182
175
  def kube_tmp_chart_secret_path(*path)
183
- kube_tmp_chart_path('decoded-secret', *path).tap { |p| p.parent.mkpath }
176
+ kube_chart_path_for_helm('decoded-secret', *path).tap { |p| p.parent.mkpath }
184
177
  end
185
178
 
186
179
  def kube_values_paths
@@ -190,7 +183,7 @@ module Dapp
190
183
  end
191
184
 
192
185
  def kube_tmp_chart_secret_values_paths
193
- @kube_tmp_chart_secret_values_paths ||= kube_secret_values_paths.map { |f| kube_tmp_chart_path("#{SecureRandom.uuid}-#{f.basename}") }
186
+ @kube_tmp_chart_secret_values_paths ||= kube_secret_values_paths.each_with_index.map { |f, i| kube_chart_path_for_helm( "decoded-secret-values-#{i}.yaml") }
194
187
  end
195
188
 
196
189
  def kube_secret_values_paths
@@ -17,7 +17,7 @@ module Dapp
17
17
  end
18
18
  end
19
19
 
20
- tmp_file_path = kube_tmp_chart_path(File.basename(file_path))
20
+ tmp_file_path = kube_chart_path_for_helm(File.basename(file_path))
21
21
  tmp_file_path.binwrite(decoded_data)
22
22
 
23
23
  loop do
@@ -49,8 +49,8 @@ module Dapp
49
49
 
50
50
  def deploy!
51
51
  args = [
52
- name, chart_path, additional_values,
53
- set_options, extra_options
52
+ name, chart_path, additional_values_options,
53
+ set_options, upgrade_extra_options
54
54
  ].flatten
55
55
 
56
56
  dapp.kubernetes.create_namespace!(namespace) unless dapp.kubernetes.namespace?(namespace)
@@ -62,52 +62,31 @@ module Dapp
62
62
 
63
63
  def evaluation_output
64
64
  @evaluation_output ||= begin
65
- args = [
66
- name, chart_path, additional_values,
67
- set_options, extra_options(dry_run: true)
68
- ].flatten
69
-
70
- dapp.shellout!("helm upgrade #{args.join(' ')}").stdout
65
+ cmd = dapp.shellout! [
66
+ "helm",
67
+ "template",
68
+ chart_path,
69
+ additional_values_options,
70
+ set_options,
71
+ ("--namespace #{namespace}" if namespace),
72
+ ].compact.join(" ")
73
+
74
+ cmd.stdout
71
75
  end
72
76
  end
73
77
 
74
78
  def resources_specs
75
79
  @resources_specs ||= {}.tap do |specs|
76
- generator = proc do |text|
77
- text.split(/# Source.*|---/).reject {|c| c.strip.empty? }.map {|c| yaml_load(c) }.each do |spec|
78
- specs[spec['kind']] ||= {}
79
- specs[spec['kind']][(spec['metadata'] || {})['name']] = spec
80
- end
81
- end
82
-
83
- hook_start_index = nil
84
- if ind = evaluation_output.lines.index("HOOKS:\n")
85
- hook_start_index = ind + 1
86
- else
87
- warn "[WARN][DEBUG INFO] Cannot find HOOKS section in helm dry-run output:"
88
- end
89
-
90
- manifest_start_index = nil
91
- if ind = evaluation_output.lines.index("MANIFEST:\n")
92
- manifest_start_index = ind + 1
93
- else
94
- warn "[WARN][DEBUG INFO] Cannot find MANIFEST section in helm dry-run output:"
95
- end
96
-
97
- happy_helming_start_index = evaluation_output.lines.index("Release \"#{name}\" has been upgraded. Happy Helming!\n")
98
-
99
- generator.call(evaluation_output.lines[hook_start_index..manifest_start_index-2].join) if hook_start_index and manifest_start_index
100
- if manifest_start_index
101
- if happy_helming_start_index
102
- generator.call(evaluation_output.lines[manifest_start_index..happy_helming_start_index-2].join)
103
- else
104
- generator.call(evaluation_output.lines[manifest_start_index..-1].join)
105
- end
80
+ evaluation_output.split(/^---$/)
81
+ .reject {|chunk| chunk.lines.all? {|line| line.strip.empty? or line.strip.start_with? "#"}}
82
+ .map {|chunk| yaml_load(chunk)}.each do |spec|
83
+ specs[spec['kind']] ||= {}
84
+ specs[spec['kind']][(spec['metadata'] || {})['name']] = spec
106
85
  end
107
86
  end
108
87
  end
109
88
 
110
- def additional_values
89
+ def additional_values_options
111
90
  [].tap do |options|
112
91
  options.concat(values.map { |p| "--values #{p}" })
113
92
  end
@@ -122,11 +101,11 @@ module Dapp
122
101
  end
123
102
  end
124
103
 
125
- def extra_options(dry_run: nil)
104
+ def upgrade_extra_options(dry_run: nil)
126
105
  dry_run = dapp.dry_run? if dry_run.nil?
127
106
 
128
107
  [].tap do |options|
129
- options << "--namespace #{namespace}"
108
+ options << "--namespace #{namespace}" if namespace
130
109
  options << '--install'
131
110
  options << '--dry-run' if dry_run
132
111
  options << '--debug' if dry_run
@@ -1,4 +1,4 @@
1
1
  module Dapp
2
- VERSION = '0.17.4'.freeze
2
+ VERSION = '0.18.0'.freeze
3
3
  BUILD_CACHE_VERSION = 20
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.17.4
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Stolyarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-16 00:00:00.000000000 Z
11
+ date: 2017-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -186,34 +186,6 @@ dependencies:
186
186
  - - ">="
187
187
  - !ruby/object:Gem::Version
188
188
  version: 1.0.6
189
- - !ruby/object:Gem::Dependency
190
- name: sentry-raven
191
- requirement: !ruby/object:Gem::Requirement
192
- requirements:
193
- - - "~>"
194
- - !ruby/object:Gem::Version
195
- version: 2.7.2
196
- type: :runtime
197
- prerelease: false
198
- version_requirements: !ruby/object:Gem::Requirement
199
- requirements:
200
- - - "~>"
201
- - !ruby/object:Gem::Version
202
- version: 2.7.2
203
- - !ruby/object:Gem::Dependency
204
- name: toml-rb
205
- requirement: !ruby/object:Gem::Requirement
206
- requirements:
207
- - - "~>"
208
- - !ruby/object:Gem::Version
209
- version: 1.1.1
210
- type: :runtime
211
- prerelease: false
212
- version_requirements: !ruby/object:Gem::Requirement
213
- requirements:
214
- - - "~>"
215
- - !ruby/object:Gem::Version
216
- version: 1.1.1
217
189
  - !ruby/object:Gem::Dependency
218
190
  name: bundler
219
191
  requirement: !ruby/object:Gem::Requirement
@@ -471,7 +443,6 @@ files:
471
443
  - lib/dapp/dapp/logging/i18n.rb
472
444
  - lib/dapp/dapp/logging/paint.rb
473
445
  - lib/dapp/dapp/logging/process.rb
474
- - lib/dapp/dapp/sentry.rb
475
446
  - lib/dapp/dapp/shellout/base.rb
476
447
  - lib/dapp/dapp/shellout/streaming.rb
477
448
  - lib/dapp/dapp/ssh_agent.rb
@@ -668,7 +639,6 @@ files:
668
639
  - lib/dapp/helper/sha256.rb
669
640
  - lib/dapp/helper/tar.rb
670
641
  - lib/dapp/helper/trivia.rb
671
- - lib/dapp/helper/url.rb
672
642
  - lib/dapp/helper/yaml.rb
673
643
  - lib/dapp/kube.rb
674
644
  - lib/dapp/kube/cli/cli.rb
@@ -736,7 +706,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
736
706
  version: 2.5.0
737
707
  requirements: []
738
708
  rubyforge_project:
739
- rubygems_version: 2.5.1
709
+ rubygems_version: 2.7.0
740
710
  signing_key:
741
711
  specification_version: 4
742
712
  summary: Build docker packaged apps using chef or shell
@@ -1,112 +0,0 @@
1
- module Dapp
2
- class Dapp
3
- module Sentry
4
- def sentry_message(msg, **kwargs)
5
- return if not ensure_sentry_configured
6
- kwargs[:level] ||= "info"
7
- Raven.capture_message(msg, _make_sentry_params(**kwargs))
8
- end
9
-
10
- def sentry_exception(exception, **kwargs)
11
- return if not ensure_sentry_configured
12
- (kwargs[:tags] ||= {})['error-code'] = begin
13
- net_status = exception.net_status
14
- [net_status[:context], net_status[:code]].compact.join('_')
15
- end
16
- Raven.capture_exception(exception, _make_sentry_params(**kwargs))
17
- end
18
-
19
- def ensure_sentry_configured
20
- return false unless sentry_settings = settings["sentry"]
21
-
22
- unless @sentry_settings_configured
23
- Raven.configure do |config|
24
- logger = ::Logger.new(STDOUT)
25
- logger.level = ::Logger::WARN
26
-
27
- config.logger = logger
28
- config.dsn = sentry_settings["dsn"]
29
- end
30
-
31
- @sentry_settings_configured = true
32
- end
33
-
34
- return true
35
- end
36
-
37
- def _make_sentry_params(level: nil, tags: {}, extra: {}, user: {})
38
- {
39
- level: level,
40
- tags: _sentry_tags_context.merge(tags),
41
- extra: _sentry_extra_context.merge(extra),
42
- user: _sentry_user_context.merge(user),
43
- }
44
- end
45
-
46
- def _sentry_extra_context
47
- @_sentry_extra_context ||= {
48
- "pwd" => Dir.pwd,
49
- "dapp-dir" => self.work_dir,
50
- "options" => self.options,
51
- "env-options" => {
52
- "DAPP_FORCE_SAVE_CACHE" => ENV["DAPP_FORCE_SAVE_CACHE"],
53
- "DAPP_BIN_DAPPFILE_YML" => ENV["DAPP_BIN_DAPPFILE_YML"],
54
- "ANSIBLE_ARGS" => ENV["ANSIBLE_ARGS"],
55
- "DAPP_CHEF_DEBUG" => ENV["DAPP_CHEF_DEBUG"],
56
- },
57
- }.tap {|extra|
58
- extra["ci-env"] = {"CI" => ENV["CI"]}
59
- ENV.select {|k, v| k.start_with?("CI_")}.each do |k, v|
60
- extra["ci-env"][k] = v
61
- end
62
- }
63
- end
64
-
65
- def _sentry_tags_context
66
- name = options[:name] ||
67
- @_sentry_tags_context ||= {
68
- "dapp-short-version" => ::Dapp::VERSION.split(".")[0..1].join("."),
69
- "dapp-version" => ::Dapp::VERSION,
70
- "dapp-build-cache-version" => ::Dapp::BUILD_CACHE_VERSION,
71
- "dapp-command" => self.options[:dapp_command],
72
- }.tap {|tags|
73
- git_config_path = File.join(Dir.pwd, ".git/config")
74
-
75
- tags["dapp-name"] = options[:name]
76
-
77
- if File.exists? git_config_path
78
- cfg = IniFile.load(File.join(Dir.pwd, ".git/config"))
79
- remote_origin_cfg = cfg['remote "origin"']
80
- remote_origin_url = remote_origin_cfg["url"]
81
- if remote_origin_url
82
- tags["dapp-name"] ||= begin
83
- repo_name = remote_origin_url.split('/').last
84
- repo_name = repo_name[/.*(?=\.git)/] if repo_name.end_with? '.git'
85
- repo_name
86
- end
87
-
88
- tags["git-host"] = self.get_host_from_git_url(remote_origin_url)
89
-
90
- git_name = self.git_url_to_name(remote_origin_url)
91
-
92
- tags["git-group"] = git_name.partition("/")[0]
93
- tags["git-name"] = git_name
94
- end
95
- end
96
-
97
- tags["dapp-name"] ||= File.basename(Dir.pwd)
98
-
99
- begin
100
- ver = self.class.host_docker_minor_version
101
- tags["docker-minor-version"] = ver.to_s
102
- rescue ::Exception
103
- end
104
- }
105
- end
106
-
107
- def _sentry_user_context
108
- @_sentry_user_context ||= {}
109
- end
110
- end # Sentry
111
- end # Dapp
112
- end # Dapp
@@ -1,23 +0,0 @@
1
- module Dapp
2
- module Helper
3
- module Url
4
- def git_url_to_name(url)
5
- url_without_scheme = url.split("://", 2).last
6
- # This may be broken, because "@" should delimit creds, not a ":"
7
- url_without_creds = url_without_scheme.split(":", 2).last
8
- url_without_creds.gsub(%r{.*?([^\/ ]+\/[^\/ ]+)\.git}, '\\1')
9
- end
10
-
11
- def get_host_from_git_url(url)
12
- url_without_scheme = url.split("://", 2).last
13
- url_without_creds = url_without_scheme.split("@", 2).last
14
-
15
- # Split out part after ":" in this kind of url: github.com:flant/dapp.git
16
- url_part = url_without_creds.split(":", 2).first
17
-
18
- # Split out part after first "/": github.com/flant/dapp.git
19
- url_part.split("/", 2).first
20
- end
21
- end # Url
22
- end # Helper
23
- end # Dapp