class DTK::Client::Operation::Module::CloneModule
Attributes
module_ref[R]
target_repo_dir[R]
Public Class Methods
execute(args = Args.new)
click to toggle source
# File lib/client/operation/module/clone_module.rb, line 28 def self.execute(args = Args.new) wrap_operation(args) do |args| module_ref = args.required(:module_ref) target_directory = args[:target_directory] new(module_ref, target_directory).clone_module end end
new(module_ref, target_directory)
click to toggle source
# File lib/client/operation/module/clone_module.rb, line 22 def initialize(module_ref, target_directory) @module_ref = module_ref @target_repo_dir = target_directory || ClientModuleDir.ret_path_with_current_dir(module_ref.module_name) end
Public Instance Methods
clone_module()
click to toggle source
# File lib/client/operation/module/clone_module.rb, line 36 def clone_module unless module_info = module_version_exists?(@module_ref, :remote_info => false, :rsa_pub_key => SSHUtil.rsa_pub_key_content) raise Error::Usage, "DTK module '#{@module_ref.pretty_print}' does not exist on the DTK Server." end # This handles state where a depenent module is just created as a component module and consequently we tell server # to create the common_module tied to it unless module_info.data(:repo) module_info = create_module_repo_from_component_info end branch = module_info.required(:branch, :name) repo_url = module_info.required(:repo, :url) repo_name = module_info.required(:repo, :name) clone_args = { :module_type => :common_module, :repo_url => module_info.required(:repo, :url), :branch => module_info.required(:branch, :name), :module_name => @module_ref.module_name, :repo_dir => @target_repo_dir } ret = ClientModuleDir::GitRepo.clone_module_repo(clone_args) if module_info.data(:component_info) || module_info.data(:service_info) LoadSource.fetch_from_remote(module_info, self) end # OsUtil.print_info("DTK module '#{@module_ref.pretty_print}' has been successfully cloned into '#{ret.required(:target_repo_dir)}'") target_repo_dir = ret.required(:target_repo_dir) # pull_service_info = check_if_pull_needed { target_repo_dir: target_repo_dir # pull_service_info: pull_service_info } end
version()
click to toggle source
# File lib/client/operation/module/clone_module.rb, line 74 def version @module_ref.version end
Private Instance Methods
check_if_pull_needed()
click to toggle source
# File lib/client/operation/module/clone_module.rb, line 88 def check_if_pull_needed query_string_hash = QueryStringHash.new( :module_name => @module_ref.module_name, :namespace => @module_ref.namespace, :rsa_pub_key => SSHUtil.rsa_pub_key_content, :version => version||'master' ) begin remote_module_info = rest_get "#{BaseRoute}/remote_module_info", query_string_hash rescue DTK::Client::Error::ServerNotOkResponse => e # ignore if remote does not exist rescue DTK::Client::Error::Server => error # ignore if remote does not exist end if remote_module_info && remote_module_info.data(:service_info) !module_version_exists?(@module_ref) end end
create_module_repo_from_component_info()
click to toggle source
# File lib/client/operation/module/clone_module.rb, line 80 def create_module_repo_from_component_info rest_post("#{BaseRoute}/create_repo_from_component_info", module_ref_post_body) end
module_ref_post_body()
click to toggle source
# File lib/client/operation/module/clone_module.rb, line 84 def module_ref_post_body self.class.module_ref_post_body(@module_ref) end