Class: PDK::Module::Update
Constant Summary
collapse
- GIT_DESCRIBE_PATTERN =
/\A(?<base>.+?)-(?<additional_commits>\d+)-g(?<sha>.+)\Z/.freeze
Instance Attribute Summary
Attributes inherited from Convert
#module_dir, #options
Instance Method Summary
collapse
Methods inherited from Convert
#add_tests!, #add_tests?, #adding_tests?, #available_test_generators, #convert?, #force?, #full_report, #generate_banner, #initialize, invoke, #missing_tests?, #noop?, #print_result, #print_summary, #stage_changes!, #stage_tests!, #summary, #test_generators, #update_manager, #update_metadata
Instance Method Details
#current_version ⇒ Object
55
56
57
|
# File 'lib/pdk/module/update.rb', line 55
def current_version
@current_version ||= describe_ref_to_s(current_template_version)
end
|
45
46
47
48
49
|
# File 'lib/pdk/module/update.rb', line 45
def module_metadata
@module_metadata ||= PDK::Module::Metadata.from_file(File.join(module_dir, 'metadata.json'))
rescue ArgumentError => e
raise PDK::CLI::ExitWithError, e.message
end
|
#new_template_version ⇒ Object
#new_version ⇒ Object
59
60
61
|
# File 'lib/pdk/module/update.rb', line 59
def new_version
@new_version ||= fetch_remote_version(new_template_version)
end
|
#pinned_to_puppetlabs_template_tag? ⇒ Boolean
73
74
75
76
77
78
79
|
# File 'lib/pdk/module/update.rb', line 73
def pinned_to_puppetlabs_template_tag?
return false unless template_uri.puppetlabs_template?
return false unless PDK::Util::Git.tag?(template_uri.bare_uri, template_uri.uri_fragment)
return false if latest_template?
template_uri.uri_fragment == new_template_version
end
|
#run ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/pdk/module/update.rb', line 8
def run
template_uri.uri_fragment = new_template_version
stage_changes!
PDK.logger.debug format('This module is already up to date with version %{version} of the template.', version: new_version) if current_version == new_version
unless update_manager.changes?
PDK::Report.default_target.puts('No changes required.')
return
end
PDK.logger.info(update_message)
print_summary
full_report('update_report.txt') unless update_manager.changes[:modified].empty?
return if noop?
unless force?
message = 'Do you want to continue and make these changes to your module?'
return unless PDK::CLI::Util.prompt_for_yes(message)
end
update_manager.unlink_file('Gemfile.lock')
update_manager.unlink_file(File.join('.bundle', 'config'))
update_manager.sync_changes!
require 'pdk/util/bundler'
PDK::Util::Bundler.ensure_bundle!
print_result 'Update completed'
end
|
#template_uri ⇒ Object
51
52
53
|
# File 'lib/pdk/module/update.rb', line 51
def template_uri
@template_uri ||= PDK::Util::TemplateURI.new(module_metadata.data['template-url'])
end
|