Exception: Puppet::ModuleTool::Errors::ModuleIsRequiredError

Inherits:
UninstallError show all
Defined in:
lib/puppet/module_tool/errors/uninstaller.rb

Instance Attribute Summary

Attributes inherited from Error

#original

Instance Method Summary collapse

Methods inherited from ModuleToolError

#v, #vstring

Constructor Details

#initialize(options) ⇒ ModuleIsRequiredError

Returns a new instance of ModuleIsRequiredError.



25
26
27
28
29
30
31
32
# File 'lib/puppet/module_tool/errors/uninstaller.rb', line 25

def initialize(options)
  @module_name       = options[:module_name]
  @required_by       = options[:required_by]
  @requested_version = options[:requested_version]
  @installed_version = options[:installed_version]

  super _("Could not uninstall '%{module_name}'; installed modules still depend upon it") % { module_name: @module_name }
end

Instance Method Details

#multilineObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/puppet/module_tool/errors/uninstaller.rb', line 34

def multiline
  message = []
  if @requested_version
    message << _("Could not uninstall module '%{module_name}' (v%{requested_version})") % { module_name: @module_name, requested_version: @requested_version }
  else
    message << _("Could not uninstall module '%{module_name}'") % { module_name: @module_name }
  end
  message << _("  Other installed modules have dependencies on '%{module_name}' (%{version})") % { module_name: @module_name, version: v(@installed_version) }
  message += @required_by.map do |mod|
    _("    '%{module_name}' (%{version}) requires '%{module_dep}' (%{dep_version})") % { module_name: mod['name'], version: v(mod['version']), module_dep: @module_name, dep_version: v(mod['version_requirement']) }
  end
  message << _("    Use `puppet module uninstall --force` to uninstall this module anyway")
  message.join("\n")
end