Sha256: 26bb6452dde04e8c42f8a97f5031ffae69a0bed06a8ce9ee309cfa89a9d08624

Contents?: true

Size: 1.85 KB

Versions: 1

Compression:

Stored size: 1.85 KB

Contents

require 'uri'
require 'vagrant'

require 'pe_build/config_default'

module PEBuild
module Config

class Global < Vagrant.plugin('2', :config)

  # @todo This value should be discovered based on what versions of the
  #       installer are cached.
  #DEFAULT_PE_VERSION = '2.7.2'

  # @!attribute download_root
  attr_accessor :download_root

  # @!attribute version
  attr_accessor :version

  # @!attribute suffix
  attr_accessor :suffix

  # @!attribute filename
  attr_accessor :filename

  def initialize
    @download_root = UNSET_VALUE
    @version       = UNSET_VALUE
    @suffix        = UNSET_VALUE
    @filename      = UNSET_VALUE
  end

  include PEBuild::ConfigDefault

  def finalize!
    set_default :@suffix,   'all'
    #set_default :@version,  DEFAULT_PE_VERSION
    set_default :@filename, "puppet-enterprise-:version-#{suffix}.tar.gz"

    set_default :@download_root, nil
  end

  # @todo Convert error strings to I18n
  def validate(machine)
    errors = []

    # Allow Global version to be unset, rendering it essentially optional. If it is
    # discovered to be unset by a configuration on the next level up who cannot provide a
    # value, it is that configuration's job to take action.
    if @version.kind_of? String
      unless @version.match /\d+\.\d+(\.\d+)?/
        errors << "version must be a valid version string, got #{@version.inspect}"
      end
    elsif @version != UNSET_VALUE
      errors << "version only accepts a string, got #{@version.class}"
    end

    uri = URI.parse(@download_root) rescue nil
    unless @download_root == UNSET_VALUE or @download_root.nil? or File.directory?(File.expand_path(@download_root)) or uri.kind_of? (URI::HTTP||URI::HTTPS) or uri.kind_of? URI::FTP
      errors << "download_root must be valid URL or present local file path, got #{@download_root}"
    end

    {"PE Build global config" => errors}
  end
end

end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-pe_build-0.1.0 lib/pe_build/config/global.rb