module VagrantPlugins
  module CookbookFetcher
    class Config < Vagrant.plugin("2", :config)
      attr_accessor :url
      attr_accessor :disable

      def initialize
        super
        @url     = UNSET_VALUE
        @disable = UNSET_VALUE
      end

      def finalize!
        @disable = false if @disable == UNSET_VALUE
      end

      def validate(machine)
        errors = []
        unless @disable then
          if @url == UNSET_VALUE
            errors << "vagrant-cookbook-fetcher plugin requires a config parameter, 'url', which is missing."
          end
        end

        { 'Cookbook Fetcher' => errors }
      end

    end
  end
end

module VagrantPlugins
  module CookbookFetcher
    class Config < Vagrant.plugin("2", :config)
      attr_accessor :url
      attr_accessor :disable

      def initialize
        super
        @url     = UNSET_VALUE
        @disable = UNSET_VALUE
      end

      def finalize!
        @disable = false if @disable == UNSET_VALUE
      end

      def validate(machine)
        errors = []
        if @url == UNSET_VALUE
          # Disable vagrant cookbook fetcher if we don't specify a URL
          @disable = true
        end

        { 'Cookbook Fetcher' => errors }
      end

    end
  end
end

Disable plugin if a URL isn't specified
Disable plugin if a URL isn't specified

Rather than throw an error, this change disables vagrant-cookbook-fetcher.
Without this, any Vagrantfile that doesn't use vagrant-cookbook-fetcher will
throw an error, preventing you from using vagrant without configuring this
plugin.
