Method: Vagrant::Config::V2::Loader.upgrade

Defined in:
lib/vagrant/config/v2/loader.rb

.upgrade(old) ⇒ Array

Upgrade a V1 configuration to a V2 configuration. We do this by creating a V2 configuration, and calling “upgrade” on each of the V1 configurations, expecting them to set the right settings on the new root.

Parameters:

Returns:

  • (Array)

    A 3-tuple result.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/vagrant/config/v2/loader.rb', line 101

def self.upgrade(old)
  # Get a new root
  root = new_root_object

  # Store the warnings/errors
  warnings = []
  errors   = []

  # Go through the old keys and upgrade them if they can be
  old.__internal_state["keys"].each do |_, old_value|
    if old_value.respond_to?(:upgrade)
      result = old_value.upgrade(root)

      # Sanity check to guard against random return values
      if result.is_a?(Array)
        warnings += result[0]
        errors   += result[1]
      end
    end
  end

  old.__internal_state["missing_key_calls"].to_a.sort.each do |key|
    warnings << I18n.t("vagrant.config.loader.bad_v1_key", :key => key)
  end

  [root, warnings, errors]
end