Class: DTK::Client::Operation::Module::CloneModule

Inherits:
DTK::Client::Operation::Module show all
Defined in:
lib/client/operation/module/clone_module.rb

Constant Summary

Constants inherited from DTK::Client::Operation::Module

BaseRoute, MODULE_LOCK, OPERATIONS

Constants inherited from DTK::Client::Operation

TYPES

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DTK::Client::Operation::ModuleServiceCommon::ClassMixin

#method_missing, #respond_to?

Methods included from Auxiliary

#hash_to_yaml, #snake_form, #snake_to_camel_case, #yaml_to_hash

Instance Attribute Details

#module_refObject (readonly)

Returns the value of attribute module_ref.



21
22
23
# File 'lib/client/operation/module/clone_module.rb', line 21

def module_ref
  @module_ref
end

#target_repo_dirObject (readonly)

Returns the value of attribute target_repo_dir.



21
22
23
# File 'lib/client/operation/module/clone_module.rb', line 21

def target_repo_dir
  @target_repo_dir
end

Class Method Details

.execute(args = Args.new) ⇒ Object



28
29
30
31
32
33
34
# 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

Instance Method Details

#clone_moduleObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# 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

#versionObject



74
75
76
# File 'lib/client/operation/module/clone_module.rb', line 74

def version
  @module_ref.version
end