Class: DTK::Network::Client::Command::Pull
- Inherits:
-
DTK::Network::Client::Command
- Object
- DTK::Network::Client::Command
- DTK::Network::Client::Command::Pull
- Defined in:
- lib/client/command/pull.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#construct_remote_url(module_info) ⇒ Object
TODO: move construct_remote_url to helper or mixin and use for all commands when needed.
-
#initialize(module_ref, dependency_tree, options = {}) ⇒ Pull
constructor
A new instance of Pull.
- #pull ⇒ Object
Methods inherited from DTK::Network::Client::Command
Methods included from RestWrapper
#rest_delete, #rest_get, #rest_post
Methods included from Client::PermissionsUtil
Methods included from Util::Tar
Constructor Details
#initialize(module_ref, dependency_tree, options = {}) ⇒ Pull
Returns a new instance of Pull.
4 5 6 7 8 9 10 |
# File 'lib/client/command/pull.rb', line 4 def initialize(module_ref, dependency_tree, = {}) @module_ref = module_ref @dependency_tree = dependency_tree @module_directory = module_ref.repo_dir @options = @parsed_module = [:parsed_module] end |
Class Method Details
.run(module_info, opts = {}) ⇒ Object
12 13 14 15 16 |
# File 'lib/client/command/pull.rb', line 12 def self.run(module_info, opts = {}) module_ref = ModuleRef.new(module_info) dependency_tree = DependencyTree.get_or_create(module_ref, opts.merge(save_to_file: true)) new(module_ref, dependency_tree, opts).pull end |
Instance Method Details
#construct_remote_url(module_info) ⇒ Object
TODO: move construct_remote_url to helper or mixin and use for all commands when needed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/client/command/pull.rb', line 31 def construct_remote_url(module_info) require 'open-uri' if clone_url_http = module_info['meta']['aws']['codecommit']['repository_metadata']['clone_url_http'] = module_info['public_user_meta'] codecommit_data = || Session.get_codecommit_data # codecommit_data = Session.get_codecommit_data service_user_name = codecommit_data['service_specific_credential']['service_user_name'] service_password = codecommit_data['service_specific_credential']['service_password'] encoded_password = URI.encode_www_form_component(service_password) url = nil if match = clone_url_http.match(/^(https:\/\/)(.*)$/) url = "#{match[1]}#{service_user_name}:#{encoded_password}@#{match[2]}" end url else raise "Unable to find codecommit https url" end end |
#pull ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/client/command/pull.rb', line 18 def pull module_info = rest_get('modules/module_info', { name: @module_ref.name, namespace: @module_ref.namespace, version: @module_ref.version.str_version }) remote_url = construct_remote_url(module_info) git_args = Args.new({ repo_dir: @module_directory, branch: @module_ref.version.str_version, remote_url: remote_url, force: @options[:force] }) GitRepo.pull_from_remote(git_args) end |