Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change precedence of droplet name config values #248

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/vagrant-digitalocean/actions/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.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,
Expand Down
3 changes: 3 additions & 0 deletions lib/vagrant-digitalocean/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -27,6 +28,7 @@ def initialize
@ssh_key_name = UNSET_VALUE
@setup = UNSET_VALUE
@user_data = UNSET_VALUE
@name = UNSET_VALUE
end

def finalize!
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-digitalocean/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.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
Expand Down