Support array of ip addresses

This commit is contained in:
Joel Elkins 2023-12-08 13:35:45 -06:00
parent 05e011f76f
commit 370df4f53f
No known key found for this signature in database
GPG Key ID: 133589DC38921AE2
2 changed files with 14 additions and 6 deletions

View File

@ -188,6 +188,12 @@ func (c *Container) CreateCommands() cmd.Set {
if c.Networks[i].IPv6Address != nil {
ips = append(ips, c.Networks[i].IPv6Address)
}
for _, ip := range c.Networks[i].IPv4Addresses {
ips = append(ips, ip)
}
for _, ip := range c.Networks[i].IPv6Addresses {
ips = append(ips, ip)
}
nets[c.Networks[i].Name] = types.PerNetworkOptions{
StaticIPs: ips,
InterfaceName: c.Networks[i].Name,

View File

@ -1,7 +1,7 @@
/*
Package network houses configured default metadata. Items defined for
a `network.Network` struct serve as default values for container network
definitions (based on the nework Name).
definitions (based on the network Name).
Copyright © 2022 Joel D. Elkins <joel@elkins.co>
@ -37,9 +37,11 @@ import (
// configuration omits DNS servers or the IPv6 flag, then the stand alone
// definition values will be applied for the container when it is created.
type Network struct {
Name string `toml:"name"`
DNS []net.IP `toml:"dns,omitempty"`
IPv6 null.Bool `toml:"ipv6,omitempty"`
IPv4Address net.IP `toml:"ipv4_address,omitempty"`
IPv6Address net.IP `toml:"ipv6_address,omitempty"`
Name string `toml:"name"`
DNS []net.IP `toml:"dns,omitempty"`
IPv6 null.Bool `toml:"ipv6,omitempty"`
IPv4Address net.IP `toml:"ipv4_address,omitempty"`
IPv6Address net.IP `toml:"ipv6_address,omitempty"`
IPv4Addresses []net.IP `toml:"ipv4_addresses,omitempty"`
IPv6Addresses []net.IP `toml:"ipv6_addresses,omitempty"`
}