Skip to content

Commit

Permalink
config: use name as attribute along with setter method
Browse files Browse the repository at this point in the history
config.name name can be used else where to print VM name (UTM GUI)
  • Loading branch information
naveenrajm7 committed Jul 21, 2024
1 parent 44754e6 commit 2e1242c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/vagrant_utm/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ class Config < Vagrant.plugin("2", :config)
# This should be set to the name of the machine in the UTM GUI.
#
# @return [String]
# attr_accessor :name
attr_accessor :name

# The path to the UTM VM file.
#
# @return [String]
attr_accessor :utm_file_url

# If true, will check if guest additions are installed and up to
# date. By default, this is true.
#
# @return [Boolean]
attr_accessor :check_guest_additions

# An array of customizations to make on the VM prior to booting it.
#
# @return [Array]
Expand All @@ -25,6 +31,7 @@ class Config < Vagrant.plugin("2", :config)
# Initialize the configuration with unset values.
def initialize
super
@check_guest_additions = UNSET_VALUE
@customizations = []
@name = UNSET_VALUE
@utm_file_url = UNSET_VALUE
Expand All @@ -45,11 +52,14 @@ def customize(*command)
@customizations << [event, command]
end

# name in utm config will call this method
# Will change the name of the VM in UTM GUI
# Shortcut for setting the VM name.
# Calls #customize internally.
#
# @param name [String] the name of the virtual machine
def name=(name)
def name=(name) # rubocop:disable Lint/DuplicateMethods
@name = name # To be able to access config.name else where
customize("pre-boot", ["customize_vm.applescript", :id, "--name", name.to_s])
end

Expand Down

0 comments on commit 2e1242c

Please sign in to comment.