Skip to content

Commit

Permalink
Bare minimum plugin setup
Browse files Browse the repository at this point in the history
  • Loading branch information
naveenrajm7 committed Jul 15, 2024
1 parent 0798f1b commit d529011
Show file tree
Hide file tree
Showing 9 changed files with 333 additions and 14 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# bundle
/.bundle/
/.yardoc
/_yardoc/
Expand All @@ -9,3 +10,11 @@

# rspec failure tracking
.rspec_status

# ruby
*.gem

# vagrant
.vagrant/
# testing vagrant
Vagrantfile
17 changes: 10 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
source "https://rubygems.org"

# Specify your gem's dependencies in vagrant_utm.gemspec
gemspec

gem "rake", "~> 13.0"

gem "rspec", "~> 3.0"

gem "rubocop", "~> 1.21"
group :development do
gem "rake", "~> 13.0"
gem "rspec", "~> 3.0"
gem "rubocop", "~> 1.21"
gem "vagrant", git: "https://github.com/hashicorp/vagrant.git", tag: "v2.4.1"
end

group :plugins do
gem "vagrant_utm", path: "."
end
202 changes: 202 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
GIT
remote: https://github.com/hashicorp/vagrant.git
revision: 720b68f59facb98781e096747864262df6cc8a3a
tag: v2.4.1
specs:
vagrant (2.4.1)
bcrypt_pbkdf (~> 1.1)
childprocess (~> 4.1.0)
ed25519 (~> 1.3.0)
erubi
googleapis-common-protos-types (~> 1.3)
grpc (~> 1.56.0)
hashicorp-checkpoint (~> 0.1.5)
i18n (~> 1.12)
ipaddr (>= 1.2.4)
listen (~> 3.7)
log4r (~> 1.1.9, < 1.1.11)
mime-types (~> 3.3)
net-ftp (~> 0.2)
net-scp (~> 4.0)
net-sftp (~> 4.0)
net-ssh (~> 7.0)
rb-kqueue (~> 0.2.0)
rexml (~> 3.2)
rgl (~> 0.5.10)
rubyzip (~> 2.3.2)
vagrant_cloud (~> 3.1.1)
wdm (~> 0.1.1)
winrm (>= 2.3.6, < 3.0)
winrm-elevated (>= 1.2.3, < 2.0)
winrm-fs (>= 1.3.5, < 2.0)

PATH
remote: .
specs:
vagrant_utm (0.0.0)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
base64 (0.2.0)
bcrypt_pbkdf (1.1.1)
bcrypt_pbkdf (1.1.1-arm64-darwin)
bigdecimal (3.1.8)
builder (3.3.0)
childprocess (4.1.0)
concurrent-ruby (1.3.3)
date (3.3.4)
diff-lcs (1.5.1)
ed25519 (1.3.0)
erubi (1.13.0)
excon (0.111.0)
ffi (1.17.0)
ffi (1.17.0-aarch64-linux-gnu)
ffi (1.17.0-aarch64-linux-musl)
ffi (1.17.0-arm-linux-gnu)
ffi (1.17.0-arm-linux-musl)
ffi (1.17.0-arm64-darwin)
google-protobuf (3.25.3)
google-protobuf (3.25.3-aarch64-linux)
google-protobuf (3.25.3-arm64-darwin)
googleapis-common-protos-types (1.15.0)
google-protobuf (>= 3.18, < 5.a)
grpc (1.56.2)
google-protobuf (~> 3.23)
googleapis-common-protos-types (~> 1.0)
gssapi (1.3.1)
ffi (>= 1.0.1)
gyoku (1.4.0)
builder (>= 2.1.2)
rexml (~> 3.0)
hashicorp-checkpoint (0.1.5)
httpclient (2.8.3)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
ipaddr (1.2.6)
json (2.7.2)
language_server-protocol (3.17.0.3)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
little-plugger (1.1.4)
log4r (1.1.10)
logging (2.4.0)
little-plugger (~> 1.1)
multi_json (~> 1.14)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0702)
multi_json (1.15.0)
net-ftp (0.3.7)
net-protocol
time
net-protocol (0.2.2)
timeout
net-scp (4.0.0)
net-ssh (>= 2.6.5, < 8.0.0)
net-sftp (4.0.0)
net-ssh (>= 5.0.0, < 8.0.0)
net-ssh (7.2.3)
nori (2.7.0)
bigdecimal
pairing_heap (3.1.0)
parallel (1.25.1)
parser (3.3.4.0)
ast (~> 2.4.1)
racc
racc (1.8.0)
rainbow (3.1.1)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rb-kqueue (0.2.8)
ffi (>= 0.5.0)
regexp_parser (2.9.2)
rexml (3.2.9)
strscan
rgl (0.5.10)
pairing_heap (>= 0.3.0)
rexml (~> 3.2, >= 3.2.4)
stream (~> 0.5.3)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
rubocop (1.65.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
ruby-progressbar (1.13.0)
rubyntlm (0.6.5)
base64
rubyzip (2.3.2)
stream (0.5.5)
strscan (3.1.0)
time (0.3.0)
date
timeout (0.4.1)
unicode-display_width (2.5.0)
vagrant_cloud (3.1.1)
excon (~> 0.73)
log4r (~> 1.1.10)
rexml (~> 3.2.5)
wdm (0.1.1)
winrm (2.3.8)
builder (>= 2.1.2)
erubi (~> 1.8)
gssapi (~> 1.2)
gyoku (~> 1.0)
httpclient (~> 2.2, >= 2.2.0.2)
logging (>= 1.6.1, < 3.0)
nori (~> 2.0)
rexml (~> 3.0)
rubyntlm (~> 0.6.0, >= 0.6.3)
winrm-elevated (1.2.3)
erubi (~> 1.8)
winrm (~> 2.0)
winrm-fs (~> 1.0)
winrm-fs (1.3.5)
erubi (~> 1.8)
logging (>= 1.6.1, < 3.0)
rubyzip (~> 2.0)
winrm (~> 2.0)

PLATFORMS
aarch64-linux
aarch64-linux-gnu
aarch64-linux-musl
arm-linux-gnu
arm-linux-musl
arm64-darwin
ruby

DEPENDENCIES
rake (~> 13.0)
rspec (~> 3.0)
rubocop (~> 1.21)
vagrant!
vagrant_utm!

BUNDLED WITH
2.5.11
20 changes: 16 additions & 4 deletions lib/vagrant_utm.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
# frozen_string_literal: true

require_relative "vagrant_utm/version"
require "pathname"
require "vagrant_utm/plugin"

module VagrantUtm
class Error < StandardError; end
# Your code goes here...
module VagrantPlugins
# Top level module for the UTM provider plugin.
module Utm
lib_path = Pathname.new(File.expand_path("vagrant_utm", __dir__))
# autoload :Action, lib_path.join("action")
# autoload :Errors, lib_path.join("errors")

# This returns the path to the source of this plugin.
#
# @return [Pathname]
def self.source_root
@source_root ||= Pathname.new(File.expand_path("..", __dir__))
end
end
end
23 changes: 23 additions & 0 deletions lib/vagrant_utm/errors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module VagrantPlugins
module Utm
module Errors
# Base class for all errors raised by the UTM provider.
class UtmError < Vagrant::Errors::VagrantError
error_namespace("vagrant_utm.errors")
end

# Error raised if the platform is not MacOS.
class MacOSRequired < UtmError
error_key(:macos_required)
end

# Error raised if the utmctl binary is not found.
class UtmRequired < UtmError
error_key(:utm_required)
end

end
end
end
33 changes: 33 additions & 0 deletions lib/vagrant_utm/plugin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

# check if the Vagrant gem is available
begin
require "vagrant"
rescue LoadError
raise "The 'vagrant' gem could not be found. Please make sure it is installed."
end

# check if the Vagrant version is sufficient
raise "The Vagrant UTM plugin is only compatible with Vagrant 2.3 or later" if Vagrant::VERSION < "2.3.0"

module VagrantPlugins
module Utm
# This is the main entry point for the UTM provider plugin.
class Plugin < Vagrant.plugin("2")
name "utm"
description "UTM provider for Vagrant"

# # Register the configuration
# config(:utm, :provider) do
# require_relative "config"
# Config
# end

# Register the provider
provider(:utm) do
require_relative "provider"
Provider
end
end
end
end
33 changes: 33 additions & 0 deletions lib/vagrant_utm/provider.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require "log4r"
# require_relative "util/driver"

module VagrantPlugins
module Utm
# This is the provider for UTM.
class Provider < Vagrant.plugin("2", :provider)

# Initialize the provider with given machine.
def initialize(machine)
super
@logger = Log4r::Logger.new("vagrant::provider::utm")
@machine = machine
@driver = nil
end

# Check if the provider is usable.
def self.usable?(raise_error = false)
raise Errors::MacOSRequired unless Vagrant::Util::Platform.darwin?

utm_present = Vagrant::Util::Which.which("utmctl")
raise Errors::UtmRequired unless utm_present

true
rescue Errors::UtmError
raise if raise_error
false
end
end
end
end
8 changes: 6 additions & 2 deletions lib/vagrant_utm/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# frozen_string_literal: true

module VagrantUtm
VERSION = "0.1.0"
module VagrantPlugins
# Top level module for the Tart provider plugin.
module Utm
# Current version of the Tart provider plugin.
VERSION = "0.0.0"
end
end
2 changes: 1 addition & 1 deletion vagrant_utm.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require_relative "lib/vagrant_utm/version"

Gem::Specification.new do |spec|
spec.name = "vagrant_utm"
spec.version = VagrantUtm::VERSION
spec.version = VagrantPlugins::Utm::VERSION
spec.authors = ["Naveenraj M"]
spec.email = ["naveenrajm97@gmail.com"]

Expand Down

0 comments on commit d529011

Please sign in to comment.