Skip to content

Commit

Permalink
fix: linting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkProminic committed Jan 9, 2024
1 parent 895fb1f commit a0b7295
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions lib/vagrant-zones/action/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,26 @@ def call(env)

## Create the Metadata and Vagrantfile
Dir.chdir(tmp_dir)
File.write('./metadata.json', metadata_content(brand, kernel, vcc, boxshortname))
File.write('./Vagrantfile', vagrantfile_content(brand, kernel))

metadata_content_hash = {
"provider" => "zone",
"architecture" => "amd64",
"brand" => brand,
"format" => "zss",
"url" => "https://app.vagrantup.com/#{vcc}/boxes/#{boxshortname}"
}

File.write('./metadata.json', metadata_content_hash)

user_vagrantfile = File.expand_path('Vagrantfile', __dir__)
vagrantfile_content = %{require 'yaml'
require File.expand_path("#{File.dirname(__FILE__)}/Hosts.rb")
settings = YAML::load(File.read("#{File.dirname(__FILE__)}/Hosts.yml"))
Vagrant.configure("2") do |config|
Hosts.configure(config, settings)
end}
vagrantfile_content = File.read(user_vagrantfile ) if File.exist?(user_vagrantfile)
File.write('./Vagrantfile', vagrantfile_content)

## Create the Box file
assemble_box(boxname)
Expand Down Expand Up @@ -110,11 +128,7 @@ def snapshot_send(datasetpath, destination, datetime, uii, config)
puts "#{@pfexec} zfs send -r #{datasetpath}/boot@vagrant_box#{datetime} > #{destination}" if result.zero? && config.debug
end

def metadata_content(brand, _kernel, vcc, boxshortname)
<<-ZONEBOX
{ "provider": "zone", "architecture": "amd64", "brand": "#{brand}", "format": "zss", "url": "https://app.vagrantup.com/#{vcc}/boxes/#{boxshortname}" }
ZONEBOX
end


# This method copies the include files (passed in via command line) to the
# temporary directory so they are included in a sub-folder within the actual box
Expand All @@ -137,21 +151,6 @@ def copy_include_files(include_files, destination, uii)
end
end

def vagrantfile_content(brand, _kernel)
<<-ZONEBOX
## Vagrant File tooling compatabile with Bhyve and Virtualbox
require 'yaml'
require File.expand_path("#{File.dirname(__FILE__)}/Hosts.rb")
settings = YAML::load(File.read("#{File.dirname(__FILE__)}/Hosts.yml"))
Vagrant.configure("2") do |config|
Hosts.configure(config, settings)
config.brand = "#{brand}"
end
ZONEBOX
user_vagrantfile = File.expand_path('Vagrantfile', __dir__)
load user_vagrantfile if File.exist?(user_vagrantfile)
end

def assemble_box(boxname)
is_linux = `bash -c '[[ "$(uname -a)" =~ "Linux" ]]'`
files = Dir.glob(File.join('.', '*'))
Expand Down

0 comments on commit a0b7295

Please sign in to comment.