dtk-client 0.11.8.1 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c1243437980492193969d331349b58e87d20f6c
4
- data.tar.gz: '08e0afe0380f0d2eee56edf002005fb098850c94'
3
+ metadata.gz: a47a56ce9cda25aab4fb83c4941859a6b2939fee
4
+ data.tar.gz: 1f9c0660dde04474cc27df2167157601aaa1e4b2
5
5
  SHA512:
6
- metadata.gz: 1b23957da3a9aa6347e43ed156956fc51773a9deb15b6b8bd45b57c6a4504740a4e0a6afc80e999dbf0a307b40cf5ee9952e9065f0fe4a53186854d879938d3f
7
- data.tar.gz: 8dbbc1ebfba62af5cf4d85815cf62e7c926152ba27eca693d625c858508fd51cc24451ddf258847d8d9d8d6cb6dc2bae1247117dbda4e8d5bdef68315bc06ce3
6
+ metadata.gz: 2e3ea6163e3da2e95a2a9e9e37f435892338bb2d8290d181ac43241e7d5c2b46a5a296b3488aaf1f08f8d18eeb504dbe0e8e8b73715583faaf38e6a2656ee164
7
+ data.tar.gz: 9b61099f14cb4251fe9eab8d7fdb42a0987caf718f07db5130dc94529202fdf3c46d905f640aeff4e20e78738cdd570546a2bf19662a51f505775d82dce9da9a
data/dtk-client.gemspec CHANGED
@@ -17,13 +17,13 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
 
20
- spec.add_dependency 'dtk-common-core','0.11.1.1'
20
+ spec.add_dependency 'dtk-common-core','0.12.0'
21
21
  spec.add_dependency 'gli', '2.13.4'
22
22
  spec.add_dependency 'highline', '1.7.8'
23
23
  spec.add_dependency 'colorize', '0.7.7'
24
24
  spec.add_dependency 'git', '1.2.9'
25
25
  spec.add_dependency 'hirb', '0.7.3'
26
26
  spec.add_dependency 'mime-types', '~> 2.99.3'
27
- spec.add_dependency 'dtk-dsl', '1.1.3'
28
- spec.add_dependency 'dtk-network-client', '1.0.1.1'
27
+ spec.add_dependency 'dtk-dsl', '~> 1.1.3'
28
+ spec.add_dependency 'dtk-network-client', '1.0.2'
29
29
  end
@@ -251,6 +251,7 @@ module DTK::Client
251
251
  rescue Exception => e
252
252
  # if does not exist on repoman try getting version from server
253
253
  versions = get_versions_from_server(module_ref)
254
+ raise e if versions.empty?
254
255
  end
255
256
 
256
257
  if versions.empty?
@@ -0,0 +1,37 @@
1
+ #
2
+ # Copyright (C) 2010-2016 dtk contributors
3
+ #
4
+ # This file is part of the dtk project.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module DTK::Client; module CLI
19
+ module Command
20
+ module Service
21
+ subcommand_def 'add' do |c|
22
+ command_body c, 'add', 'Add service instance content' do |sc|
23
+ sc.flag Token.path, :desc => "supported paths are 'dependencies/name', 'components/name', 'actions/name'"
24
+ sc.flag Token.relative_path, :desc => "Relative path of file to edit in service instance content"
25
+ sc.action do |_global_options, options, _args|
26
+ args = {
27
+ service_instance: service_instance_in_options_or_context(options),
28
+ path: options[:path],
29
+ relative_path: options[:relative_path]
30
+ }
31
+ Operation::Service.add(args)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end; end
@@ -20,14 +20,15 @@ module DTK::Client; module CLI
20
20
  module Service
21
21
  subcommand_def 'delete' do |c|
22
22
  command_body c, :delete, 'Destroys the running infrastructure associated with the service instance' do |sc|
23
- sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory associated; not needed if executed in service instance directory'
23
+ sc.flag Token.directory_path, :desc => 'Absolute or relative path to service instance directory associated; not needed if executed in service instance directory'
24
+ # sc.flag Token.path, :desc => "Delete specific part of service instance. Supported paths are 'dependencies/[name]', 'components/[name]', 'actions/[name]'"
25
+
24
26
  sc.switch Token.skip_prompt, :desc => 'Skip prompt that checks if user wants to delete the service instance'
25
27
  sc.switch Token.recursive, :desc => 'Delete all service instances staged into specified target'
26
28
  sc.switch Token.force, :desc => 'Ignore changes and destroy the running service instance'
27
- # sc.switch Token.purge, :desc => 'Delete the service instance directory on the client'
29
+
28
30
  sc.action do |_global_options, options, args|
29
31
  directory_path = options[:directory_path]
30
- purge = options[:purge]
31
32
  recursive = options[:recursive]
32
33
  force = options[:f]
33
34
  service_instance = service_instance_in_options_or_context(options)
@@ -37,7 +38,8 @@ module DTK::Client; module CLI
37
38
  :skip_prompt => options[:skip_prompt],
38
39
  :directory_path => directory_path || base_dsl_file_obj.parent_dir,
39
40
  :recursive => recursive,
40
- :force => force
41
+ :force => force,
42
+ # :path => options[:path]
41
43
  }
42
44
  Operation::Service.delete(args)
43
45
  end
@@ -0,0 +1,35 @@
1
+ #
2
+ # Copyright (C) 2010-2016 dtk contributors
3
+ #
4
+ # This file is part of the dtk project.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module DTK::Client; module CLI
19
+ module Command
20
+ module Service
21
+ subcommand_def 'describe' do |c|
22
+ command_body c, 'describe', 'Describe service instance content' do |sc|
23
+ sc.flag Token.path, :desc => "supported paths are 'dependencies', 'components/[name]', 'actions/[name]' "
24
+ sc.action do |_global_options, options, _args|
25
+ args = {
26
+ service_instance: service_instance_in_options_or_context(options),
27
+ path: options[:path]
28
+ }
29
+ Operation::Service.describe(args)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end; end
@@ -51,7 +51,9 @@ module DTK::Client
51
51
  # 'stop',
52
52
 
53
53
  'task-status',
54
- 'uninstall'
54
+ 'uninstall',
55
+ 'describe'
56
+ # 'add'
55
57
  ]
56
58
 
57
59
  command_def :desc => 'Subcommands for creating and interacting with DTK service instances'
@@ -52,6 +52,7 @@ module DTK::Client
52
52
  :format => Flag.new(:format, 'FORMAT', 'Choose in which format to display data (ex. TABLE, YAML)'),
53
53
  :sleep => Flag.new(:sleep, '', ''),
54
54
  :attempts => Flag.new(:attempts, '', ''),
55
+ :path => Flag.new(:path, 'PATH', 'Path'),
55
56
 
56
57
  # switches
57
58
  # Switch constructor args order: key, desc, opts={}
data/lib/cli/context.rb CHANGED
@@ -124,7 +124,8 @@ module DTK::Client
124
124
 
125
125
  def service_instance_from_base_dsl_file?
126
126
  #raise_error_when_missing_context(:service_instance) unless base_dsl_file_obj.file_type == DTK::DSL::FileType::ServiceInstance::DSLFile::Top
127
- base_dsl_file_obj.file_type == DTK::DSL::FileType::ServiceInstance::DSLFile::Top
127
+ # base_dsl_file_obj.file_type == DTK::DSL::FileType::ServiceInstance::DSLFile::Top
128
+ base_dsl_file_obj.file_type == DTK::DSL::FileType::ServiceInstance::DSLFile::Top::Hidden
128
129
  parse_conent_and_ret_service_name
129
130
  end
130
131
 
@@ -164,7 +165,8 @@ module DTK::Client
164
165
  FILE_TYPES =
165
166
  [
166
167
  ::DTK::DSL::FileType::CommonModule::DSLFile::Top,
167
- ::DTK::DSL::FileType::ServiceInstance::DSLFile::Top
168
+ ::DTK::DSL::FileType::ServiceInstance::DSLFile::Top,
169
+ ::DTK::DSL::FileType::ServiceInstance::DSLFile::Top::Hidden
168
170
  ]
169
171
 
170
172
  def module_ref_object_from_options_or_context?(options, module_refs_opts = {})
@@ -91,7 +91,7 @@ module DTK::Client; module CLI
91
91
  # returns an array of strings that are file paths; except bakup files (e.g. bak.dtk.service.yaml)
92
92
  def matching_file_paths(dir_path, path_info)
93
93
  return [] if File.exist?("#{dir_path}/.nested_module")
94
- Dir.glob("#{dir_path}/*").select { |file_path| File.file?(file_path) and !is_backup_file?(file_path) and path_info.matches?(file_path) }
94
+ Dir.glob("#{dir_path}/*", File::FNM_DOTMATCH).select { |file_path| File.file?(file_path) and !is_backup_file?(file_path) and path_info.matches?(file_path) }
95
95
  end
96
96
 
97
97
  def is_backup_file?(file_path)
@@ -126,7 +126,8 @@ module DTK::Client; module CLI
126
126
  def self.ranking_for_types
127
127
  @ranking_for_types ||= {
128
128
  DTK::DSL::FileType::CommonModule::DSLFile::Top => 2,
129
- DTK::DSL::FileType::ServiceInstance::DSLFile::Top => 1
129
+ DTK::DSL::FileType::ServiceInstance::DSLFile::Top => 1,
130
+ DTK::DSL::FileType::ServiceInstance::DSLFile::Top::Hidden => 0
130
131
  }
131
132
  end
132
133
 
@@ -137,7 +138,8 @@ module DTK::Client; module CLI
137
138
  def self.input_types
138
139
  {
139
140
  'module' => DTK::DSL::FileType::CommonModule::DSLFile::Top,
140
- 'service' => DTK::DSL::FileType::ServiceInstance::DSLFile::Top
141
+ 'service' => DTK::DSL::FileType::ServiceInstance::DSLFile::Top::Hidden
142
+ # 'service' => DTK::DSL::FileType::ServiceInstance::DSLFile::Top
141
143
  }
142
144
  end
143
145
  end
data/lib/cli/version.rb CHANGED
@@ -18,7 +18,7 @@
18
18
  module DTK
19
19
  module Client
20
20
  module CLI
21
- VERSION="0.11.8.1"
21
+ VERSION="0.12.0"
22
22
  end
23
23
  end
24
24
  end
@@ -72,19 +72,6 @@ module DTK::Client
72
72
  raise Error::Usage, "Module '#{@base_module_ref.print_form}' exists already"
73
73
  end
74
74
 
75
- # unless dependent_modules.empty?
76
- # begin
77
- # if @has_remote_repo
78
- # DependentModules.install(@base_module_ref, dependent_modules, opts)
79
- # else
80
- # DependentModules.install_with_local(@base_module_ref, dependent_modules, opts)
81
- # end
82
- # rescue TerminateInstall
83
- # @print_helper.print_terminated_installation
84
- # return nil
85
- # end
86
- # end
87
-
88
75
  @print_helper.print_continuation_installing_base_module
89
76
 
90
77
  base_path = @base_module_ref.client_dir_path || @file_obj.parent_dir?
@@ -0,0 +1,35 @@
1
+ #
2
+ # Copyright (C) 2010-2016 dtk contributors
3
+ #
4
+ # This file is part of the dtk project.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module DTK::Client
19
+ class Operation::Service
20
+ class Add < self
21
+ def self.execute(args = Args.new)
22
+ wrap_operation(args) do |args|
23
+ service_instance = args.required(:service_instance)
24
+ path = args.required(:path)
25
+ relative_path = args.required(:relative_path)
26
+
27
+ content = yaml_to_hash(FileHelper.get_content?(relative_path))
28
+
29
+ query_string_hash = QueryStringHash.new(:service_instance => service_instance, path: path, content: content)
30
+ rest_post "#{BaseRoute}/add_by_path", query_string_hash
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -20,25 +20,29 @@ module DTK::Client
20
20
  class Delete < self
21
21
  def self.execute(args = Args.new)
22
22
  wrap_operation(args) do |args|
23
- service_instance = args.required(:service_instance)
23
+ @service_instance = args.required(:service_instance)
24
24
  recursive = args.required(:recursive)
25
25
  force = args[:force]
26
26
  directory_path = args[:directory_path]
27
27
 
28
- unless args[:skip_prompt]
29
- return false unless Console.prompt_yes_no("Are you sure you want to delete the content of service instance '#{service_instance}' ?", :add_options => true)
30
- end
28
+ if path = args[:path]
29
+ delete_service_path(path)
30
+ else
31
+ unless args[:skip_prompt]
32
+ return false unless Console.prompt_yes_no("Are you sure you want to delete the content of service instance '#{@service_instance}' ?", :add_options => true)
33
+ end
31
34
 
32
- error_msg = "To allow delete to go through, invoke 'dtk push' to push the changes to server before invoking delete again"
33
- GitRepo.modified_with_diff?(directory_path || @module_ref.client_dir_path, { :error_msg => error_msg, :command => 'delete' }) unless force
34
- post_body = PostBody.new(
35
- :service_instance => service_instance,
36
- :recursive? => recursive
37
- )
38
- response = rest_post("#{BaseRoute}/delete", post_body)
35
+ error_msg = "To allow delete to go through, invoke 'dtk push' to push the changes to server before invoking delete again"
36
+ GitRepo.modified_with_diff?(directory_path || @module_ref.client_dir_path, { :error_msg => error_msg, :command => 'delete' }) unless force
37
+ post_body = PostBody.new(
38
+ :service_instance => @service_instance,
39
+ :recursive? => recursive
40
+ )
41
+ response = rest_post("#{BaseRoute}/delete", post_body)
39
42
 
40
- OsUtil.print_info("Delete procedure started. For more information use 'dtk task-status'.")
41
- display_node_info(response.data)
43
+ OsUtil.print_info("Delete procedure started. For more information use 'dtk task-status'.")
44
+ display_node_info(response.data)
45
+ end
42
46
  end
43
47
  end
44
48
 
@@ -53,8 +57,16 @@ module DTK::Client
53
57
  end
54
58
  end
55
59
 
56
- end
57
- end
58
- end
60
+ def self.delete_service_path(path)
61
+ return false unless Console.prompt_yes_no("Are you sure you want to delete '#{path}' ?", :add_options => true)
59
62
 
63
+ post_body = PostBody.new(
64
+ :service_instance => @service_instance,
65
+ :path => path
66
+ )
67
+ rest_post("#{BaseRoute}/delete_by_path", post_body)
68
+ end
60
69
 
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,33 @@
1
+ #
2
+ # Copyright (C) 2010-2016 dtk contributors
3
+ #
4
+ # This file is part of the dtk project.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module DTK::Client
19
+ class Operation::Service
20
+ class Describe < self
21
+ def self.execute(args = Args.new)
22
+ wrap_operation(args) do |args|
23
+ service_instance = args.required(:service_instance)
24
+ path = args[:path]
25
+ query_string_hash = QueryStringHash.new
26
+
27
+ query_string_hash.merge!(path: path) if path
28
+ rest_get "#{BaseRoute}/#{service_instance}/describe", query_string_hash
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -46,7 +46,9 @@ module DTK::Client
46
46
  :start,
47
47
  :stop,
48
48
  :task_status,
49
- :uninstall
49
+ :uninstall,
50
+ :describe,
51
+ :add
50
52
  ]
51
53
  OPERATIONS.each { |operation| require_relative("service/#{operation}") }
52
54
 
@@ -30,5 +30,9 @@ module DTK::Client
30
30
  def hash_to_yaml(hash_content)
31
31
  YAML.dump(hash_content)
32
32
  end
33
+
34
+ def yaml_to_hash(yaml_content)
35
+ YAML.load(yaml_content)
36
+ end
33
37
  end
34
38
  end
@@ -0,0 +1,7 @@
1
+ module DTK::Client
2
+ module FileHelper
3
+ def self.get_content?(file_path)
4
+ File.open(file_path).read if file_path && File.exists?(file_path)
5
+ end
6
+ end
7
+ end
data/lib/client/util.rb CHANGED
@@ -31,4 +31,5 @@ module DTK
31
31
  require_relative('util/query_string_hash')
32
32
  require_relative('util/interactive_wizard')
33
33
  require_relative('util/validation')
34
+ require_relative('util/file_helper')
34
35
  end
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.11.8.1
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reactor8
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-23 00:00:00.000000000 Z
11
+ date: 2018-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dtk-common-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.11.1.1
19
+ version: 0.12.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.11.1.1
26
+ version: 0.12.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: gli
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -112,14 +112,14 @@ dependencies:
112
112
  name: dtk-dsl
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '='
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: 1.1.3
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '='
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 1.1.3
125
125
  - !ruby/object:Gem::Dependency
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - '='
130
130
  - !ruby/object:Gem::Version
131
- version: 1.0.1.1
131
+ version: 1.0.2
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - '='
137
137
  - !ruby/object:Gem::Version
138
- version: 1.0.1.1
138
+ version: 1.0.2
139
139
  description: Command line tool to interact with a DTK Server and DTK Service Catalog.
140
140
  email: support@reactor8.com
141
141
  executables:
@@ -194,11 +194,13 @@ files:
194
194
  - lib/cli/command/module/update.rb
195
195
  - lib/cli/command/options.rb
196
196
  - lib/cli/command/service.rb
197
+ - lib/cli/command/service/add.rb
197
198
  - lib/cli/command/service/cancel_task.rb
198
199
  - lib/cli/command/service/clone.rb
199
200
  - lib/cli/command/service/converge.rb
200
201
  - lib/cli/command/service/create_workspace.rb
201
202
  - lib/cli/command/service/delete.rb
203
+ - lib/cli/command/service/describe.rb
202
204
  - lib/cli/command/service/destroy.rb
203
205
  - lib/cli/command/service/edit.rb
204
206
  - lib/cli/command/service/eject.rb
@@ -315,12 +317,14 @@ files:
315
317
  - lib/client/operation/module/update.rb
316
318
  - lib/client/operation/module_service_common.rb
317
319
  - lib/client/operation/service.rb
320
+ - lib/client/operation/service/add.rb
318
321
  - lib/client/operation/service/cancel_task.rb
319
322
  - lib/client/operation/service/clone_service.rb
320
323
  - lib/client/operation/service/commit_and_push.rb
321
324
  - lib/client/operation/service/converge.rb
322
325
  - lib/client/operation/service/create_workspace.rb
323
326
  - lib/client/operation/service/delete.rb
327
+ - lib/client/operation/service/describe.rb
324
328
  - lib/client/operation/service/destroy.rb
325
329
  - lib/client/operation/service/edit.rb
326
330
  - lib/client/operation/service/eject.rb
@@ -387,6 +391,7 @@ files:
387
391
  - lib/client/util/console.rb
388
392
  - lib/client/util/disk_cacher.rb
389
393
  - lib/client/util/dtk_path.rb
394
+ - lib/client/util/file_helper.rb
390
395
  - lib/client/util/hash_with_optional_keys.rb
391
396
  - lib/client/util/interactive_wizard.rb
392
397
  - lib/client/util/os_util.rb
@@ -423,7 +428,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
423
428
  version: '0'
424
429
  requirements: []
425
430
  rubyforge_project:
426
- rubygems_version: 2.6.11
431
+ rubygems_version: 2.4.1
427
432
  signing_key:
428
433
  specification_version: 4
429
434
  summary: DTK CLI client for DTK server interaction.