Class: VagrantPlugins::Shell::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-shell/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/vagrant-shell/config.rb', line 31

def initialize
  @image                  = UNSET_VALUE
  @instance_ready_timeout = UNSET_VALUE
  @user_data              = UNSET_VALUE
  @script                 = UNSET_VALUE
  @run_args               = UNSET_VALUE

  # Internal state (prefix with __ so they aren't automatically
  # merged)
  @__finalized = false
end

Instance Attribute Details

#imageString

The ID of the Image to use.

Returns:

  • (String)


9
10
11
# File 'lib/vagrant-shell/config.rb', line 9

def image
  @image
end

#instance_ready_timeoutFixnum

The timeout to wait for an instance to become ready.

Returns:

  • (Fixnum)


14
15
16
# File 'lib/vagrant-shell/config.rb', line 14

def instance_ready_timeout
  @instance_ready_timeout
end

#run_argsString

The shell script run-instance args

Returns:

  • (String)


29
30
31
# File 'lib/vagrant-shell/config.rb', line 29

def run_args
  @run_args
end

#scriptString

The shell script implementing some tech

Returns:

  • (String)


24
25
26
# File 'lib/vagrant-shell/config.rb', line 24

def script
  @script
end

#user_dataString

The user data string

Returns:

  • (String)


19
20
21
# File 'lib/vagrant-shell/config.rb', line 19

def user_data
  @user_data
end

Instance Method Details

#finalize!Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/vagrant-shell/config.rb', line 52

def finalize!
  # Image must be nil, since we can't default that
  @image = nil if @image == UNSET_VALUE

  # Set the default timeout for waiting for an instance to be ready
  @instance_ready_timeout = 120 if @instance_ready_timeout == UNSET_VALUE

  # User Data is nil by default
  @user_data = nil if @user_data == UNSET_VALUE

  # No default shell script
  @script = nil if @script == UNSET_VALUE

  # No rub args by default
  @run_args = [] if @run_args == UNSET_VALUE

  # Mark that we finalized
  @__finalized = true
end

#find_script(name) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/vagrant-shell/config.rb', line 81

def find_script name
  try_path = ENV['PATH'].split(/:/).flatten.inject([]) { |acc, p| x = File.join(p,"shell-#{name.to_s}"); File.exists?(x) && acc << x; acc }.first
  if try_path
    return try_path
  end

  try_load = $:.inject([]) { |acc, p| x = File.expand_path("../libexec/shell-#{name.to_s}", p); File.exists?(x) && acc << x; acc }.first
  if try_load
    return try_load
  end
end

#merge(other) ⇒ Object


Internal methods.




47
48
49
50
# File 'lib/vagrant-shell/config.rb', line 47

def merge(other)
  super.tap do |result|
  end
end

#read_script(pth_script) ⇒ Object

utilities



77
78
79
# File 'lib/vagrant-shell/config.rb', line 77

def read_script pth_script
  File.read(pth_script).split(/[ \t]*[\r\n]+/).join("; ")
end

#validate(machine) ⇒ Object



72
73
74
# File 'lib/vagrant-shell/config.rb', line 72

def validate(machine)
  { "Shell Provider" => [ ] } 
end