Class: VagrantDockerNetworksManager::NetworkBuilder
- Inherits:
-
Object
- Object
- VagrantDockerNetworksManager::NetworkBuilder
- Defined in:
- lib/vagrant-docker-networks-manager/network_builder.rb
Instance Method Summary collapse
- #build_create_command ⇒ Object
- #build_create_command_args ⇒ Object
-
#initialize(config, machine_id: nil) ⇒ NetworkBuilder
constructor
A new instance of NetworkBuilder.
Constructor Details
#initialize(config, machine_id: nil) ⇒ NetworkBuilder
Returns a new instance of NetworkBuilder.
7 8 9 10 |
# File 'lib/vagrant-docker-networks-manager/network_builder.rb', line 7 def initialize(config, machine_id: nil) @config = config @machine_id = machine_id end |
Instance Method Details
#build_create_command ⇒ Object
30 31 32 |
# File 'lib/vagrant-docker-networks-manager/network_builder.rb', line 30 def build_create_command build_create_command_args.shelljoin end |
#build_create_command_args ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/vagrant-docker-networks-manager/network_builder.rb', line 12 def build_create_command_args args = ["network", "create"] args += ["--label", "com.vagrant.plugin=docker_networks_manager"] args += ["--label", "com.vagrant.machine_id=#{@machine_id}"] if @machine_id args += ["--driver", @config.network_type] if present?(@config.network_type) args += ["--subnet", @config.network_subnet] if present?(@config.network_subnet) args += ["--gateway", @config.network_gateway] if present?(@config.network_gateway) args += ["--ip-range", @config.ip_range] if present?(@config.ip_range) args << "--ipv6" if truthy?(@config.enable_ipv6) args << "--attachable" if truthy?(@config.network_attachable) if @config.network_type.to_s == "macvlan" && present?(@config.network_parent) args += ["--opt", "parent=#{@config.network_parent}"] end args << @config.network_name.to_s args end |