Sha256: bcc1bc98036840f42d730f3b81864fe285c3b7a9595619f3de35ff58f03594e0

Contents?: true

Size: 1.17 KB

Versions: 22

Compression:

Stored size: 1.17 KB

Contents

require "json"

module VagrantPlugins
  module CommandUp
    # Stores metadata information about the box used
    # for the current guest. This allows Vagrant to
    # determine the box currently in use when the
    # Vagrantfile is modified with a new box name or
    # version while the guest still exists.
    class StoreBoxMetadata
      def initialize(app, env)
        @app = app
        @logger = Log4r::Logger.new("vagrant::up::storeboxmetadata")
      end

      def call(env)
        if env[:machine].box
          box = env[:machine].box
          box_meta = {
            name: box.name,
            version: box.version,
            provider: box.provider,
            directory: box.directory.sub(Vagrant.user_data_path.to_s + "/", "")
          }
          meta_file = env[:machine].data_dir.join("box_meta")
          @logger.debug("Writing box metadata file to #{meta_file}")
          File.open(meta_file.to_s, "w+") do |file|
            file.write(JSON.dump(box_meta))
          end
        else
          @logger.debug("No box data found for #{env[:machine].name} with provider #{env[:machine].provider_name}")
        end
        @app.call(env)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/commands/up/middleware/store_box_metadata.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.3.3.0 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.3.2.0 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.2.19.0 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.2.18.0 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.2.16.0 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.2.14.0 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.2.10.0 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.2.9.0 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.2.8.0 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.2.7.0 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.2.6.2 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.2.6.1 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.2.6.0 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.2.5.0 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.2.4.0 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.2.3.0 plugins/commands/up/middleware/store_box_metadata.rb
vagrant-unbundled-2.2.2.0 plugins/commands/up/middleware/store_box_metadata.rb