Sha256: 4e2004f2d3e3fc1cac9b1b8d24ca8209c3ed586f2de0f98711b6c8645f24add7
Contents?: true
Size: 1.73 KB
Versions: 12
Compression:
Stored size: 1.73 KB
Contents
require 'vagrant' module VagrantHosts class Config < Vagrant.plugin('2', :config) # @!attribute hosts # @return [Array<Array<String, Array<String>>>] A list of IP addresses and their aliases attr_reader :hosts # @!attribute autoconfigure # @return [TrueClass, FalseClass] If hosts should be generated from the # other vagrant machines attr_accessor :autoconfigure def initialize @hosts = [] @autoconfigure = UNSET_VALUE end # Register a host for entry # # @param [String] address The IP address for aliases # @param [Array] aliases An array of hostnames to assign to the IP address def add_host(address, aliases) @hosts << [address, aliases] end # All IPv6 multicast addresses def add_ipv6_multicast add_host '::1', ['ip6-localhost', 'ip6-loopback'] add_host 'fe00::0', ['ip6-localnet'] add_host 'ff00::0', ['ip6-mcastprefix'] add_host 'ff02::1', ['ip6-allnodes'] add_host 'ff02::2', ['ip6-allrouters'] end def finalize! if @autoconfigure == UNSET_VALUE if @hosts.empty? @autoconfigure = true else @autoconfigure = false end end end # @param other [VagrantHosts::Config] # @return [VagrantHosts::Config] The merged results def merge(other) super.tap do |result| result.hosts += other.hosts end end def validate(machine) errors = [] @hosts.each do |(address, aliases)| unless aliases.is_a? Array errors << "#{address} should have an array of aliases, got #{aliases.inspect}:#{aliases.class}" end end {"Vagrant Hosts" => errors} end end end
Version data entries
12 entries across 12 versions & 1 rubygems