dtk-client 0.9.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/Gemfile +1 -3
- data/README.md +2 -121
- data/Rakefile +44 -0
- data/bin/dtk +10 -88
- data/dtk-client.gemspec +21 -44
- data/examples/simple/dtk.module.yaml +32 -0
- data/{lib/git-logs/git.log → examples/simple/test/README.md} +0 -0
- data/examples/spark/dtk.module.yaml +120 -0
- data/examples/with_repo_content/deploy/puppet/manifests/hostname.pp +54 -0
- data/examples/with_repo_content/dtk.module.yaml +49 -0
- data/examples/with_repo_content/test/README.txt +0 -0
- data/features/dtk.feature +8 -0
- data/features/step_definitions/dtk_steps.rb +6 -0
- data/features/support/env.rb +15 -0
- data/lib/cli/command/mixin.rb +101 -0
- data/lib/cli/command/module/clone.rb +42 -0
- data/lib/cli/command/module/install.rb +52 -0
- data/lib/cli/command/module/list.rb +31 -0
- data/lib/cli/command/module/list_assemblies.rb +39 -0
- data/lib/cli/command/module/push.rb +34 -0
- data/lib/cli/command/module/uninstall.rb +46 -0
- data/lib/cli/command/module.rb +33 -0
- data/lib/cli/command/options.rb +33 -0
- data/lib/cli/command/service/cancel_task.rb +33 -0
- data/lib/cli/command/service/converge.rb +37 -0
- data/lib/{parser/adapters/thor/common_option_defs.rb → cli/command/service/create_workspace.rb} +13 -17
- data/lib/cli/command/service/destroy.rb +47 -0
- data/lib/cli/command/service/edit.rb +47 -0
- data/lib/cli/command/service/exec.rb +42 -0
- data/lib/cli/command/service/exec_sync.rb +53 -0
- data/lib/cli/command/service/list.rb +30 -0
- data/lib/cli/command/service/list_actions.rb +39 -0
- data/lib/cli/command/service/list_attributes.rb +44 -0
- data/lib/cli/command/service/list_component_links.rb +33 -0
- data/lib/cli/command/service/list_components.rb +39 -0
- data/lib/cli/command/service/list_dependent_modules.rb +33 -0
- data/lib/cli/command/service/list_nodes.rb +33 -0
- data/lib/cli/command/service/list_violations.rb +33 -0
- data/lib/cli/command/service/pull.rb +32 -0
- data/lib/cli/command/service/push.rb +37 -0
- data/lib/{shell/parse_monkey_patch.rb → cli/command/service/set_default_target.rb} +9 -17
- data/lib/cli/command/service/set_required_attributes.rb +32 -0
- data/lib/cli/command/service/ssh.rb +42 -0
- data/lib/cli/command/service/stage.rb +55 -0
- data/lib/cli/command/service/start.rb +33 -0
- data/lib/{shell/context_aux.rb → cli/command/service/stop.rb} +10 -23
- data/lib/cli/command/service/task_status.rb +39 -0
- data/lib/cli/command/service.rb +55 -0
- data/lib/{commands.rb → cli/command/subcommand.rb} +22 -25
- data/lib/{bundler_monkey_patch.rb → cli/command/token/arg.rb} +6 -6
- data/lib/cli/command/token/class_mixin.rb +96 -0
- data/lib/cli/command/token/flag.rb +42 -0
- data/lib/{execute/command/rest_call.rb → cli/command/token/mixin.rb} +23 -14
- data/lib/cli/command/token/switch.rb +35 -0
- data/lib/cli/command/token.rb +76 -0
- data/lib/cli/command.rb +46 -0
- data/lib/cli/context/attributes.rb +50 -0
- data/lib/cli/context/type/module.rb +34 -0
- data/lib/{commands/thor/state_change.rb → cli/context/type/service.rb} +11 -5
- data/lib/cli/context/type/top.rb +32 -0
- data/lib/cli/context/type.rb +42 -0
- data/lib/cli/context.rb +174 -0
- data/lib/cli/directory_parser/file_system.rb +105 -0
- data/lib/{execute/command.rb → cli/directory_parser.rb} +14 -17
- data/lib/{execute.rb → cli/file_obj.rb} +13 -9
- data/lib/cli/processor/plugin/gli.rb +70 -0
- data/lib/cli/processor.rb +60 -0
- data/lib/cli/runner/dtkn_access.rb +75 -0
- data/lib/cli/runner.rb +58 -0
- data/lib/cli/version.rb +8 -0
- data/lib/{config → client/config}/cacert.pem +0 -0
- data/lib/client/config/default.conf +20 -0
- data/lib/client/config.rb +106 -0
- data/lib/client/configurator.rb +182 -0
- data/lib/client/conn.rb +197 -0
- data/lib/client/content_generator.rb +127 -0
- data/lib/client/error/subclasses.rb +105 -0
- data/lib/client/error.rb +98 -0
- data/lib/client/git_repo/adapter/git_gem/error_handler.rb +70 -0
- data/lib/client/git_repo/adapter/git_gem.rb +179 -0
- data/lib/client/git_repo.rb +122 -0
- data/lib/client/logger.rb +136 -0
- data/lib/client/operation/account.rb +66 -0
- data/lib/client/operation/client_module_dir/git_repo.rb +286 -0
- data/lib/client/operation/client_module_dir.rb +138 -0
- data/lib/client/operation/module/clone_module.rb +52 -0
- data/lib/client/operation/module/install/common_module.rb +58 -0
- data/lib/client/operation/module/install/external_module.rb +122 -0
- data/lib/client/operation/module/install.rb +91 -0
- data/lib/client/operation/module/install_from_catalog.rb +76 -0
- data/lib/client/operation/module/list.rb +34 -0
- data/lib/client/operation/module/list_assemblies.rb +35 -0
- data/lib/client/operation/module/push.rb +62 -0
- data/lib/client/operation/module/uninstall.rb +44 -0
- data/lib/client/operation/module.rb +58 -0
- data/lib/{commands/common/thor/reparse.rb → client/operation/module_service_common.rb} +27 -16
- data/lib/client/operation/service/cancel_task.rb +29 -0
- data/lib/client/operation/service/commit_and_push.rb +128 -0
- data/lib/client/operation/service/converge.rb +50 -0
- data/lib/{util/common_util.rb → client/operation/service/create_workspace.rb} +13 -13
- data/lib/client/operation/service/destroy.rb +42 -0
- data/lib/client/operation/service/edit.rb +54 -0
- data/lib/client/operation/service/exec.rb +73 -0
- data/lib/client/operation/service/list.rb +32 -0
- data/lib/client/operation/service/list_actions.rb +34 -0
- data/lib/{commands/thor/dependency.rb → client/operation/service/list_attributes.rb} +16 -12
- data/lib/client/operation/service/list_component_links.rb +29 -0
- data/lib/{commands/common/thor/pull_clone_changes.rb → client/operation/service/list_components.rb} +13 -7
- data/lib/client/operation/service/list_dependent_modules.rb +29 -0
- data/lib/client/operation/service/list_nodes.rb +29 -0
- data/lib/{commands/thor/project.rb → client/operation/service/list_violations.rb} +8 -13
- data/lib/client/operation/service/pull.rb +37 -0
- data/lib/client/operation/service/set_default_target.rb +31 -0
- data/lib/client/operation/service/set_required_attributes.rb +41 -0
- data/lib/client/operation/service/ssh.rb +118 -0
- data/lib/client/operation/service/stage.rb +54 -0
- data/lib/client/operation/service/start.rb +29 -0
- data/lib/client/operation/service/stop.rb +30 -0
- data/lib/{task_status → client/operation/service/task_status}/refresh_mode.rb +15 -25
- data/lib/{task_status → client/operation/service/task_status}/snapshot_mode.rb +4 -5
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/format.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result/action.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result/components.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result/node_level.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result.rb +4 -4
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps/action.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps/components.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps/node_level.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps.rb +4 -4
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task.rb +3 -3
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/no_results.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/render.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/stage/render.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/stage.rb +3 -3
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/task_end.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/task_start.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element.rb +13 -13
- data/lib/{task_status → client/operation/service/task_status}/stream_mode.rb +5 -9
- data/lib/client/operation/service/task_status.rb +77 -0
- data/lib/client/operation/service.rb +54 -0
- data/lib/client/operation.rb +67 -0
- data/lib/client/operation_args.rb +40 -0
- data/lib/{execute/execute_context/result_store.rb → client/render/view/simple.rb} +15 -14
- data/lib/client/render/view/table/processor.rb +248 -0
- data/lib/client/render/view/table.rb +75 -0
- data/lib/client/render.rb +113 -0
- data/lib/client/response/error_handler.rb +97 -0
- data/lib/client/response/render_helper.rb +78 -0
- data/lib/client/response/subclasses.rb +62 -0
- data/lib/client/response.rb +83 -0
- data/lib/client/session.rb +62 -0
- data/lib/client/util/auxiliary.rb +34 -0
- data/lib/client/util/console.rb +81 -0
- data/lib/client/util/disk_cacher.rb +66 -0
- data/lib/client/util/dtk_path.rb +28 -0
- data/lib/{search_hash.rb → client/util/hash_with_optional_keys.rb} +29 -21
- data/lib/client/util/interactive_wizard.rb +84 -0
- data/lib/client/util/module_ref.rb +92 -0
- data/lib/client/util/os_util/print.rb +121 -0
- data/lib/client/util/os_util.rb +122 -0
- data/lib/{commands/thor/utils.rb → client/util/post_body.rb} +1 -1
- data/lib/{execute/error_usage.rb → client/util/query_string_hash.rb} +2 -2
- data/lib/client/util/remote_dependency.rb +67 -0
- data/lib/client/util/ssh_util.rb +89 -0
- data/lib/client/util/validation.rb +28 -0
- data/lib/client/util.rb +18 -0
- data/lib/{util/permission_util.rb → dtk_cli.rb} +10 -9
- data/lib/dtk_client.rb +18 -14
- data/test/default_test.rb +14 -0
- data/test/test_helper.rb +9 -0
- metadata +196 -307
- data/Gemfile_dev +0 -13
- data/bin/dtk-execute +0 -32
- data/bin/dtk-shell +0 -31
- data/lib/auxiliary.rb +0 -61
- data/lib/client.rb +0 -58
- data/lib/command_helper.rb +0 -33
- data/lib/command_helpers/git_repo/merge.rb +0 -153
- data/lib/command_helpers/git_repo.rb +0 -589
- data/lib/command_helpers/jenkins_client/config_xml.rb +0 -288
- data/lib/command_helpers/jenkins_client.rb +0 -106
- data/lib/command_helpers/service_importer.rb +0 -251
- data/lib/command_helpers/service_link.rb +0 -33
- data/lib/command_helpers/test_module_creator.rb +0 -69
- data/lib/command_helpers/test_module_templates/dtk.model.yaml.eruby +0 -10
- data/lib/command_helpers/test_module_templates/spec_helper.rb.eruby +0 -10
- data/lib/command_helpers/test_module_templates/temp_component_spec.rb.eruby +0 -5
- data/lib/commands/common/thor/access_control.rb +0 -133
- data/lib/commands/common/thor/action_result_handler.rb +0 -74
- data/lib/commands/common/thor/assembly_template.rb +0 -92
- data/lib/commands/common/thor/assembly_workspace.rb +0 -1638
- data/lib/commands/common/thor/base_command_helper.rb +0 -59
- data/lib/commands/common/thor/clone.rb +0 -82
- data/lib/commands/common/thor/common.rb +0 -88
- data/lib/commands/common/thor/common_base.rb +0 -49
- data/lib/commands/common/thor/create_target.rb +0 -70
- data/lib/commands/common/thor/edit.rb +0 -255
- data/lib/commands/common/thor/inventory_parser.rb +0 -98
- data/lib/commands/common/thor/list_diffs.rb +0 -128
- data/lib/commands/common/thor/module/import.rb +0 -215
- data/lib/commands/common/thor/module.rb +0 -1011
- data/lib/commands/common/thor/node.rb +0 -53
- data/lib/commands/common/thor/poller.rb +0 -65
- data/lib/commands/common/thor/pull_from_remote.rb +0 -152
- data/lib/commands/common/thor/puppet_forge.rb +0 -72
- data/lib/commands/common/thor/purge_clone.rb +0 -101
- data/lib/commands/common/thor/push_clone_changes.rb +0 -162
- data/lib/commands/common/thor/push_to_remote.rb +0 -94
- data/lib/commands/common/thor/remotes.rb +0 -71
- data/lib/commands/common/thor/set_required_attributes.rb +0 -46
- data/lib/commands/thor/account.rb +0 -239
- data/lib/commands/thor/assembly.rb +0 -361
- data/lib/commands/thor/attribute.rb +0 -79
- data/lib/commands/thor/component.rb +0 -70
- data/lib/commands/thor/component_module.rb +0 -501
- data/lib/commands/thor/component_template.rb +0 -174
- data/lib/commands/thor/developer.rb +0 -144
- data/lib/commands/thor/dtk.rb +0 -152
- data/lib/commands/thor/library.rb +0 -125
- data/lib/commands/thor/node.rb +0 -504
- data/lib/commands/thor/node_group.rb +0 -203
- data/lib/commands/thor/node_template.rb +0 -94
- data/lib/commands/thor/provider.rb +0 -233
- data/lib/commands/thor/remotes.rb +0 -49
- data/lib/commands/thor/service.rb +0 -932
- data/lib/commands/thor/service_module.rb +0 -900
- data/lib/commands/thor/target.rb +0 -250
- data/lib/commands/thor/task.rb +0 -116
- data/lib/commands/thor/test_module.rb +0 -310
- data/lib/commands/thor/workspace.rb +0 -698
- data/lib/config/client.conf.header +0 -20
- data/lib/config/configuration.rb +0 -99
- data/lib/config/default.conf +0 -16
- data/lib/config/disk_cacher.rb +0 -80
- data/lib/configurator.rb +0 -176
- data/lib/context_router.rb +0 -44
- data/lib/core.rb +0 -489
- data/lib/domain/git_adapter.rb +0 -412
- data/lib/domain/git_error_handler.rb +0 -64
- data/lib/domain/response/error_handler.rb +0 -86
- data/lib/domain/response.rb +0 -285
- data/lib/dtk-client/version.rb +0 -20
- data/lib/dtk_constants.rb +0 -40
- data/lib/dtk_error.rb +0 -114
- data/lib/dtk_logger.rb +0 -113
- data/lib/error.rb +0 -85
- data/lib/execute/cli_pure/cli_rerouter.rb +0 -102
- data/lib/execute/command/api_call/map.rb +0 -60
- data/lib/execute/command/api_call/service.rb +0 -91
- data/lib/execute/command/api_call/translation_term.rb +0 -119
- data/lib/execute/command/api_call.rb +0 -60
- data/lib/execute/command_processor/rest_call.rb +0 -59
- data/lib/execute/command_processor.rb +0 -30
- data/lib/execute/execute_context.rb +0 -86
- data/lib/execute/script/add_tenant.rb +0 -121
- data/lib/execute/script.rb +0 -64
- data/lib/parser/adapters/option_parser.rb +0 -70
- data/lib/parser/adapters/thor.rb +0 -555
- data/lib/require_first.rb +0 -104
- data/lib/shell/context.rb +0 -1064
- data/lib/shell/domain/active_context.rb +0 -186
- data/lib/shell/domain/context_entity.rb +0 -89
- data/lib/shell/domain/context_params.rb +0 -223
- data/lib/shell/domain/override_tasks.rb +0 -88
- data/lib/shell/domain/shadow_entity.rb +0 -76
- data/lib/shell/header_shell.rb +0 -44
- data/lib/shell/help_monkey_patch.rb +0 -283
- data/lib/shell/interactive_wizard.rb +0 -256
- data/lib/shell/message_queue.rb +0 -63
- data/lib/shell/status_monitor.rb +0 -124
- data/lib/shell.rb +0 -261
- data/lib/task_status.rb +0 -83
- data/lib/util/console.rb +0 -235
- data/lib/util/dtk_puppet.rb +0 -65
- data/lib/util/module_util.rb +0 -66
- data/lib/util/os_util.rb +0 -385
- data/lib/util/remote_dependency_util.rb +0 -84
- data/lib/util/ssh_util.rb +0 -94
- data/lib/view_processor/augmented_simple_list.rb +0 -44
- data/lib/view_processor/hash_pretty_print.rb +0 -123
- data/lib/view_processor/simple_list.rb +0 -156
- data/lib/view_processor/table_print.rb +0 -309
- data/lib/view_processor.rb +0 -129
- data/puppet/manifests/init.pp +0 -72
- data/puppet/manifests/params.pp +0 -16
- data/puppet/r8meta.puppet.yml +0 -35
- data/puppet/templates/bash_profile.erb +0 -2
- data/puppet/templates/client.conf.erb +0 -1
- data/puppet/templates/dtkclient.erb +0 -2
- data/spec/component_module_spec.rb +0 -34
- data/spec/dependency_spec.rb +0 -6
- data/spec/dtk_shell_spec.rb +0 -13
- data/spec/dtk_spec.rb +0 -33
- data/spec/lib/spec_helper.rb +0 -10
- data/spec/lib/spec_thor.rb +0 -108
- data/spec/node_template_spec.rb +0 -24
- data/spec/project_spec.rb +0 -6
- data/spec/repo_spec.rb +0 -7
- data/spec/response_spec.rb +0 -52
- data/spec/service_module_spec.rb +0 -38
- data/spec/service_spec.rb +0 -50
- data/spec/state_change_spec.rb +0 -7
- data/spec/table_print_spec.rb +0 -48
- data/spec/target_spec.rb +0 -57
- data/spec/task_spec.rb +0 -28
- data/views/assembly/augmented_simple_list.rb +0 -12
- data/views/assembly_template/augmented_simple_list.rb +0 -12
- data/views/list_task/augmented_simple_list.rb +0 -12
@@ -0,0 +1,28 @@
|
|
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
|
+
module DtkPath
|
20
|
+
def self.base_dir
|
21
|
+
"#{OsUtil.home_dir}/dtk"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.log_dir
|
25
|
+
base_dir
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -15,30 +15,38 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
|
-
module DTK
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
18
|
+
module DTK::Client
|
19
|
+
class HashWithOptionalKeys < ::Hash
|
20
|
+
def initialize(raw={})
|
21
|
+
super()
|
22
|
+
replace(convert(raw)) unless raw.empty?
|
23
|
+
end
|
24
|
+
|
25
|
+
def merge(raw)
|
26
|
+
super(convert(raw))
|
27
|
+
end
|
28
|
+
|
29
|
+
def merge!(raw)
|
30
|
+
super(convert(raw))
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def convert(raw)
|
36
|
+
raw.inject(Hash.new) do |h,(k,v)|
|
37
|
+
if non_null_var = is_only_non_null_var?(k)
|
38
|
+
v.nil? ? h : h.merge(non_null_var => v)
|
39
|
+
else
|
40
|
+
h.merge(k => v)
|
30
41
|
end
|
31
|
-
order_by =
|
32
|
-
[{
|
33
|
-
:field => col,
|
34
|
-
:order => dir
|
35
|
-
}]
|
36
|
-
self.merge!(:order_by => order_by)
|
37
42
|
end
|
38
|
-
|
39
|
-
|
40
|
-
|
43
|
+
end
|
44
|
+
|
45
|
+
def is_only_non_null_var?(k)
|
46
|
+
if k.to_s =~ /\?$/
|
47
|
+
k.to_s.gsub(/\?$/,'').to_sym
|
41
48
|
end
|
42
49
|
end
|
43
50
|
end
|
44
51
|
end
|
52
|
+
|
@@ -0,0 +1,84 @@
|
|
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 InteractiveWizard
|
20
|
+
require 'readline'
|
21
|
+
|
22
|
+
class << self
|
23
|
+
def resolve_missing_params(param_list, additional_message = nil)
|
24
|
+
begin
|
25
|
+
user_provided_params, checkup_hash = [], {}
|
26
|
+
|
27
|
+
OsUtil.print("\nPlease fill in missing data.")
|
28
|
+
param_list.each do |param_info|
|
29
|
+
description =
|
30
|
+
if param_info['display_name'] =~ Regexp.new(param_info['description'])
|
31
|
+
param_info['display_name']
|
32
|
+
else
|
33
|
+
"#{param_info['display_name']} (#{param_info['description']})"
|
34
|
+
end
|
35
|
+
datatype_info = (param_info['datatype'] ? OsUtil.colorize(" [#{param_info['datatype'].upcase}]", :yellow) : '')
|
36
|
+
string_identifier = OsUtil.colorize(description, :green) + datatype_info
|
37
|
+
|
38
|
+
puts "Please enter #{string_identifier}:"
|
39
|
+
while line = Readline.readline(": ", true)
|
40
|
+
id = param_info['id']
|
41
|
+
user_provided_params << {:id => id, :value => line, :display_name => param_info['display_name']}
|
42
|
+
checkup_hash[id] = {:value => line, :description => description}
|
43
|
+
break
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
# pp print for provided parameters
|
49
|
+
pretty_print_provided_user_info(checkup_hash)
|
50
|
+
|
51
|
+
# make sure this is satisfactory
|
52
|
+
while line = Readline.readline("Is provided information ok? (yes|no) ", true)
|
53
|
+
# start all over again
|
54
|
+
return resolve_missing_params(param_list) if 'no'.eql? line
|
55
|
+
# continue with the code
|
56
|
+
break if 'yes'.eql? line
|
57
|
+
end
|
58
|
+
|
59
|
+
rescue Interrupt => e
|
60
|
+
raise Error::Usage, "You have decided to skip correction wizard.#{additional_message}"
|
61
|
+
end
|
62
|
+
|
63
|
+
return user_provided_params
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def pretty_print_provided_user_info(user_information)
|
69
|
+
OsUtil.print('--------------------------------- DATA ---------------------------------')
|
70
|
+
|
71
|
+
user_information.each do |key,info|
|
72
|
+
description = info[:description]
|
73
|
+
value = info[:value]
|
74
|
+
printf "%48s : %s\n", OsUtil.colorize(description, :green), OsUtil.colorize(value, :yellow)
|
75
|
+
end
|
76
|
+
|
77
|
+
OsUtil.print('------------------------------------------------------------------------')
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
@@ -0,0 +1,92 @@
|
|
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 ModuleRef
|
20
|
+
|
21
|
+
attr_reader :namespace, :module_name, :version, :client_dir_path
|
22
|
+
|
23
|
+
# opts can have keys
|
24
|
+
# :namespace
|
25
|
+
# :module_name
|
26
|
+
# :namespace_module_name
|
27
|
+
# :version
|
28
|
+
# :client_dir_path
|
29
|
+
def initialize(opts = {})
|
30
|
+
if opts[:namespace] and opts[:module_name]
|
31
|
+
@namespace = opts[:namespace]
|
32
|
+
@module_name = opts[:module_name]
|
33
|
+
elsif opts[:namespace_module_name]
|
34
|
+
namespace, module_name = NamespaceModuleName.parse(opts[:namespace_module_name])
|
35
|
+
@namespace = namespace
|
36
|
+
@module_name = module_name
|
37
|
+
else
|
38
|
+
raise Error, "Either :module_name and :namespace must be given or :namespace_module_name"
|
39
|
+
end
|
40
|
+
@version = opts[:version]
|
41
|
+
@client_dir_path = opts[:client_dir_path]
|
42
|
+
end
|
43
|
+
|
44
|
+
def print_form
|
45
|
+
NamespaceModuleName.print_form(@namespace, @module_name, :version => @version)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
module NamespaceModuleName
|
51
|
+
PRINT_FORM_DELIM = ':'
|
52
|
+
PARSE_FORM_DELIM = [':', '/']
|
53
|
+
|
54
|
+
# opts can have keys
|
55
|
+
# :version
|
56
|
+
def self.print_form(namespace, module_name, opts = {})
|
57
|
+
ret = "#{namespace}#{PRINT_FORM_DELIM}#{module_name}"
|
58
|
+
if version = opts[:version]
|
59
|
+
ret << "(#{version})"
|
60
|
+
end
|
61
|
+
ret
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.legal_form
|
65
|
+
print_form('NAMESPACE', 'MODULE-NAME')
|
66
|
+
end
|
67
|
+
|
68
|
+
# returns [namespace, module_name] or raises error
|
69
|
+
def self.parse(term)
|
70
|
+
parse?(term) || raise(Error::Usage, illegal_term_msg(term))
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def self.parse?(term)
|
76
|
+
if match_delim = PARSE_FORM_DELIM.find { |delim| term =~ Regexp.new(delim) }
|
77
|
+
split = term.split(match_delim)
|
78
|
+
if split.size == 2
|
79
|
+
namespace = split[0]
|
80
|
+
module_name = split[1]
|
81
|
+
[namespace, module_name]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.illegal_term_msg(term)
|
87
|
+
# TODO: not showing how version can be in this
|
88
|
+
"Illegal term '#{term}' for designating a module with a namespace; legal form is '#{legal_form}'"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,121 @@
|
|
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
|
+
require 'highline'
|
19
|
+
require 'colorize'
|
20
|
+
|
21
|
+
module DTK::Client
|
22
|
+
class OsUtil
|
23
|
+
module PrintMixin
|
24
|
+
# Method will print to STDOUT with given color
|
25
|
+
#
|
26
|
+
# message - String to be colorize and printed
|
27
|
+
# color - Symbol describing the color to be used on STDOUT
|
28
|
+
#
|
29
|
+
def print(message, color = :white)
|
30
|
+
puts colorize(message, color)
|
31
|
+
end
|
32
|
+
|
33
|
+
def print_info(message)
|
34
|
+
print_with_prefix(:info, message, :yellow)
|
35
|
+
end
|
36
|
+
|
37
|
+
def print_warning(message)
|
38
|
+
print_with_prefix(:warning, message, :yellow)
|
39
|
+
end
|
40
|
+
|
41
|
+
def print_error(message)
|
42
|
+
print_with_prefix(:error, message, :red)
|
43
|
+
end
|
44
|
+
|
45
|
+
def put_warning(prefix, text, color)
|
46
|
+
width = HighLine::SystemExtensions.terminal_size[0] - (prefix.length + 1)
|
47
|
+
text_split = wrap(text, width)
|
48
|
+
Kernel.print colorize(prefix, color), " "
|
49
|
+
text_split.lines.each_with_index do |line, index|
|
50
|
+
line = " "*(prefix.length + 1) + line unless index == 0
|
51
|
+
puts line
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Method will convert given string, to string with colorize output
|
56
|
+
#
|
57
|
+
# message - String to be colorized
|
58
|
+
# color - Symbol describing color to be used
|
59
|
+
#
|
60
|
+
# Returns String with colorize output
|
61
|
+
def colorize(message, color)
|
62
|
+
# at the moment we do not support colors in windows
|
63
|
+
((is_windows? || message.nil?) ? message : message.colorize(color))
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def wrap(text, wrap_at)
|
69
|
+
wrapped = [ ]
|
70
|
+
text.each_line do |line|
|
71
|
+
# take into account color escape sequences when wrapping
|
72
|
+
wrap_at = wrap_at + (line.length - actual_length(line))
|
73
|
+
while line =~ /([^\n]{#{wrap_at + 1},})/
|
74
|
+
search = $1.dup
|
75
|
+
replace = $1.dup
|
76
|
+
if index = replace.rindex(" ", wrap_at)
|
77
|
+
replace[index, 1] = "\n"
|
78
|
+
replace.sub!(/\n[ \t]+/, "\n")
|
79
|
+
line.sub!(search, replace)
|
80
|
+
else
|
81
|
+
line[$~.begin(1) + wrap_at, 0] = "\n"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
wrapped << line
|
85
|
+
end
|
86
|
+
wrapped.join
|
87
|
+
end
|
88
|
+
|
89
|
+
def actual_length(string_with_escapes)
|
90
|
+
string_with_escapes.to_s.gsub(/\e\[\d{1,2}m/, "").length
|
91
|
+
end
|
92
|
+
|
93
|
+
def print_with_prefix(prefix, message, color)
|
94
|
+
PrintWithPrefix.print(prefix, message, color)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
module PrintWithPrefix
|
99
|
+
LEFT_DELIM = '['
|
100
|
+
RIGHT_DELIM = ']'
|
101
|
+
def self.print(prefix, message, color)
|
102
|
+
prefix = prefix.to_s
|
103
|
+
# only add prefix if does not have it already
|
104
|
+
if already_has_prefix?(prefix, message)
|
105
|
+
OsUtil.print(message, color)
|
106
|
+
else
|
107
|
+
OsUtil.print(add_prefix(prefix, message), color)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
LEFT_DELIM_AT_BEG_REGEXP = Regexp.new('^' + '\\' + LEFT_DELIM)
|
112
|
+
def self.already_has_prefix?(prefix, message)
|
113
|
+
!!(message =~ LEFT_DELIM_AT_BEG_REGEXP)
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.add_prefix(prefix, message)
|
117
|
+
"#{LEFT_DELIM}#{prefix.upcase}#{RIGHT_DELIM} #{message}"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,122 @@
|
|
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 OsUtil
|
20
|
+
require 'readline'
|
21
|
+
require_relative('os_util/print')
|
22
|
+
extend Auxiliary
|
23
|
+
extend PrintMixin
|
24
|
+
|
25
|
+
def self.home_dir
|
26
|
+
is_windows? ? home_dir__windows : genv(:home)
|
27
|
+
end
|
28
|
+
|
29
|
+
DTK_FOLDER_DIR = 'dtk'
|
30
|
+
def self.dtk_local_folder
|
31
|
+
"#{home_dir}/#{DTK_FOLDER_DIR}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.temp_dir
|
35
|
+
is_windows? ? genv(:temp) : '/tmp'
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.current_dir
|
39
|
+
Dir.getwd
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.which(cmd)
|
43
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
44
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
45
|
+
exts.each { |ext|
|
46
|
+
exe = File.join(path, "#{cmd}#{ext}")
|
47
|
+
return exe if File.executable? exe
|
48
|
+
}
|
49
|
+
end
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.parent_dir(path)
|
54
|
+
parent_dir?(path) || raise(Error::Usage, "Cannot find parent directory of '#{path}'")
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns parent directory; if at root returns nil
|
58
|
+
def self.parent_dir?(path)
|
59
|
+
raise Error.new("Not implemented for windows") if is_windows?
|
60
|
+
ret = File.expand_path('../', path)
|
61
|
+
unless ret == path # meaning at root
|
62
|
+
ret
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.delim
|
67
|
+
is_windows? ? '\\' : '/'
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.edit(file)
|
71
|
+
editor = ENV['EDITOR']
|
72
|
+
if is_windows?
|
73
|
+
raise Error, "Environment variable EDITOR needs to be set; exit dtk-shell, set variable and log back into dtk-shell." unless editor
|
74
|
+
else
|
75
|
+
editor = 'vim' unless editor
|
76
|
+
end
|
77
|
+
|
78
|
+
system("#{editor} #{file}")
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.user_input(message)
|
82
|
+
trap("INT", "SIG_IGN")
|
83
|
+
while line = Readline.readline("#{message}: ",true)
|
84
|
+
unless line.chomp.empty?
|
85
|
+
trap("INT", false)
|
86
|
+
return line
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
DTK_IDENTITY_FILE = 'dtk.pem'
|
92
|
+
def self.dtk_identity_file_location
|
93
|
+
path_to_identity_file = "#{dtk_local_folder}/#{DTK_IDENTITY_FILE}"
|
94
|
+
return path_to_identity_file if File.exists?(path_to_identity_file)
|
95
|
+
print_warning("TIP: You can save your identity file as '#{path_to_identity_file}' and it will be used as default identityfile.")
|
96
|
+
nil
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def self.genv(name)
|
102
|
+
ENV[name.to_s.upcase].gsub(/\\/,'/')
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.is_mac?
|
106
|
+
RUBY_PLATFORM.downcase.include?('darwin')
|
107
|
+
end
|
108
|
+
|
109
|
+
def self.is_windows?
|
110
|
+
RUBY_PLATFORM =~ /mswin|mingw|cygwin/
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.home_dir__windows
|
114
|
+
"#{genv(:homedrive)}#{genv(:homepath)}"
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.is_linux?
|
118
|
+
RUBY_PLATFORM.downcase.include?('linux')
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
|
-
|
19
|
-
class
|
18
|
+
module DTK::Client
|
19
|
+
class QueryStringHash < HashWithOptionalKeys
|
20
20
|
end
|
21
21
|
end
|
@@ -0,0 +1,67 @@
|
|
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
|
+
#
|
19
|
+
# Managment of remote dependencies detection (print warning) or providing data from local resources
|
20
|
+
#
|
21
|
+
module DTK::Client
|
22
|
+
module RemoteDependency
|
23
|
+
class << self
|
24
|
+
def print_dependency_warnings(response, success_msg = nil, opts = {})
|
25
|
+
are_there_warnings = false
|
26
|
+
return are_there_warnings if response.nil? || response.data.nil?
|
27
|
+
|
28
|
+
warnings = response.data['dependency_warnings']
|
29
|
+
if warnings && !warnings.empty?
|
30
|
+
if opts[:ignore_permission_warnings]
|
31
|
+
warnings.delete_if { |warning| warning['error_type'].eql?('no_permission') }
|
32
|
+
return if warnings.empty?
|
33
|
+
end
|
34
|
+
print_out "Following warnings have been detected for current module by Repo Manager:\n"
|
35
|
+
warnings.each { |w| print_out(" - #{w['message']}") }
|
36
|
+
puts
|
37
|
+
are_there_warnings = true
|
38
|
+
end
|
39
|
+
print_out success_msg, :green if success_msg
|
40
|
+
are_there_warnings
|
41
|
+
end
|
42
|
+
|
43
|
+
def check_permission_warnings(response)
|
44
|
+
errors = ''
|
45
|
+
dependency_warnings = response.data['dependency_warnings']
|
46
|
+
|
47
|
+
if dependency_warnings && !dependency_warnings.empty?
|
48
|
+
no_permissions = dependency_warnings.select { |warning| warning['error_type'].eql?('no_permission') }
|
49
|
+
|
50
|
+
unless no_permissions.empty?
|
51
|
+
errors << "\n\nYou do not have (R) permissions for modules:\n\n"
|
52
|
+
no_permissions.each { |np| errors << " - #{np['module_namespace']}:#{np['module_name']} (owner: #{np['module_owner']})\n" }
|
53
|
+
errors << "\nPlease contact owner(s) to change permissions for those modules."
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
raise Error, errors unless errors.empty?
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def print_out(message, color=:yellow)
|
63
|
+
DTK::Client::OsUtil.print(message, color)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,89 @@
|
|
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
|
+
module SSHUtil
|
20
|
+
def self.read_and_validate_pub_key(path_to_pub_key)
|
21
|
+
is_ssh_key_path_valid?(path_to_pub_key)
|
22
|
+
rsa_pub_key = File.open(path_to_pub_key) { |f| f.read }
|
23
|
+
is_ssh_key_content_valid?(rsa_pub_key)
|
24
|
+
rsa_pub_key
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.update_ssh_known_hosts(server_dns,server_fingerprint)
|
28
|
+
known_hosts_path = ssh_known_hosts_path
|
29
|
+
if File.file?(known_hosts_path)
|
30
|
+
`ssh-keygen -f #{known_hosts_path} -R #{server_dns} 2> /dev/null`
|
31
|
+
File.open(known_hosts_path,"a"){|f|f << server_fingerprint}
|
32
|
+
else
|
33
|
+
ssh_base_dir = ssh_base_dir()
|
34
|
+
unless File.directory?(ssh_base_dir)
|
35
|
+
Dir.mkdir(ssh_base_dir)
|
36
|
+
end
|
37
|
+
File.open(known_hosts_path,"w"){|f|f << server_fingerprint}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.default_rsa_pub_key_path
|
42
|
+
"#{ssh_base_dir}/id_rsa.pub"
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.rsa_pub_key_content
|
46
|
+
path_to_key = self.default_rsa_pub_key_path
|
47
|
+
unless File.file?(path_to_key)
|
48
|
+
raise Error,"No File found at (#{path_to_key}). Path is wrong or it is necessary to generate the public rsa key (e.g., run ssh-keygen -t rsa)"
|
49
|
+
end
|
50
|
+
|
51
|
+
content = File.open(path_to_key){ |f| f.read }
|
52
|
+
content.chomp
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.ssh_reachable?(user, server, timeout = 3)
|
56
|
+
output = `ssh -o ConnectTimeout=#{timeout} -o \"StrictHostKeyChecking no\" -o \"UserKnownHostsFile /dev/null\" -q #{user}@#{server} exit; echo $?`
|
57
|
+
|
58
|
+
# if response 0 than it is able to connect
|
59
|
+
"0".eql?(output.strip)
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def self.ssh_base_dir
|
65
|
+
"#{OsUtil.home_dir}/.ssh"
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.ssh_known_hosts_path
|
69
|
+
"#{ssh_base_dir}/known_hosts"
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.is_ssh_key_path_valid?(path_to_key)
|
73
|
+
unless path_to_key.include?(".pub")
|
74
|
+
raise Error, "[ERROR] Invalid public key file path (#{path_to_key}). Please provide valid path and try again."
|
75
|
+
end
|
76
|
+
|
77
|
+
unless File.exists?(path_to_key)
|
78
|
+
raise Error, "[ERROR] Not able to find provided key (#{path_to_key}). Please provide valid path and try again."
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.is_ssh_key_content_valid?(rsa_pub_key)
|
83
|
+
# checking know ssh rsa pub key content
|
84
|
+
if(rsa_pub_key.empty? || !rsa_pub_key.include?("AAAAB3NzaC1yc2EA"))
|
85
|
+
raise Error, "[ERROR] SSH public key (#{path_to_key}) does not have valid content. Please check your key and try again."
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|