Module: ChefWorkstationInitialize::SelfBootstrap::NoChef::GitHelpers

Includes:
SSHHelpers
Included in:
BerksHelpers
Defined in:
lib/selfbootstrap/nochef/git.rb

Instance Method Summary collapse

Methods included from SSHHelpers

#delete_hostkey, #delete_hostkey_ip_or_name, #generate_private_key, #ssh, #ssh_command, #ssh_keygen

Methods included from CommandlineHelpers

#base_command, #get_homedir, #is_mixlib_disabled?, #main_command, #run_options

Methods included from DefaultMethodsHelpers

#analyse_object, #check_install_dir, #debug_worklog, #default_chefzero_portrange, #default_hostname, #default_install_dir, #define_resource_requirements, #error_worklog, #generate_default_install_dir, #generate_directory, #get_out_of_cache_path, #get_out_of_folder, #get_out_of_local_chef_path, #get_path, #is_chef_constant_enabled?, #parent_nil?, #require_implement_method, #search_local_project_folder, #warning_worklog, #worklog, #worklog_counter

Instance Method Details

#all_cookbooksObject



56
57
58
59
60
61
62
63
64
65
# File 'lib/selfbootstrap/nochef/git.rb', line 56

def all_cookbooks
  cookbooks_Arr = []
  workstation_resource[:gitinfo]['submodules'].each do |gitname, git_info|
    case git_info['type']
    when 'cookbooks', 'libraries', 'resources'
      cookbooks_Arr.push(gitname)
    end
  end unless parent_nil?(workstation_resource[:gitinfo], 'submodules')
  cookbooks_Arr
end

#generate_git_submodules(modules) ⇒ Object



98
99
100
101
102
103
104
# File 'lib/selfbootstrap/nochef/git.rb', line 98

def generate_git_submodules(modules)
  json_submodules = {}
  modules.each do |module_name, module_info|
    json_submodules[module_name] = { path: get_git_path(module_name), repository: module_info['repository'] }
  end
  json_submodules
end

#generate_json_repo(type, repository, revision = 'master', remote = 'origin', submodule_list = nil, additional_remotes = nil) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/selfbootstrap/nochef/git.rb', line 85

def generate_json_repo(type, repository, revision = 'master', remote = 'origin', submodule_list = nil, additional_remotes = nil)
  json_output = {
    type: type,
    repository: repository,
    revision: revision,
    remote: remote,
    submodules: submodule_list,
    additional_remotes: additional_remotes,
  }
  worklog("Generate json for #{JSON.pretty_generate(json_output)}")
  json_output
end

#get_git_path(gitname) ⇒ Object



77
78
79
# File 'lib/selfbootstrap/nochef/git.rb', line 77

def get_git_path(gitname)
  ::File.join(get_path(workstation_chef_repo_path), get_git_relative_path(gitname))
end

#get_git_relative_path(gitname) ⇒ Object



67
68
69
70
71
72
73
74
75
# File 'lib/selfbootstrap/nochef/git.rb', line 67

def get_git_relative_path(gitname)
  if gitname == project_name
    ''
  elsif workstation_resource[:gitinfo]['submodules'][gitname].nil?
    ''
  else
    ::File.join(workstation_resource[:gitinfo]['submodules'][gitname]['type'], gitname)
  end
end

#get_git_server(git_action) ⇒ Object



33
34
35
# File 'lib/selfbootstrap/nochef/git.rb', line 33

def get_git_server(git_action)
  require_implement_method('get_git_server', %w(git_action))
end

#get_git_submodule(git_name, git_info, action, compile_time) ⇒ Object



29
30
31
# File 'lib/selfbootstrap/nochef/git.rb', line 29

def get_git_submodule(git_name, git_info, action, compile_time)
  require_implement_method('get_git_submodule', %w(git_name git_info action compile_time))
end

#get_self_git(action, compile_time) ⇒ Object



81
82
83
# File 'lib/selfbootstrap/nochef/git.rb', line 81

def get_self_git(action, compile_time)
  get_git_submodule(project_name, workstation_resource[:gitinfo], action, compile_time)
end

#git_exec(*args, **run_opts) ⇒ Object



37
38
39
# File 'lib/selfbootstrap/nochef/git.rb', line 37

def git_exec(*args, **run_opts)
  base_command('git', args, run_opts)
end

#git_submodule_initObject



41
42
43
44
# File 'lib/selfbootstrap/nochef/git.rb', line 41

def git_submodule_init
  git_exec('submodule' + 'init')
  git_exec('submodule' + 'update')
end

#repository_listObject



46
47
48
49
50
51
52
53
54
# File 'lib/selfbootstrap/nochef/git.rb', line 46

def repository_list
  if parent_nil?(workstation_resource, 'gitinfo', 'submodules')
    worklog('Use default repository')
    [project_name, "#{project_name}_generator", new_cookbook_name]
  else
    worklog("workstation_resource[:gitinfo][\"submodules\"] = #{JSON.pretty_generate(workstation_resource[:gitinfo]['submodules'])}")
    [project_name, "#{project_name}_generator", new_cookbook_name] + workstation_resource[:gitinfo]['submodules'].keys
  end
end