Skip to content

Commit 7be7b11

Browse files
authored
Merge pull request #289 from floatingstatic/link_local_ips
Add missing LinkLocalIPs to ServiceNetworkConfig
2 parents c796fcc + ec8d637 commit 7be7b11

File tree

2 files changed

+66
-4
lines changed

2 files changed

+66
-4
lines changed

loader/loader_test.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,67 @@ networks:
14841484
assert.DeepEqual(t, config, expected, cmpopts.EquateEmpty())
14851485
}
14861486

1487+
func TestLoadNetworkLinkLocalIPs(t *testing.T) {
1488+
config, err := loadYAML(`
1489+
services:
1490+
foo:
1491+
image: alpine
1492+
networks:
1493+
network1:
1494+
ipv4_address: 10.1.0.100
1495+
ipv6_address: 2001:db8:0:1::100
1496+
link_local_ips:
1497+
- fe80::1:95ff:fe20:100
1498+
networks:
1499+
network1:
1500+
driver: bridge
1501+
enable_ipv6: true
1502+
name: network1
1503+
ipam:
1504+
config:
1505+
- subnet: 10.1.0.0/16
1506+
- subnet: 2001:db8:0:1::/64
1507+
`)
1508+
assert.NilError(t, err)
1509+
1510+
workingDir, err := os.Getwd()
1511+
assert.NilError(t, err)
1512+
expected := &types.Project{
1513+
Name: "",
1514+
WorkingDir: workingDir,
1515+
Services: types.Services{
1516+
{
1517+
Name: "foo",
1518+
Image: "alpine",
1519+
Scale: 1,
1520+
Networks: map[string]*types.ServiceNetworkConfig{
1521+
"network1": {
1522+
Ipv4Address: "10.1.0.100",
1523+
Ipv6Address: "2001:db8:0:1::100",
1524+
LinkLocalIPs: []string{
1525+
"fe80::1:95ff:fe20:100",
1526+
},
1527+
},
1528+
},
1529+
},
1530+
},
1531+
Networks: map[string]types.NetworkConfig{
1532+
"network1": {
1533+
Name: "network1",
1534+
Driver: "bridge",
1535+
EnableIPv6: true,
1536+
Ipam: types.IPAMConfig{
1537+
Config: []*types.IPAMPool{
1538+
{Subnet: "10.1.0.0/16"},
1539+
{Subnet: "2001:db8:0:1::/64"},
1540+
},
1541+
},
1542+
},
1543+
},
1544+
}
1545+
assert.DeepEqual(t, config, expected, cmpopts.EquateEmpty())
1546+
}
1547+
14871548
func TestLoadInit(t *testing.T) {
14881549
booleanTrue := true
14891550
booleanFalse := false

types/types.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,10 +617,11 @@ type PlacementPreferences struct {
617617

618618
// ServiceNetworkConfig is the network configuration for a service
619619
type ServiceNetworkConfig struct {
620-
Priority int `yaml:",omitempty" json:"priotirt,omitempty"`
621-
Aliases []string `yaml:",omitempty" json:"aliases,omitempty"`
622-
Ipv4Address string `mapstructure:"ipv4_address" yaml:"ipv4_address,omitempty" json:"ipv4_address,omitempty"`
623-
Ipv6Address string `mapstructure:"ipv6_address" yaml:"ipv6_address,omitempty" json:"ipv6_address,omitempty"`
620+
Priority int `yaml:",omitempty" json:"priority,omitempty"`
621+
Aliases []string `yaml:",omitempty" json:"aliases,omitempty"`
622+
Ipv4Address string `mapstructure:"ipv4_address" yaml:"ipv4_address,omitempty" json:"ipv4_address,omitempty"`
623+
Ipv6Address string `mapstructure:"ipv6_address" yaml:"ipv6_address,omitempty" json:"ipv6_address,omitempty"`
624+
LinkLocalIPs []string `mapstructure:"link_local_ips" yaml:"link_local_ips,omitempty" json:"link_local_ips,omitempty"`
624625

625626
Extensions map[string]interface{} `yaml:",inline" json:"-"`
626627
}

0 commit comments

Comments
 (0)