Class: Kitchen::Box::LocalArchive
- Inherits:
-
Object
- Object
- Kitchen::Box::LocalArchive
- Defined in:
- lib/kitchen/box/local_archive.rb
Overview
Extracts a trusted local Vagrant-format box without evaluating its Vagrantfile. Callers supply a private, empty destination and select their provider payload.
Defined Under Namespace
Classes: InvalidBox
Instance Method Summary collapse
- #extract(destination) ⇒ Object
-
#initialize(path, provider:) ⇒ LocalArchive
constructor
A new instance of LocalArchive.
Constructor Details
#initialize(path, provider:) ⇒ LocalArchive
Returns a new instance of LocalArchive.
13 14 15 16 |
# File 'lib/kitchen/box/local_archive.rb', line 13 def initialize(path, provider:) @path = path @provider = provider end |
Instance Method Details
#extract(destination) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kitchen/box/local_archive.rb', line 18 def extract(destination) yield "/usr/bin/tar", "-xf", @path, "-C", destination, "--no-same-owner", "--no-same-permissions" = File.join(destination, "metadata.json") unless File.file?() && !File.symlink?() raise InvalidBox, "Box is missing a regular metadata.json file: #{@path}" end = JSON.parse(File.read()) unless .is_a?(Hash) && ["provider"] == @provider raise InvalidBox, "Box metadata must specify the #{@provider} provider: #{@path}" end rescue JSON::ParserError => e raise InvalidBox, "Invalid metadata.json in #{@path}: #{e.}" end |