dtk-client 0.10.0.1 → 0.10.0.2
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/.gitignore +1 -0
- data/Gemfile +0 -1
- data/dtk-client.gemspec +1 -0
- data/examples/simple/dtk.module.yaml +1 -1
- data/examples/spark/dtk.module.yaml +1 -2
- data/lib/cli/command/module.rb +1 -3
- data/lib/cli/version.rb +1 -1
- data/lib/client/content_generator.rb +11 -8
- data/lib/client/operation/client_module_dir/git_repo.rb +56 -23
- data/lib/client/operation/module/install/external_module.rb +1 -1
- data/lib/client/operation/module/install_from_catalog.rb +5 -0
- data/lib/client/operation/module/uninstall.rb +2 -2
- data/lib/client/operation/service/commit_and_push.rb +37 -30
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f28cd5b72fe1b22b5ed1c1acf5d7994c70e147d5
|
4
|
+
data.tar.gz: 3ed5a5af32baa1a5d22e5a493bd4907b7636eef2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 609335a109d58bfc74ffa0b0b5580b6474fdadea1d2691d7270420de7f60bb1bd26363c7e55cd77e0f2dbd854bc4c9939d0587360f314b77b45814809f9fae1a
|
7
|
+
data.tar.gz: 3f3446bd3d10709e48c19c12886fde17da89e16bf0dcaa866a582a525fe81bb411352da2475100ca54abe75705b02f886805f03546b6a3a6ec846bdad6d7e8ec
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/dtk-client.gemspec
CHANGED
data/lib/cli/command/module.rb
CHANGED
@@ -21,9 +21,7 @@ module DTK::Client
|
|
21
21
|
module Module
|
22
22
|
include Command::Mixin
|
23
23
|
|
24
|
-
|
25
|
-
# ALL_SUBCOMMANDS = ['install', 'list', 'list-assemblies', 'push', 'uninstall', 'clone']
|
26
|
-
ALL_SUBCOMMANDS = ['install', 'list', 'list-assemblies', 'uninstall', 'clone']
|
24
|
+
ALL_SUBCOMMANDS = ['install', 'list', 'list-assemblies', 'push', 'uninstall', 'clone']
|
27
25
|
command_def :desc => 'Subcommands for interacting with DTK modules'
|
28
26
|
ALL_SUBCOMMANDS.each { |subcommand| require_relative("module/#{subcommand.gsub(/-/,'_')}") }
|
29
27
|
end
|
data/lib/cli/version.rb
CHANGED
@@ -91,8 +91,8 @@ module DTK::Client
|
|
91
91
|
content_hash = convert_file_content_to_hash(assembly)
|
92
92
|
name = content_hash['name']
|
93
93
|
assembly_content = content_hash['assembly']
|
94
|
-
workflows = ret_workflows_hash(content_hash
|
95
|
-
|
94
|
+
workflows = ret_workflows_hash(content_hash)
|
95
|
+
|
96
96
|
assembly_content.merge!('workflows' => workflows) if workflows
|
97
97
|
assemblies.merge!(name => assembly_content)
|
98
98
|
end
|
@@ -100,12 +100,15 @@ module DTK::Client
|
|
100
100
|
assemblies.empty? ? nil : assemblies
|
101
101
|
end
|
102
102
|
|
103
|
-
def ret_workflows_hash(
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
103
|
+
def ret_workflows_hash(content_hash)
|
104
|
+
if workflows = content_hash['workflow'] || content_hash['workflows']
|
105
|
+
# this is legacy workflow
|
106
|
+
if workflow_name = workflows.delete('assembly_action')
|
107
|
+
{ workflow_name => workflows }
|
108
|
+
else
|
109
|
+
workflows
|
110
|
+
end
|
111
|
+
end
|
109
112
|
end
|
110
113
|
|
111
114
|
def ret_dependencies_hash
|
@@ -83,11 +83,16 @@ module DTK::Client
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
def self.
|
86
|
+
def self.add_service_repo_file(args)
|
87
87
|
wrap_operation(args) do |args|
|
88
|
-
response_data_hash(:repo => Internal.
|
88
|
+
response_data_hash(:repo => Internal.add_service_repo_file(args))
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.get_service_repo_file_content(args)
|
93
|
+
wrap_operation(args) do |args|
|
94
|
+
response_data_hash(:content => Internal.get_service_repo_file_content(args))
|
89
95
|
end
|
90
|
-
|
91
96
|
end
|
92
97
|
|
93
98
|
def self.pull_from_service_repo(args)
|
@@ -283,33 +288,61 @@ module DTK::Client
|
|
283
288
|
repo.pull(Dtkn::GIT_REMOTE, remote_branch)
|
284
289
|
end
|
285
290
|
|
286
|
-
def self.
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
unless all_backup_file_paths.include?(line.strip)
|
294
|
-
write = File.open(file_path, "a")
|
295
|
-
write << line
|
296
|
-
end
|
297
|
-
end
|
298
|
-
end
|
299
|
-
else
|
300
|
-
File.open(".gitignore", "w") do |f|
|
301
|
-
all_backup_file_paths.each {|el| f.puts("#{el}\n")}
|
302
|
-
end
|
291
|
+
def self.add_service_repo_file(args)
|
292
|
+
branch = args.required(:branch)
|
293
|
+
service_instance = args.required(:service_instance)
|
294
|
+
path = args.required(:path)
|
295
|
+
content = args.required(:content)
|
296
|
+
checkout_branch(service_instance, branch) do
|
297
|
+
File.open(qualified_path(service_instance, path), 'w') { |f| f.write(content) }
|
303
298
|
end
|
304
|
-
|
305
|
-
|
306
|
-
|
299
|
+
end
|
300
|
+
|
301
|
+
# returns content if file exists
|
302
|
+
def self.get_service_repo_file_content(args)
|
303
|
+
branch = args.required(:branch)
|
304
|
+
service_instance = args.required(:service_instance)
|
305
|
+
path = args.required(:path)
|
306
|
+
checkout_branch(service_instance, branch) do
|
307
|
+
qualified_path = qualified_path(service_instance, path)
|
308
|
+
if File.exists?(qualified_path)
|
309
|
+
File.open(qualified_path, 'r').read
|
310
|
+
end
|
307
311
|
end
|
308
312
|
end
|
309
313
|
|
310
314
|
def self.git_repo
|
311
315
|
::DTK::Client::GitRepo
|
312
316
|
end
|
317
|
+
|
318
|
+
private
|
319
|
+
|
320
|
+
# relative_path is relative to top-leel repo directory
|
321
|
+
def self.qualified_path(service_instance, relative_path)
|
322
|
+
repo_dir = ret_base_path(:service, service_instance)
|
323
|
+
"#{repo_dir}/#{relative_path}"
|
324
|
+
end
|
325
|
+
|
326
|
+
CHECKOUT_LOCK = Mutex.new
|
327
|
+
def self.checkout_branch(service_instance, branch, &body)
|
328
|
+
ret = nil
|
329
|
+
CHECKOUT_LOCK.synchronize do
|
330
|
+
repo = git_repo.new(ret_base_path(:service, service_instance), :branch => branch)
|
331
|
+
current_branch = repo.current_branch.name
|
332
|
+
if current_branch == branch
|
333
|
+
ret = yield
|
334
|
+
else
|
335
|
+
begin
|
336
|
+
repo.checkout(branch)
|
337
|
+
ret = yield
|
338
|
+
ensure
|
339
|
+
repo.checkout(current_branch)
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
ret
|
344
|
+
end
|
345
|
+
|
313
346
|
end
|
314
347
|
end
|
315
348
|
end
|
@@ -23,7 +23,7 @@ module DTK::Client
|
|
23
23
|
def self.install_dependent_modules(module_refs, opts = {})
|
24
24
|
module_refs.each do |module_ref|
|
25
25
|
if module_exists?(module_ref, { :type => :component_module })
|
26
|
-
OsUtil.print("Using module '#{module_ref.namespace}:#{module_ref.module_name}'")
|
26
|
+
OsUtil.print("Using module '#{module_ref.namespace}:#{module_ref.module_name}'" + (module_ref.version.nil? ? "" : " version: #{module_ref.version} "))
|
27
27
|
# If component module is imported, still check to see if it's dependencies are imported
|
28
28
|
find_and_install_component_module_dependency(module_ref, opts.merge(:skip_if_no_remote => true))
|
29
29
|
else
|
@@ -44,6 +44,11 @@ module DTK::Client
|
|
44
44
|
)
|
45
45
|
module_info = rest_get "#{BaseRoute}/remote_module_info", query_string_hash
|
46
46
|
|
47
|
+
# unless version is explicitly provided, use latest version instead of master
|
48
|
+
unless @version
|
49
|
+
@version = module_info.required(:latest_version)
|
50
|
+
end
|
51
|
+
|
47
52
|
git_repo_args = {
|
48
53
|
:repo_dir => target_repo_dir,
|
49
54
|
:repo_url => module_info.required(:remote_repo_url),
|
@@ -31,9 +31,9 @@ module DTK::Client
|
|
31
31
|
:namespace => module_ref.namespace,
|
32
32
|
:version? => module_ref.version
|
33
33
|
)
|
34
|
-
|
34
|
+
rest_post("#{BaseRoute}/delete", post_body)
|
35
35
|
OsUtil.print_info("DTK module '#{module_ref.print_form}' has been deleted successfully.")
|
36
|
-
|
36
|
+
nil
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -25,18 +25,24 @@ module DTK::Client
|
|
25
25
|
|
26
26
|
response = rest_get("#{BaseRoute}/#{service_instance}/repo_info")
|
27
27
|
|
28
|
-
|
28
|
+
repo_info_args = Args.new(
|
29
29
|
:service_instance => service_instance,
|
30
30
|
:commit_message => args[:commit_message] || default_commit_message(service_instance),
|
31
31
|
:branch => response.required(:branch, :name),
|
32
32
|
:repo_url => response.required(:repo, :url)
|
33
|
-
|
33
|
+
)
|
34
34
|
|
35
|
-
response = ClientModuleDir::GitRepo.commit_and_push_to_service_repo(
|
35
|
+
response = ClientModuleDir::GitRepo.commit_and_push_to_service_repo(repo_info_args)
|
36
36
|
commit_sha = response.required(:head_sha)
|
37
37
|
|
38
38
|
response = rest_post("#{BaseRoute}/#{service_instance}/update_from_repo", :commit_sha => commit_sha)
|
39
|
-
|
39
|
+
print_msgs_of_type(:error_msgs, response)
|
40
|
+
print_msgs_of_type(:warning_msgs, response)
|
41
|
+
print_msgs_of_type(:info_msgs, response)
|
42
|
+
|
43
|
+
ClientModuleDir::GitRepo.pull_from_service_repo(repo_info_args) if response.data(:repo_updated)
|
44
|
+
process_backup_files(repo_info_args, response.data(:backup_files))
|
45
|
+
process_semantic_diffs(response.data(:semantic_diffs))
|
40
46
|
nil
|
41
47
|
end
|
42
48
|
end
|
@@ -51,36 +57,37 @@ module DTK::Client
|
|
51
57
|
raise Error, "Need to write"
|
52
58
|
end
|
53
59
|
|
54
|
-
def self.process_response(response, opts = {})
|
55
|
-
print_msgs_of_type(:error_msgs, response)
|
56
|
-
print_msgs_of_type(:warning_msgs, response)
|
57
|
-
print_msgs_of_type(:info_msgs, response)
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
def self.process_backup_files(repo_info_args, backup_files)
|
62
|
+
return if (backup_files || {}).empty?
|
63
|
+
backup_files.each_pair do |path, content|
|
64
|
+
ClientModuleDir::GitRepo.add_service_repo_file(repo_info_args.merge(:path => path, :content => content))
|
65
|
+
end
|
66
|
+
|
67
|
+
backup_file_paths = backup_files.keys
|
68
|
+
update_gitignore?(repo_info_args, backup_file_paths)
|
63
69
|
|
64
|
-
|
65
|
-
ClientModuleDir::GitRepo.pull_from_service_repo(opts[:args]) if response.data(:repo_updated)
|
70
|
+
ClientModuleDir::GitRepo.commit_and_push_to_service_repo(repo_info_args)
|
66
71
|
end
|
67
72
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
73
|
+
GITIGNORE_REL_PATH = '.gitignore'
|
74
|
+
def self.update_gitignore?(repo_info_args, backup_file_paths)
|
75
|
+
response = ClientModuleDir::GitRepo.get_service_repo_file_content(repo_info_args.merge(:path => GITIGNORE_REL_PATH))
|
76
|
+
gitignore_content = response.data(:content) || ''
|
77
|
+
gitignore_files = gitignore_content.split("\n")
|
78
|
+
to_add = ''
|
79
|
+
backup_file_paths.each do |backup_file_path|
|
80
|
+
to_add << "#{backup_file_path}\n" unless gitignore_files.include?(backup_file_path)
|
81
|
+
end
|
82
|
+
unless to_add.empty?
|
83
|
+
gitignore_content << "\n" unless gitignore_content.empty? or gitignore_content[-1] == "\n"
|
84
|
+
gitignore_content << to_add
|
85
|
+
ClientModuleDir::GitRepo.add_service_repo_file(repo_info_args.merge(:path => GITIGNORE_REL_PATH, :content => gitignore_content))
|
86
|
+
end
|
79
87
|
end
|
80
|
-
|
81
|
-
def self.process_semantic_diffs(
|
82
|
-
|
83
|
-
return if semantic_diffs.empty?
|
88
|
+
|
89
|
+
def self.process_semantic_diffs(semantic_diffs)
|
90
|
+
return if (semantic_diffs || {}).empty?
|
84
91
|
# TODO: DTK-2663; cleanup so pretty printed'
|
85
92
|
OsUtil.print_info("\nDiffs that were pushed:")
|
86
93
|
# TODO: get rid of use of STDOUT
|
@@ -91,7 +98,7 @@ module DTK::Client
|
|
91
98
|
PRINT_FN = {
|
92
99
|
:info_msgs => lambda { |msg| OsUtil.print_info(msg) },
|
93
100
|
:warning_msgs => lambda { |msg| OsUtil.print_warning(msg) },
|
94
|
-
:error_msgs
|
101
|
+
:error_msgs => lambda { |msg| OsUtil.print_error(msg) }
|
95
102
|
}
|
96
103
|
def self.print_msgs_of_type(msg_type, response)
|
97
104
|
msgs = response.data(msg_type) || []
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtk-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.0.
|
4
|
+
version: 0.10.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reactor8
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dtk-common-core
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 2.99.3
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: dtk-dsl
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.0.0
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.0.0
|
111
125
|
description: Command line tool to interact with a DTK Server and DTK Service Catalog.
|
112
126
|
email: support@reactor8.com
|
113
127
|
executables:
|
@@ -306,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
306
320
|
version: '0'
|
307
321
|
requirements: []
|
308
322
|
rubyforge_project:
|
309
|
-
rubygems_version: 2.4.
|
323
|
+
rubygems_version: 2.4.6
|
310
324
|
signing_key:
|
311
325
|
specification_version: 4
|
312
326
|
summary: DTK CLI client for DTK server interaction.
|