Generate metadata.json in root of package.

This commit is contained in:
Bjorn Brala 2016-10-05 14:42:46 +02:00
parent be2e9e79aa
commit 0970a5a67b
2 changed files with 36 additions and 0 deletions

View File

@ -87,6 +87,7 @@ module VagrantPlugins
b2.use Package
b2.use Export
b2.use PackageVagrantfile
b2.use PackageMetadataJson
end
end
end
@ -291,6 +292,7 @@ module VagrantPlugins
autoload :PackageSetupFolders, action_root.join("package_setup_folders")
autoload :PackageSetupFiles, action_root.join("package_setup_files")
autoload :PackageVagrantfile, action_root.join("package_vagrantfile")
autoload :PackageMetadataJson, action_root.join("package_metadata_json")
autoload :Export, action_root.join("export")
autoload :CheckEnabled, action_root.join("check_enabled")

View File

@ -0,0 +1,34 @@
require "json"
#require 'vagrant/util/template_renderer'
module VagrantPlugins
module HyperV
module Action
class PackageMetadataJson
# For TemplateRenderer
include Vagrant::Util
def initialize(app, env)
@app = app
end
def call(env)
@env = env
create_metadata
@app.call(env)
end
# This method creates a metadata.json file to tell vagrant this is a
# Hyper V box
def create_metadata
File.open(File.join(@env["export.temp_dir"], "metadata.json"), "w") do |f|
f.write(JSON.generate({
provider: "hyperv"
}))
end
end
end
end
end
end