Add Rocky Linux guest support
This commit is contained in:
parent
24a00ee3b3
commit
a8c5980afb
23
plugins/guests/rocky/cap/flavor.rb
Normal file
23
plugins/guests/rocky/cap/flavor.rb
Normal file
@ -0,0 +1,23 @@
|
||||
module VagrantPlugins
|
||||
module GuestRocky
|
||||
module Cap
|
||||
class Flavor
|
||||
def self.flavor(machine)
|
||||
# Read the version file
|
||||
version = ""
|
||||
machine.communicate.sudo("source /etc/os-release && printf $VERSION_ID") do |type, data|
|
||||
if type == :stdout
|
||||
version = data.split(".").first.to_i
|
||||
end
|
||||
end
|
||||
|
||||
if version.nil? || version < 1
|
||||
:rocky
|
||||
else
|
||||
"rocky_#{version}".to_sym
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
10
plugins/guests/rocky/guest.rb
Normal file
10
plugins/guests/rocky/guest.rb
Normal file
@ -0,0 +1,10 @@
|
||||
require_relative "../linux/guest"
|
||||
|
||||
module VagrantPlugins
|
||||
module GuestRocky
|
||||
class Guest < VagrantPlugins::GuestLinux::Guest
|
||||
# Name used for guest detection
|
||||
GUEST_DETECTION_NAME = "rocky".freeze
|
||||
end
|
||||
end
|
||||
end
|
||||
20
plugins/guests/rocky/plugin.rb
Normal file
20
plugins/guests/rocky/plugin.rb
Normal file
@ -0,0 +1,20 @@
|
||||
require "vagrant"
|
||||
|
||||
module VagrantPlugins
|
||||
module GuestRocky
|
||||
class Plugin < Vagrant.plugin("2")
|
||||
name "Rocky guest"
|
||||
description "Rocky guest support."
|
||||
|
||||
guest(:rocky, :redhat) do
|
||||
require_relative "guest"
|
||||
Guest
|
||||
end
|
||||
|
||||
guest_capability(:rocky, :flavor) do
|
||||
require_relative "cap/flavor"
|
||||
Cap::Flavor
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
36
test/unit/plugins/guests/rocky/cap/flavor_test.rb
Normal file
36
test/unit/plugins/guests/rocky/cap/flavor_test.rb
Normal file
@ -0,0 +1,36 @@
|
||||
require_relative "../../../../base"
|
||||
|
||||
describe "VagrantPlugins::GuestRocky::Cap::Flavor" do
|
||||
let(:caps) do
|
||||
VagrantPlugins::GuestRocky::Plugin
|
||||
.components
|
||||
.guest_capabilities[:rocky]
|
||||
end
|
||||
|
||||
let(:machine) { double("machine") }
|
||||
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
||||
|
||||
before do
|
||||
allow(machine).to receive(:communicate).and_return(comm)
|
||||
end
|
||||
|
||||
after do
|
||||
comm.verify_expectations!
|
||||
end
|
||||
|
||||
describe ".flavor" do
|
||||
let(:cap) { caps.get(:flavor) }
|
||||
|
||||
{
|
||||
"" => :rocky,
|
||||
"8.2" => :rocky_8,
|
||||
"9" => :rocky_9,
|
||||
"invalid" => :rocky
|
||||
}.each do |str, expected|
|
||||
it "returns #{expected} for #{str}" do
|
||||
comm.stub_command("source /etc/os-release && printf $VERSION_ID", stdout: str)
|
||||
expect(cap.flavor(machine)).to be(expected)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user