Sha256: b8c0abb381263c9fe9c5876de577a4116e9c01d1574c7a8aaaff136f59622004

Contents?: true

Size: 1.94 KB

Versions: 3

Compression:

Stored size: 1.94 KB

Contents

require "vagrant"

module VagrantPlugins
  module Shell
    class Config < Vagrant.plugin("2", :config)
      # The ID of the Image to use.
      #
      # @return [String]
      attr_accessor :image

      # The timeout to wait for an instance to become ready.
      #
      # @return [Fixnum]
      attr_accessor :instance_ready_timeout

      # The user data string
      #
      # @return [String]
      attr_accessor :user_data

      # The shell script implementing some tech
      # 
      # @return [String]
      attr_accessor :script

      # The shell script run-instance args
      # 
      # @return [String]
      attr_accessor :run_args

      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

      #-------------------------------------------------------------------
      # Internal methods.
      #-------------------------------------------------------------------

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

      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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-shell-0.2.6 lib/vagrant-shell/config.rb
vagrant-shell-0.2.5 lib/vagrant-shell/config.rb
vagrant-shell-0.2.4 lib/vagrant-shell/config.rb