dapp 0.35.45 → 0.36.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.
- checksums.yaml +4 -4
- data/bin/dapp +1 -23
- data/config/en/net_status.yml +1 -0
- data/lib/dapp.rb +1 -0
- data/lib/dapp/dapp/dappfile.rb +2 -2
- data/lib/dapp/dapp/ruby2go.rb +6 -2
- data/lib/dapp/dimg/dapp/command/cleanup_repo.rb +8 -14
- data/lib/dapp/kube/dapp/command/deploy.rb +46 -0
- data/lib/dapp/kube/dapp/command/dismiss.rb +15 -0
- data/lib/dapp/kube/dapp/command/lint.rb +16 -1
- data/lib/dapp/kube/dapp/command/render.rb +15 -0
- data/lib/dapp/kube/dapp/command/ruby2go.rb +17 -0
- data/lib/dapp/kube/dapp/command/secret_edit.rb +7 -99
- data/lib/dapp/kube/dapp/command/secret_extract.rb +3 -45
- data/lib/dapp/kube/dapp/command/secret_generate.rb +7 -45
- data/lib/dapp/kube/dapp/command/secret_key_generate.rb +1 -1
- data/lib/dapp/kube/dapp/command/secret_regenerate.rb +1 -27
- data/lib/dapp/kube/dapp/dapp.rb +1 -0
- data/lib/dapp/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d135d54181359c7611f52b0ab468ad228d54965e2330ddd01e0ec93f76895960
|
|
4
|
+
data.tar.gz: 41f7fabca8433c1fc63a21d0046445c42e277bb1990a0fef61fff91426fd9fae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0cc215bc2eea16d569556c5b63b5f68720bf24e99c7d2aece391a69b6093bf40f175773b19e7c1ad562b97f8c306b12eb7acb3b4c188e64f5f10149eeff2a66d
|
|
7
|
+
data.tar.gz: ce224f9c86f8211fd12ccd95022d178b8973a9eefc49c1686e6fab1a55bb8c49f06dc6b5331ed26f1ccad4221ae4c79783319949a27ad27a28be1ed1e888316d
|
data/bin/dapp
CHANGED
|
@@ -75,29 +75,7 @@ set_gitlab_cancel_handler if ENV["GITLAB_CI"]
|
|
|
75
75
|
begin
|
|
76
76
|
begin
|
|
77
77
|
begin
|
|
78
|
-
|
|
79
|
-
Dapp::CLI.new.run
|
|
80
|
-
ensure
|
|
81
|
-
if Time.now.to_date < Date.parse("2019-11-01")
|
|
82
|
-
STDERR.puts
|
|
83
|
-
STDERR.puts ::Paint["###################################################################", :red, :bold]
|
|
84
|
-
STDERR.puts ::Paint["### DEPRECATION WARNING! ###", :red, :bold]
|
|
85
|
-
STDERR.puts ::Paint["### Dapp will be deprecated for use starting with 01.11.2019! ###", :red, :bold]
|
|
86
|
-
STDERR.puts ::Paint["### Please port your project to werf: ###", :red, :bold]
|
|
87
|
-
STDERR.puts ::Paint["### https://werf.io ###", :red, :bold]
|
|
88
|
-
STDERR.puts ::Paint["###################################################################", :red, :bold]
|
|
89
|
-
STDERR.puts
|
|
90
|
-
else
|
|
91
|
-
STDERR.puts
|
|
92
|
-
STDERR.puts ::Paint["######################################################################", :red, :bold]
|
|
93
|
-
STDERR.puts ::Paint["### DEPRECATION WARNING! ###", :red, :bold]
|
|
94
|
-
STDERR.puts ::Paint["### Dapp is deprecated for use and will not receive any support! ###", :red, :bold]
|
|
95
|
-
STDERR.puts ::Paint["### Please port your project to werf: ###", :red, :bold]
|
|
96
|
-
STDERR.puts ::Paint["### https://werf.io ###", :red, :bold]
|
|
97
|
-
STDERR.puts ::Paint["######################################################################", :red, :bold]
|
|
98
|
-
STDERR.puts
|
|
99
|
-
end
|
|
100
|
-
end
|
|
78
|
+
Dapp::CLI.new.run
|
|
101
79
|
rescue Dapp::Error::Base => e
|
|
102
80
|
unless (message = Dapp::Helper::NetStatus.before_error_message(e)).empty?
|
|
103
81
|
$stderr.puts(message)
|
data/config/en/net_status.yml
CHANGED
|
@@ -53,6 +53,7 @@ en:
|
|
|
53
53
|
kube_helm_failed: "Helm failed: %{output}"
|
|
54
54
|
samples_directory_not_exist: "Samples directory `%{path}` not exist in repository `%{url}`!"
|
|
55
55
|
sample_not_exist: "Sample `%{name}` not exist in repository `%{url}` (inside samples directory `%{path}`)!"
|
|
56
|
+
ruby2go_deploy_command_failed: "ruby2go_deploy command `%{command}` failed: `%{message}`!"
|
|
56
57
|
dapp:
|
|
57
58
|
no_such_dimg: "No such dimg: `%{dimgs_patterns}`!"
|
|
58
59
|
no_such_app: "No such app: `%{apps_patterns}`!"
|
data/lib/dapp.rb
CHANGED
|
@@ -141,6 +141,7 @@ require 'dapp/kube/dapp/command/chart_create'
|
|
|
141
141
|
require 'dapp/kube/dapp/command/render'
|
|
142
142
|
require 'dapp/kube/dapp/command/lint'
|
|
143
143
|
require 'dapp/kube/dapp/command/value_get'
|
|
144
|
+
require 'dapp/kube/dapp/command/ruby2go'
|
|
144
145
|
require 'dapp/kube/dapp/dapp'
|
|
145
146
|
require 'dapp/dimg'
|
|
146
147
|
require 'dapp/dimg/error/default'
|
data/lib/dapp/dapp/dappfile.rb
CHANGED
|
@@ -116,12 +116,12 @@ module Dapp
|
|
|
116
116
|
return if File.exists? dappfile_yml_bin_path
|
|
117
117
|
|
|
118
118
|
log_process("Downloading dappfile-yml dapp dependency") do
|
|
119
|
-
location = URI("https://dl.bintray.com/dapp
|
|
119
|
+
location = URI("https://dl.bintray.com/flant/dapp/#{::Dapp::VERSION}/dappfile-yml")
|
|
120
120
|
|
|
121
121
|
tmp_bin_path = File.join(self.class.tmp_base_dir, "dappfile-yml-#{SecureRandom.uuid}")
|
|
122
122
|
::Dapp::Downloader.download(location, tmp_bin_path, show_progress: true, progress_titile: dappfile_yml_bin_path)
|
|
123
123
|
|
|
124
|
-
checksum_location = URI("https://dl.bintray.com/dapp
|
|
124
|
+
checksum_location = URI("https://dl.bintray.com/flant/dapp/#{::Dapp::VERSION}/dappfile-yml.sha")
|
|
125
125
|
tmp_bin_checksum_path = tmp_bin_path + ".checksum"
|
|
126
126
|
::Dapp::Downloader.download(checksum_location, tmp_bin_checksum_path)
|
|
127
127
|
|
data/lib/dapp/dapp/ruby2go.rb
CHANGED
|
@@ -40,6 +40,10 @@ module Dapp
|
|
|
40
40
|
_ruby2go("deploy-watcher", args_hash, **kwargs)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
def ruby2go_deploy(args_hash)
|
|
44
|
+
_ruby2go("deploy", args_hash)
|
|
45
|
+
end
|
|
46
|
+
|
|
43
47
|
def ruby2go_init
|
|
44
48
|
@_call_after_before_terminate << proc {
|
|
45
49
|
FileUtils.rmtree(@_ruby2go_tmp_dir) if @_ruby2go_tmp_dir
|
|
@@ -102,12 +106,12 @@ module Dapp
|
|
|
102
106
|
return if File.exists? bin_path
|
|
103
107
|
|
|
104
108
|
log_process("Downloading #{progname} dapp dependency") do
|
|
105
|
-
location = URI("https://dl.bintray.com/dapp
|
|
109
|
+
location = URI("https://dl.bintray.com/flant/dapp/#{::Dapp::VERSION}/#{progname}")
|
|
106
110
|
|
|
107
111
|
tmp_bin_path = File.join(self.class.tmp_base_dir, "#{progname}-#{SecureRandom.uuid}")
|
|
108
112
|
::Dapp::Downloader.download(location, tmp_bin_path, show_progress: true, progress_titile: bin_path)
|
|
109
113
|
|
|
110
|
-
checksum_location = URI("https://dl.bintray.com/dapp
|
|
114
|
+
checksum_location = URI("https://dl.bintray.com/flant/dapp/#{::Dapp::VERSION}/#{progname}.sha")
|
|
111
115
|
tmp_bin_checksum_path = tmp_bin_path + ".checksum"
|
|
112
116
|
::Dapp::Downloader.download(checksum_location, tmp_bin_checksum_path)
|
|
113
117
|
|
|
@@ -74,65 +74,59 @@ module Dapp
|
|
|
74
74
|
# pod items[] spec containers[] image
|
|
75
75
|
def pod_images(client)
|
|
76
76
|
client.pod_list['items'].map do |item|
|
|
77
|
-
|
|
77
|
+
item['spec']['containers'].map{ |cont| cont['image'] }
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
# cronjob items[] spec jobTemplate spec template spec containers[] image
|
|
82
82
|
def cronjob_images(client)
|
|
83
83
|
client.cronjob_list['items'].map do |item|
|
|
84
|
-
|
|
84
|
+
item['spec']['jobTemplate']['spec']['template']['spec']['containers'].map{ |cont| cont['image'] }
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
# daemonsets items[] spec template spec containers[] image
|
|
89
89
|
def daemonset_images(client)
|
|
90
90
|
client.daemonset_list['items'].map do |item|
|
|
91
|
-
|
|
91
|
+
item['spec']['template']['spec']['containers'].map{ |cont| cont['image'] }
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
# deployment items[] spec template spec containers[] image
|
|
96
96
|
def deployment_images(client)
|
|
97
97
|
client.deployment_list['items'].map do |item|
|
|
98
|
-
|
|
98
|
+
item['spec']['template']['spec']['containers'].map{ |cont| cont['image'] }
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
# job items[] spec template spec containers[] image
|
|
103
103
|
def job_images(client)
|
|
104
104
|
client.job_list['items'].map do |item|
|
|
105
|
-
|
|
105
|
+
item['spec']['template']['spec']['containers'].map{ |cont| cont['image'] }
|
|
106
106
|
end
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
# replicasets items[] spec template spec containers[] image
|
|
110
110
|
def replicaset_images(client)
|
|
111
111
|
client.replicaset_list['items'].map do |item|
|
|
112
|
-
|
|
112
|
+
item['spec']['template']['spec']['containers'].map{ |cont| cont['image'] }
|
|
113
113
|
end
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
# replicasets items[] spec template spec containers[] image
|
|
117
117
|
def statefulset_images(client)
|
|
118
118
|
client.statefulset_list['items'].map do |item|
|
|
119
|
-
|
|
119
|
+
item['spec']['template']['spec']['containers'].map{ |cont| cont['image'] }
|
|
120
120
|
end
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
# replicationcontroller items[] spec template spec containers[] image
|
|
124
124
|
def replicationcontroller_images(client)
|
|
125
125
|
client.replicationcontroller_list['items'].map do |item|
|
|
126
|
-
|
|
126
|
+
item['spec']['template']['spec']['containers'].map{ |cont| cont['image'] }
|
|
127
127
|
end
|
|
128
128
|
end
|
|
129
129
|
|
|
130
|
-
def images_from_pod_spec(pod_spec)
|
|
131
|
-
containers = Array(pod_spec['spec']['containers'])
|
|
132
|
-
initContainers = Array(pod_spec['spec']['initContainers'])
|
|
133
|
-
(containers + initContainers).map { |cont| cont['image'] }
|
|
134
|
-
end
|
|
135
|
-
|
|
136
130
|
def without_kube?
|
|
137
131
|
!!options[:without_kube]
|
|
138
132
|
end
|
|
@@ -4,6 +4,52 @@ module Dapp
|
|
|
4
4
|
module Command
|
|
5
5
|
module Deploy
|
|
6
6
|
def kube_deploy
|
|
7
|
+
# TODO: move setup_ssh_agent to golang
|
|
8
|
+
setup_ssh_agent
|
|
9
|
+
|
|
10
|
+
command = "deploy"
|
|
11
|
+
|
|
12
|
+
# TODO: move option_tags logic to golang
|
|
13
|
+
tag = begin
|
|
14
|
+
raise ::Dapp::Error::Command, code: :expected_only_one_tag, data: { tags: option_tags.join(', ') } if option_tags.count > 1
|
|
15
|
+
option_tags.first
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# TODO: move project name logic to golang
|
|
19
|
+
project_name = name.to_s
|
|
20
|
+
|
|
21
|
+
# TODO: move project dir logic to golang
|
|
22
|
+
project_dir = path.to_s
|
|
23
|
+
|
|
24
|
+
# TODO: move release name logic to golang
|
|
25
|
+
release_name = kube_release_name
|
|
26
|
+
|
|
27
|
+
# TODO: move repo logic to golang
|
|
28
|
+
repo = option_repo
|
|
29
|
+
|
|
30
|
+
dimgs = self.build_configs.map do |config|
|
|
31
|
+
d = self.dimg(config: config, ignore_signature_auto_calculation: true)
|
|
32
|
+
{"Name" => d.name, "ImageTag" => tag, "Repo" => repo}
|
|
33
|
+
end.uniq do |dimg|
|
|
34
|
+
dimg["Name"]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
res = ruby2go_deploy(
|
|
38
|
+
"command" => command,
|
|
39
|
+
"projectName" => project_name,
|
|
40
|
+
"projectDir" => project_dir,
|
|
41
|
+
"tag" => tag,
|
|
42
|
+
"releaseName" => release_name,
|
|
43
|
+
"repo" => repo,
|
|
44
|
+
"dimgs" => JSON.dump(dimgs),
|
|
45
|
+
"rubyCliOptions" => JSON.dump(self.options),
|
|
46
|
+
options: { host_docker_config_dir: self.class.host_docker_config_dir },
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
raise ::Dapp::Error::Command, code: :ruby2go_deploy_command_failed, data: { command: command, message: res["error"] } unless res["error"].nil?
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def kube_deploy_old
|
|
7
53
|
setup_ssh_agent
|
|
8
54
|
|
|
9
55
|
helm_release do |release|
|
|
@@ -4,6 +4,21 @@ module Dapp
|
|
|
4
4
|
module Command
|
|
5
5
|
module Dismiss
|
|
6
6
|
def kube_dismiss
|
|
7
|
+
command = "dismiss"
|
|
8
|
+
|
|
9
|
+
# TODO: move release name logic to golang
|
|
10
|
+
release_name = kube_release_name
|
|
11
|
+
|
|
12
|
+
res = ruby2go_deploy(
|
|
13
|
+
"command" => command,
|
|
14
|
+
"releaseName" => release_name,
|
|
15
|
+
"rubyCliOptions" => JSON.dump(self.options),
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
raise ::Dapp::Error::Command, code: :ruby2go_deploy_command_failed, data: { command: command, message: res["error"] } unless res["error"].nil?
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def kube_dismiss_old
|
|
7
22
|
lock_helm_release do
|
|
8
23
|
kube_check_helm!
|
|
9
24
|
kube_check_helm_release!
|
|
@@ -3,6 +3,21 @@ module Dapp
|
|
|
3
3
|
module Dapp
|
|
4
4
|
module Command
|
|
5
5
|
module Lint
|
|
6
|
+
def kube_lint
|
|
7
|
+
command = "lint"
|
|
8
|
+
|
|
9
|
+
# TODO: move project dir logic to golang
|
|
10
|
+
project_dir = path.to_s
|
|
11
|
+
|
|
12
|
+
res = ruby2go_deploy(
|
|
13
|
+
"command" => command,
|
|
14
|
+
"projectDir" => project_dir,
|
|
15
|
+
"rubyCliOptions" => JSON.dump(self.options),
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
raise ::Dapp::Error::Command, code: :ruby2go_deploy_command_failed, data: { command: command, message: res["error"] } unless res["error"].nil?
|
|
19
|
+
end
|
|
20
|
+
|
|
6
21
|
def kube_chart_name
|
|
7
22
|
chart_spec = yaml_load_file(kube_chart_yaml_path)
|
|
8
23
|
|
|
@@ -26,7 +41,7 @@ module Dapp
|
|
|
26
41
|
end
|
|
27
42
|
end
|
|
28
43
|
|
|
29
|
-
def
|
|
44
|
+
def kube_lint_old
|
|
30
45
|
kube_check_helm_chart_yaml!
|
|
31
46
|
with_kube_tmp_lint_chart_dir do
|
|
32
47
|
helm_release(&:lint!)
|
|
@@ -4,6 +4,21 @@ module Dapp
|
|
|
4
4
|
module Command
|
|
5
5
|
module Render
|
|
6
6
|
def kube_render
|
|
7
|
+
command = "render"
|
|
8
|
+
|
|
9
|
+
# TODO: move project dir logic to golang
|
|
10
|
+
project_dir = path.to_s
|
|
11
|
+
|
|
12
|
+
res = ruby2go_deploy(
|
|
13
|
+
"command" => command,
|
|
14
|
+
"projectDir" => project_dir,
|
|
15
|
+
"rubyCliOptions" => JSON.dump(self.options),
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
raise ::Dapp::Error::Command, code: :ruby2go_deploy_command_failed, data: { command: command, message: res["error"] } unless res["error"].nil?
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def kube_render_old
|
|
7
22
|
helm_release do |release|
|
|
8
23
|
templates = begin
|
|
9
24
|
if options[:templates].any?
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Dapp
|
|
2
|
+
module Kube
|
|
3
|
+
module Dapp
|
|
4
|
+
module Command
|
|
5
|
+
module Ruby2Go
|
|
6
|
+
def ruby2go_deploy_command(command:, raw_command_options: nil, **options)
|
|
7
|
+
(options[:options] ||= {}).merge!(project_dir: path.to_s, raw_command_options: raw_command_options)
|
|
8
|
+
ruby2go_deploy(command: command, **options).tap do |res|
|
|
9
|
+
raise ::Dapp::Error::Command, code: :ruby2go_deploy_command_failed, data: { command: command, message: res["error"] } unless res["error"].nil?
|
|
10
|
+
break res['data']
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -4,107 +4,15 @@ module Dapp
|
|
|
4
4
|
module Command
|
|
5
5
|
module SecretEdit
|
|
6
6
|
def kube_secret_edit(file_path)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
with_kube_tmp_chart_dir do
|
|
10
|
-
decoded_data = begin
|
|
11
|
-
kube_secret_file_validate!(file_path)
|
|
12
|
-
|
|
13
|
-
if options[:values]
|
|
14
|
-
kube_extract_secret_values(file_path)
|
|
15
|
-
else
|
|
16
|
-
kube_extract_secret_file(file_path)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
tmp_file_path = kube_chart_path_for_helm(File.basename(file_path))
|
|
21
|
-
tmp_file_path.binwrite(decoded_data)
|
|
22
|
-
|
|
23
|
-
loop do
|
|
24
|
-
begin
|
|
25
|
-
system(kube_secret_editor, tmp_file_path.to_s)
|
|
26
|
-
|
|
27
|
-
encoded_data = begin
|
|
28
|
-
if options[:values]
|
|
29
|
-
encoded_values = yaml_load_file(file_path)
|
|
30
|
-
|
|
31
|
-
decoded_values = kube_helm_decode_json(secret, yaml_load_file(file_path))
|
|
32
|
-
updated_decoded_values = yaml_load_file(tmp_file_path)
|
|
33
|
-
|
|
34
|
-
deep_delete_if_key_not_exist(encoded_values, updated_decoded_values)
|
|
35
|
-
|
|
36
|
-
modified_decoded_values = deep_select_modified_keys(updated_decoded_values, decoded_values)
|
|
37
|
-
updated_encoded_values = deep_merge(encoded_values, kube_helm_encode_json(secret, modified_decoded_values))
|
|
38
|
-
deep_sort_by_same_structure(updated_encoded_values, updated_decoded_values).to_yaml
|
|
39
|
-
else
|
|
40
|
-
kube_secret_file(tmp_file_path)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
IO.binwrite(file_path, "#{encoded_data}\n")
|
|
45
|
-
break
|
|
46
|
-
rescue ::Dapp::Error::Default => e
|
|
47
|
-
log_warning(Helper::NetStatus.message(e))
|
|
48
|
-
print 'Do you want to change file (Y/n)?'
|
|
49
|
-
response = $stdin.getch.tap { print "\n" }
|
|
50
|
-
return if response.strip == 'n'
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def kube_secret_editor
|
|
57
|
-
return ENV['EDITOR'] unless ENV['EDITOR'].nil?
|
|
58
|
-
%w(vim vi nano).each { |editor| return editor unless shellout("which #{editor}").exitstatus.nonzero? }
|
|
59
|
-
raise ::Dapp::Error::Command, code: :editor_not_found
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
private
|
|
63
|
-
|
|
64
|
-
def deep_merge(hash1, hash2)
|
|
65
|
-
hash1.merge(hash2) do |_, v1, v2|
|
|
66
|
-
if v1.is_a?(::Hash) && v2.is_a?(::Hash)
|
|
67
|
-
deep_merge(v1, v2)
|
|
68
|
-
else
|
|
69
|
-
v2
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def deep_select_modified_keys(hash1, hash2)
|
|
75
|
-
{}.tap do |hash|
|
|
76
|
-
hash1.each do |k, v|
|
|
77
|
-
next if hash2[k] == v
|
|
78
|
-
hash[k] = begin
|
|
79
|
-
if hash2[k].is_a?(Hash) && v.is_a?(Hash)
|
|
80
|
-
deep_select_modified_keys(v, hash2[k])
|
|
81
|
-
else
|
|
82
|
-
v
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def deep_delete_if_key_not_exist(hash1, hash2)
|
|
90
|
-
hash1.delete_if do |k, v|
|
|
91
|
-
if hash2.key?(k)
|
|
92
|
-
if hash2[k].is_a?(Hash) && v.is_a?(Hash)
|
|
93
|
-
deep_delete_if_key_not_exist(v, hash2[k])
|
|
94
|
-
end
|
|
95
|
-
false
|
|
96
|
-
else
|
|
97
|
-
true
|
|
98
|
-
end
|
|
99
|
-
end
|
|
7
|
+
ruby2go_deploy_command(command: :secret_edit, options: kube_secret_edit_command_options(file_path))
|
|
100
8
|
end
|
|
101
9
|
|
|
102
|
-
def
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
10
|
+
def kube_secret_edit_command_options(file_path)
|
|
11
|
+
{
|
|
12
|
+
tmp_dir: _ruby2go_tmp_dir,
|
|
13
|
+
file_path: file_path,
|
|
14
|
+
values: options[:values]
|
|
15
|
+
}
|
|
108
16
|
end
|
|
109
17
|
end
|
|
110
18
|
end
|
|
@@ -4,53 +4,11 @@ module Dapp
|
|
|
4
4
|
module Command
|
|
5
5
|
module SecretExtract
|
|
6
6
|
def kube_secret_extract(file_path)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
data = begin
|
|
10
|
-
if file_path
|
|
11
|
-
kube_secret_file_validate!(file_path)
|
|
12
|
-
|
|
13
|
-
if options[:values]
|
|
14
|
-
kube_extract_secret_values(file_path)
|
|
15
|
-
else
|
|
16
|
-
kube_extract_secret_file(file_path)
|
|
17
|
-
end
|
|
18
|
-
else
|
|
19
|
-
kube_extract_secret
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
if (output_file_path = options[:output_file_path])
|
|
24
|
-
FileUtils.mkpath File.dirname(output_file_path)
|
|
25
|
-
IO.binwrite(output_file_path, data)
|
|
26
|
-
else
|
|
27
|
-
puts data
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def kube_extract_secret
|
|
32
|
-
data = begin
|
|
33
|
-
if $stdin.tty?
|
|
34
|
-
print 'Enter secret: '
|
|
35
|
-
$stdin.gets
|
|
36
|
-
else
|
|
37
|
-
$stdin.read
|
|
38
|
-
end.to_s.chomp
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
if data.empty?
|
|
42
|
-
exit 0
|
|
43
|
-
else
|
|
44
|
-
secret.extract(data)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def kube_extract_secret_values(file_path)
|
|
49
|
-
kube_helm_decode_json(secret, yaml_load_file(file_path)).to_yaml
|
|
7
|
+
ruby2go_deploy_command(command: :secret_extract, raw_command_options: kube_secret_extract_raw_command_options(file_path))
|
|
50
8
|
end
|
|
51
9
|
|
|
52
|
-
def
|
|
53
|
-
|
|
10
|
+
def kube_secret_extract_raw_command_options(file_path)
|
|
11
|
+
kube_secret_generate_raw_command_options(file_path)
|
|
54
12
|
end
|
|
55
13
|
end
|
|
56
14
|
end
|
|
@@ -4,53 +4,15 @@ module Dapp
|
|
|
4
4
|
module Command
|
|
5
5
|
module SecretGenerate
|
|
6
6
|
def kube_secret_generate(file_path)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
data = begin
|
|
10
|
-
if file_path
|
|
11
|
-
kube_secret_file_validate!(file_path)
|
|
12
|
-
|
|
13
|
-
if options[:values]
|
|
14
|
-
kube_secret_values(file_path)
|
|
15
|
-
else
|
|
16
|
-
kube_secret_file(file_path)
|
|
17
|
-
end
|
|
18
|
-
else
|
|
19
|
-
kube_secret
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
if (output_file_path = options[:output_file_path])
|
|
24
|
-
FileUtils.mkpath File.dirname(output_file_path)
|
|
25
|
-
IO.binwrite(output_file_path, "#{data}\n")
|
|
26
|
-
else
|
|
27
|
-
puts data
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def kube_secret
|
|
32
|
-
data = begin
|
|
33
|
-
if $stdin.tty?
|
|
34
|
-
print 'Enter secret: '
|
|
35
|
-
$stdin.noecho(&:gets).tap { print "\n" }
|
|
36
|
-
else
|
|
37
|
-
$stdin.read
|
|
38
|
-
end.to_s.chomp
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
if data.empty?
|
|
42
|
-
exit 0
|
|
43
|
-
else
|
|
44
|
-
secret.generate(data)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def kube_secret_values(file_path)
|
|
49
|
-
kube_helm_encode_json(secret, yaml_load_file(file_path)).to_yaml
|
|
7
|
+
ruby2go_deploy_command(command: :secret_generate, raw_command_options: kube_secret_generate_raw_command_options(file_path))
|
|
50
8
|
end
|
|
51
9
|
|
|
52
|
-
def
|
|
53
|
-
|
|
10
|
+
def kube_secret_generate_raw_command_options(file_path)
|
|
11
|
+
JSON.dump({
|
|
12
|
+
file_path: file_path,
|
|
13
|
+
output_file_path: options[:output_file_path],
|
|
14
|
+
values: options[:values]
|
|
15
|
+
})
|
|
54
16
|
end
|
|
55
17
|
end
|
|
56
18
|
end
|
|
@@ -4,33 +4,7 @@ module Dapp
|
|
|
4
4
|
module Command
|
|
5
5
|
module SecretRegenerate
|
|
6
6
|
def kube_secret_regenerate(*secret_values_paths)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
secret_values_paths << kube_chart_path('secret-values.yaml') if kube_chart_path('secret-values.yaml').file?
|
|
10
|
-
secret_values_paths.each do |file_path|
|
|
11
|
-
kube_secret_file_validate!(file_path)
|
|
12
|
-
regenerated_data[file_path] = kube_regenerate_secret_values(file_path)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
Dir.glob(kube_chart_secret_path('**/*'), File::FNM_DOTMATCH).each do |file_path|
|
|
16
|
-
next if File.directory?(file_path)
|
|
17
|
-
kube_secret_file_validate!(file_path)
|
|
18
|
-
regenerated_data[file_path] = kube_regenerate_secret_file(file_path)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
regenerated_data.each { |file_path, data| IO.binwrite(file_path, "#{data}\n") }
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def kube_regenerate_secret_file(file_path)
|
|
25
|
-
secret.generate(old_secret.extract(IO.binread(file_path).chomp("\n")))
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def kube_regenerate_secret_values(file_path)
|
|
29
|
-
kube_helm_encode_json(secret, kube_helm_decode_json(old_secret, yaml_load_file(file_path))).to_yaml
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def old_secret
|
|
33
|
-
@old_secret ||= Secret.new(options[:old_secret_key])
|
|
7
|
+
ruby2go_deploy_command(command: :secret_regenerate, options: { old_key: options[:old_secret_key], secret_values_paths: secret_values_paths })
|
|
34
8
|
end
|
|
35
9
|
end
|
|
36
10
|
end
|
data/lib/dapp/kube/dapp/dapp.rb
CHANGED
data/lib/dapp/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.36.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:
|
|
11
|
+
date: 2018-11-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mixlib-shellout
|
|
@@ -692,6 +692,7 @@ files:
|
|
|
692
692
|
- lib/dapp/kube/dapp/command/lint.rb
|
|
693
693
|
- lib/dapp/kube/dapp/command/minikube_setup.rb
|
|
694
694
|
- lib/dapp/kube/dapp/command/render.rb
|
|
695
|
+
- lib/dapp/kube/dapp/command/ruby2go.rb
|
|
695
696
|
- lib/dapp/kube/dapp/command/secret_edit.rb
|
|
696
697
|
- lib/dapp/kube/dapp/command/secret_extract.rb
|
|
697
698
|
- lib/dapp/kube/dapp/command/secret_generate.rb
|
|
@@ -742,7 +743,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
742
743
|
version: 2.5.0
|
|
743
744
|
requirements: []
|
|
744
745
|
rubyforge_project:
|
|
745
|
-
rubygems_version: 2.7.
|
|
746
|
+
rubygems_version: 2.7.7
|
|
746
747
|
signing_key:
|
|
747
748
|
specification_version: 4
|
|
748
749
|
summary: Build docker packaged apps using chef or shell
|