Module: DTK::Client::CloneMixin

Extended by:
Console
Includes:
CommonMixin
Included in:
EditMixin, ModuleMixin
Defined in:
lib/commands/common/thor/clone.rb

Constant Summary

Constants included from CommandHelperMixin

DTK::Client::CommandHelperMixin::Loaded

Constants included from ReparseMixin

ReparseMixin::YamlDTKMetaFiles

Instance Method Summary collapse

Methods included from Console

confirmation_prompt, confirmation_prompt_additional_options, confirmation_prompt_multiple_choice, confirmation_prompt_simple, unix_shell, wait_animation

Methods included from CommandHelperMixin

#Helper

Methods included from CommandBase

#get, #get_connection, handle_argument_error, #post, #post_file, #rest_url, #rotate_args

Methods included from ReparseMixin

#reparse_aux

Methods included from PushCloneChangesMixin

#push_clone_changes_aux

Instance Method Details

#clone_aux(module_type, module_id, version, internal_trigger = false, omit_output = false, opts = {}) ⇒ Object

internal_trigger: this flag means that other method (internal) has trigger this.

This will change behaviour of method

module_type: will be :component_module or :service_module



29
30
31
32
33
34
35
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
# File 'lib/commands/common/thor/clone.rb', line 29

def clone_aux(module_type, module_id, version, internal_trigger = false, omit_output = false, opts = {})
  # if version = base do not clone latest, just base
  if version && version.eql?('base')
    version = nil
    opts[:use_latest] = false
  end

  module_name, module_namespace, repo_url, branch, not_ok_response, version = workspace_branch_info(module_type, module_id, version, opts)
  return not_ok_response if not_ok_response

  # clone base version first if not cloned already
  clone_base_aux(module_type, module_id, "#{module_namespace}:#{module_name}") if opts[:use_latest] && version

 # TODO: DTK-2358: comenyed out because causing error in this jira; see if need to put in in revisedform to avoid this error; below is checking wromg thing ( module_location is set to wromg thing to check)
  # module_location = OsUtil.module_location(module_type, "#{module_namespace}:#{module_name}", version)
  # raise DTK::Client::DtkValidationError, "#{module_type.to_s.gsub('_',' ').capitalize} '#{module_name}#{version && "-#{version}"}' already cloned!" if File.directory?(module_location) && !opts[:skip_if_exist_check]

  full_module_name = ModuleUtil.resolve_name(module_name, module_namespace)

  # TODO: should we use instead Helper(:git_repo).create_clone_from_optional_branch
  response = Helper(:git_repo).create_clone_with_branch(module_type,module_name,repo_url,branch,version,module_namespace,opts)

  if response.ok?
    print_name = "Module '#{full_module_name}'"
    print_name << " version '#{version}'" if version
    puts "#{print_name} has been successfully cloned!" unless omit_output
    # when puppet forge import, print successfully imported instead of cloned
    DTK::Client::OsUtil.print("#{print_name} has been successfully imported!", :yellow) if omit_output && opts[:print_imported]
    unless internal_trigger
      if Console.confirmation_prompt("Would you like to edit module now?")
        context_params_for_module = create_context_for_module(full_module_name, module_type)
        return edit(context_params_for_module)
      end
    end
  end

  response
end

#clone_base_aux(module_type, module_id, full_module_name) ⇒ Object

clone base module version



69
70
71
72
73
74
# File 'lib/commands/common/thor/clone.rb', line 69

def clone_base_aux(module_type, module_id, full_module_name)
  base_module_location = OsUtil.module_location(module_type, full_module_name, nil)
  unless File.directory?(base_module_location)
    clone_aux(module_type, module_id, nil, true)
  end
end

#create_context_for_module(full_module_name, module_type) ⇒ Object



76
77
78
79
80
# File 'lib/commands/common/thor/clone.rb', line 76

def create_context_for_module(full_module_name, module_type)
  context_params_for_module = DTK::Shell::ContextParams.new
  context_params_for_module.add_context_to_params(full_module_name, module_type.to_s.gsub!(/\_/,'-').to_sym, full_module_name)
  return context_params_for_module
end