File: upgrader.rb

package info (click to toggle)
puppet-agent 8.10.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,404 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (64 lines) | stat: -rw-r--r-- 2,633 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# frozen_string_literal: true

module Puppet::ModuleTool::Errors
  class UpgradeError < ModuleToolError
    def initialize(msg)
      @action = :upgrade
      super
    end
  end

  class VersionAlreadyInstalledError < UpgradeError
    attr_reader :newer_versions

    def initialize(options)
      @module_name       = options[:module_name]
      @requested_version = options[:requested_version]
      @installed_version = options[:installed_version]
      @dependency_name   = options[:dependency_name]
      @newer_versions    = options[:newer_versions]
      @possible_culprits = options[:possible_culprits]
      super _("Could not upgrade '%{module_name}'; more recent versions not found") % { module_name: @module_name }
    end

    def multiline
      message = []
      message << _("Could not upgrade module '%{module_name}' (%{version})") % { module_name: @module_name, version: vstring }
      if @newer_versions.empty?
        message << _("  The installed version is already the latest version matching %{version}") % { version: vstring }
      else
        message << _("  There are %{count} newer versions") % { count: @newer_versions.length }
        message << _("    No combination of dependency upgrades would satisfy all dependencies")
        unless @possible_culprits.empty?
          message << _("    Dependencies will not be automatically upgraded across major versions")
          message << _("    Upgrading one or more of these modules may permit the upgrade to succeed:")
          @possible_culprits.each do |name|
            message << "    - #{name}"
          end
        end
      end
      # TRANSLATORS `puppet module upgrade --force` is a command line option that should not be translated
      message << _("    Use `puppet module upgrade --force` to upgrade only this module")
      message.join("\n")
    end
  end

  class DowngradingUnsupportedError < UpgradeError
    def initialize(options)
      @module_name = options[:module_name]
      @requested_version = options[:requested_version]
      @installed_version = options[:installed_version]
      @conditions        = options[:conditions]
      @action            = options[:action]

      super _("Could not %{action} '%{module_name}' (%{version}); downgrades are not allowed") % { action: @action, module_name: @module_name, version: vstring }
    end

    def multiline
      message = []
      message << _("Could not %{action} module '%{module_name}' (%{version})") % { action: @action, module_name: @module_name, version: vstring }
      message << _("  Downgrading is not allowed.")
      message.join("\n")
    end
  end
end