From 36a4ad7dce20f29bb3bdbddc96318657dd436461 Mon Sep 17 00:00:00 2001 From: drmyersii Date: Wed, 17 Aug 2016 01:56:10 -0400 Subject: [PATCH 1/3] Fixing bug where the provider.name config option is ignored. --- lib/vagrant-digitalocean/actions/create.rb | 2 +- lib/vagrant-digitalocean/config.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/vagrant-digitalocean/actions/create.rb b/lib/vagrant-digitalocean/actions/create.rb index c909968..4543091 100644 --- a/lib/vagrant-digitalocean/actions/create.rb +++ b/lib/vagrant-digitalocean/actions/create.rb @@ -22,7 +22,7 @@ def call(env) :size => @machine.provider_config.size, :region => @machine.provider_config.region, :image => @machine.provider_config.image, - :name => @machine.config.vm.hostname || @machine.name, + :name => @machine.config.vm.hostname || @machine.provider_config.name || @machine.name, :ssh_keys => ssh_key_id, :private_networking => @machine.provider_config.private_networking, :backups => @machine.provider_config.backups_enabled, diff --git a/lib/vagrant-digitalocean/config.rb b/lib/vagrant-digitalocean/config.rb index 7593347..677f7e1 100644 --- a/lib/vagrant-digitalocean/config.rb +++ b/lib/vagrant-digitalocean/config.rb @@ -12,6 +12,7 @@ class Config < Vagrant.plugin('2', :config) attr_accessor :ssh_key_name attr_accessor :setup attr_accessor :user_data + attr_accessor :name alias_method :setup?, :setup @@ -27,6 +28,7 @@ def initialize @ssh_key_name = UNSET_VALUE @setup = UNSET_VALUE @user_data = UNSET_VALUE + @name = UNSET_VALUE end def finalize! @@ -41,6 +43,7 @@ def finalize! @ssh_key_name = 'Vagrant' if @ssh_key_name == UNSET_VALUE @setup = true if @setup == UNSET_VALUE @user_data = nil if @user_data == UNSET_VALUE + @name = nil if @name == UNSET_VALUE end def validate(machine) From 3da3d52d4fcbe6a7578508ba30ecdd2290e3d24d Mon Sep 17 00:00:00 2001 From: drmyersii Date: Wed, 17 Aug 2016 02:02:10 -0400 Subject: [PATCH 2/3] Including code to search by provider by name in case of failed id lookup. --- lib/vagrant-digitalocean/provider.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-digitalocean/provider.rb b/lib/vagrant-digitalocean/provider.rb index 8dde8ad..bd2ee14 100644 --- a/lib/vagrant-digitalocean/provider.rb +++ b/lib/vagrant-digitalocean/provider.rb @@ -30,7 +30,7 @@ def self.droplet(machine, opts = {}) # and set the id to ensure vagrant stores locally # TODO allow the user to configure this behavior if !droplet - name = machine.config.vm.hostname || machine.name + name = machine.config.vm.hostname || machine.provider_config.name || machine.name droplet = @droplets.find { |d| d['name'] == name.to_s } machine.id = droplet['id'].to_s if droplet end From 7866d5e7f904881afea74711784e5343b1db1046 Mon Sep 17 00:00:00 2001 From: drmyersii Date: Wed, 17 Aug 2016 02:04:36 -0400 Subject: [PATCH 3/3] Changing the precedence of the config name used to specify the droplet name from config.vm.hostname to provider.name as this is more natural (expected) behavior. --- lib/vagrant-digitalocean/actions/create.rb | 2 +- lib/vagrant-digitalocean/provider.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-digitalocean/actions/create.rb b/lib/vagrant-digitalocean/actions/create.rb index 4543091..0d6123f 100644 --- a/lib/vagrant-digitalocean/actions/create.rb +++ b/lib/vagrant-digitalocean/actions/create.rb @@ -22,7 +22,7 @@ def call(env) :size => @machine.provider_config.size, :region => @machine.provider_config.region, :image => @machine.provider_config.image, - :name => @machine.config.vm.hostname || @machine.provider_config.name || @machine.name, + :name => @machine.provider_config.name || @machine.config.vm.hostname || @machine.name, :ssh_keys => ssh_key_id, :private_networking => @machine.provider_config.private_networking, :backups => @machine.provider_config.backups_enabled, diff --git a/lib/vagrant-digitalocean/provider.rb b/lib/vagrant-digitalocean/provider.rb index bd2ee14..31139b2 100644 --- a/lib/vagrant-digitalocean/provider.rb +++ b/lib/vagrant-digitalocean/provider.rb @@ -30,7 +30,7 @@ def self.droplet(machine, opts = {}) # and set the id to ensure vagrant stores locally # TODO allow the user to configure this behavior if !droplet - name = machine.config.vm.hostname || machine.provider_config.name || machine.name + name = machine.provider_config.name || machine.config.vm.hostname || machine.name droplet = @droplets.find { |d| d['name'] == name.to_s } machine.id = droplet['id'].to_s if droplet end