dapp 0.21.16 → 0.22.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.
Files changed (39) hide show
  1. checksums.yaml +5 -5
  2. data/bin/dapp +0 -4
  3. data/config/en/net_status.yml +3 -2
  4. data/lib/dapp.rb +1 -4
  5. data/lib/dapp/cli.rb +0 -4
  6. data/lib/dapp/cli/command/base.rb +1 -7
  7. data/lib/dapp/cli/command/update.rb +1 -1
  8. data/lib/dapp/dapp.rb +19 -40
  9. data/lib/dapp/dapp/command/common.rb +19 -0
  10. data/lib/dapp/dapp/option_tags.rb +4 -6
  11. data/lib/dapp/dimg/build/stage/artifact_default.rb +1 -1
  12. data/lib/dapp/dimg/builder/chef/cookbook.rb +1 -1
  13. data/lib/dapp/dimg/cli/command/base.rb +4 -0
  14. data/lib/dapp/dimg/config/directive/artifact_dimg.rb +7 -0
  15. data/lib/dapp/dimg/config/directive/dimg/instance_methods.rb +0 -1
  16. data/lib/dapp/dimg/config/directive/dimg/validation.rb +16 -39
  17. data/lib/dapp/dimg/config/directive/git_artifact_remote.rb +7 -6
  18. data/lib/dapp/dimg/dapp/command/cleanup_repo.rb +98 -24
  19. data/lib/dapp/dimg/dapp/command/common.rb +4 -13
  20. data/lib/dapp/dimg/dapp/command/stages/cleanup_local.rb +9 -7
  21. data/lib/dapp/dimg/dapp/command/stages/cleanup_repo.rb +1 -1
  22. data/lib/dapp/dimg/dapp/command/stages/common.rb +1 -6
  23. data/lib/dapp/dimg/dapp/command/stages/flush_local.rb +5 -3
  24. data/lib/dapp/dimg/dapp/command/stages/flush_repo.rb +1 -1
  25. data/lib/dapp/dimg/docker_registry/dimg.rb +0 -9
  26. data/lib/dapp/dimg/git_repo/base.rb +30 -4
  27. data/lib/dapp/dimg/image/argument.rb +1 -3
  28. data/lib/dapp/helper/trivia.rb +0 -35
  29. data/lib/dapp/kube/cli/command/kube/deploy.rb +6 -0
  30. data/lib/dapp/kube/dapp/command/common.rb +129 -13
  31. data/lib/dapp/kube/dapp/command/deploy.rb +2 -9
  32. data/lib/dapp/kube/dapp/command/render.rb +2 -2
  33. data/lib/dapp/kube/error/base.rb +5 -1
  34. data/lib/dapp/kube/helm/release.rb +39 -3
  35. data/lib/dapp/kube/kubernetes/client.rb +2 -0
  36. data/lib/dapp/version.rb +2 -2
  37. metadata +4 -33
  38. data/lib/dapp/dapp/sentry.rb +0 -112
  39. data/lib/dapp/helper/url.rb +0 -23
@@ -59,14 +59,7 @@ module Dapp
59
59
  end
60
60
 
61
61
  watch_hooks_thr = Thread.new do
62
- watch_hooks.each {|job|
63
- begin
64
- Kubernetes::Manager::Job.new(self, job.name).watch_till_done!
65
- rescue ::Exception => e
66
- sentry_exception(e, extra: {"job-spec" => job.spec})
67
- raise
68
- end
69
- }
62
+ watch_hooks.each {|job| Kubernetes::Manager::Job.new(self, job.name).watch_till_done!}
70
63
  end
71
64
 
72
65
  deployment_managers = release.deployments.values
@@ -85,7 +78,7 @@ module Dapp
85
78
  deployment_managers.each {|deployment_manager| deployment_manager.watch_till_ready!}
86
79
  end
87
80
  rescue ::Timeout::Error
88
- raise Error::Base, code: :deploy_timeout
81
+ raise Kube::Error::Base, code: :deploy_timeout
89
82
  end
90
83
  end
91
84
  end
@@ -13,8 +13,8 @@ module Dapp
13
13
  template_relative_path_pattern = Pathname(File.expand_path(template_path_pattern)).subpath_of(path('.helm'))
14
14
  template_relative_path_pattern ||= template_path_pattern
15
15
 
16
- File.fnmatch?(template_relative_path_pattern, template_path_without_chart_name, File::FNM_PATHNAME|File::FNM_DOTMATCH) ||
17
- File.fnmatch?(template_relative_path_pattern, template_path, File::FNM_PATHNAME|File::FNM_DOTMATCH)
16
+ File.fnmatch(template_relative_path_pattern, template_path_without_chart_name) ||
17
+ File.fnmatch(template_relative_path_pattern, template_path)
18
18
  end
19
19
  end
20
20
  else
@@ -1,7 +1,11 @@
1
1
  module Dapp
2
2
  module Kube
3
3
  module Error
4
- class Base < ::Dapp::Error::Base; end
4
+ class Base < ::Dapp::Error::Base
5
+ def initialize(**net_status)
6
+ super(**net_status, context: :kube)
7
+ end
8
+ end
5
9
  end
6
10
  end
7
11
  end
@@ -13,10 +13,11 @@ module Dapp
13
13
  attr_reader :set
14
14
  attr_reader :values
15
15
  attr_reader :deploy_timeout
16
+ attr_reader :without_registry
16
17
 
17
18
  def initialize(dapp,
18
19
  name:, repo:, docker_tag:, namespace:, chart_path:,
19
- set: [], values: [], deploy_timeout: nil)
20
+ set: [], values: [], deploy_timeout: nil, without_registry: nil)
20
21
  @dapp = dapp
21
22
 
22
23
  @name = name
@@ -27,6 +28,7 @@ module Dapp
27
28
  @set = set
28
29
  @values = values
29
30
  @deploy_timeout = deploy_timeout
31
+ @without_registry = (without_registry.nil? ? false : without_registry)
30
32
  end
31
33
 
32
34
  def jobs
@@ -90,7 +92,7 @@ module Dapp
90
92
  "template",
91
93
  chart_path,
92
94
  additional_values_options,
93
- set_options,
95
+ set_options(without_registry: true),
94
96
  ("--namespace #{namespace}" if namespace),
95
97
  ].compact.join(" ")
96
98
 
@@ -115,11 +117,45 @@ module Dapp
115
117
  end
116
118
  end
117
119
 
118
- def set_options
120
+ def dimg_registry
121
+ @dimg_registry ||= dapp.dimg_registry(repo)
122
+ end
123
+
124
+ def set_options(without_registry: false)
119
125
  [].tap do |options|
120
126
  options.concat(set.map { |opt| "--set #{opt}" })
121
127
  options << "--set global.dapp.repo=#{repo}"
122
128
  options << "--set global.dapp.docker_tag=#{docker_tag}"
129
+
130
+ if dapp.nameless_dimg?
131
+ options << "--set global.dapp.docker_image=#{repo}:#{docker_tag}"
132
+ if self.without_registry || without_registry
133
+ options << "--set global.dapp.docker_image_id=\\\"-\\\""
134
+ else
135
+ options << "--set global.dapp.docker_image_id=#{dimg_registry.image_id(docker_tag, nil)}"
136
+ end
137
+ else
138
+ dapp.dimgs_names.each do |dimg_name|
139
+ options << "--set global.dapp.docker_image.#{dimg_name}=#{repo}/#{dimg_name}:#{docker_tag}"
140
+ if self.without_registry || without_registry
141
+ options << "--set global.dapp.docker_image_id.#{dimg_name}=\\\"-\\\""
142
+ else
143
+ options << "--set global.dapp.docker_image_id.#{dimg_name}=#{dimg_registry.image_id(docker_tag, dimg_name)}"
144
+ end
145
+ end
146
+ end
147
+
148
+ is_branch = if ENV["CI_COMMIT_TAG"]
149
+ false
150
+ elsif ENV["CI_COMMIT_REF_NAME"]
151
+ true
152
+ elsif dapp.git_path and dapp.git_local_repo.branch != "HEAD"
153
+ true
154
+ else
155
+ false
156
+ end
157
+ options << "--set global.dapp.is_branch=#{is_branch}"
158
+
123
159
  options << "--set global.namespace=#{namespace}"
124
160
  end
125
161
  end
@@ -218,6 +218,8 @@ module Dapp
218
218
 
219
219
  client_key_data = kube_config.fetch('users', [{}]).first.fetch('user', {}).fetch('client-key-data', nil)
220
220
  opts[:client_key_data] = Base64.decode64(client_key_data) if client_key_data
221
+
222
+ opts.merge!(excon_parameters)
221
223
  end
222
224
  end
223
225
 
data/lib/dapp/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Dapp
2
- VERSION = '0.21.16'.freeze
3
- BUILD_CACHE_VERSION = 24.2
2
+ VERSION = '0.22.0'.freeze
3
+ BUILD_CACHE_VERSION = 24
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.21.16
4
+ version: 0.22.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-12-06 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
@@ -461,6 +433,7 @@ files:
461
433
  - lib/dapp/core_ext/pathname.rb
462
434
  - lib/dapp/dapp.rb
463
435
  - lib/dapp/dapp/chef.rb
436
+ - lib/dapp/dapp/command/common.rb
464
437
  - lib/dapp/dapp/dapp_config.rb
465
438
  - lib/dapp/dapp/dappfile.rb
466
439
  - lib/dapp/dapp/deps/base.rb
@@ -473,7 +446,6 @@ files:
473
446
  - lib/dapp/dapp/logging/paint.rb
474
447
  - lib/dapp/dapp/logging/process.rb
475
448
  - lib/dapp/dapp/option_tags.rb
476
- - lib/dapp/dapp/sentry.rb
477
449
  - lib/dapp/dapp/shellout/base.rb
478
450
  - lib/dapp/dapp/shellout/streaming.rb
479
451
  - lib/dapp/dapp/ssh_agent.rb
@@ -669,7 +641,6 @@ files:
669
641
  - lib/dapp/helper/sha256.rb
670
642
  - lib/dapp/helper/tar.rb
671
643
  - lib/dapp/helper/trivia.rb
672
- - lib/dapp/helper/url.rb
673
644
  - lib/dapp/helper/yaml.rb
674
645
  - lib/dapp/kube.rb
675
646
  - lib/dapp/kube/cli/cli.rb
@@ -741,7 +712,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
741
712
  version: 2.5.0
742
713
  requirements: []
743
714
  rubyforge_project:
744
- rubygems_version: 2.5.1
715
+ rubygems_version: 2.7.3
745
716
  signing_key:
746
717
  specification_version: 4
747
718
  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