Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing LinkLocalIPs to ServiceNetworkConfig #289

Merged
merged 2 commits into from Jul 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
61 changes: 61 additions & 0 deletions loader/loader_test.go
Expand Up @@ -1484,6 +1484,67 @@ networks:
assert.DeepEqual(t, config, expected, cmpopts.EquateEmpty())
}

func TestLoadNetworkLinkLocalIPs(t *testing.T) {
config, err := loadYAML(`
services:
foo:
image: alpine
networks:
network1:
ipv4_address: 10.1.0.100
ipv6_address: 2001:db8:0:1::100
link_local_ips:
- fe80::1:95ff:fe20:100
networks:
network1:
driver: bridge
enable_ipv6: true
name: network1
ipam:
config:
- subnet: 10.1.0.0/16
- subnet: 2001:db8:0:1::/64
`)
assert.NilError(t, err)

workingDir, err := os.Getwd()
assert.NilError(t, err)
expected := &types.Project{
Name: "",
WorkingDir: workingDir,
Services: types.Services{
{
Name: "foo",
Image: "alpine",
Scale: 1,
Networks: map[string]*types.ServiceNetworkConfig{
"network1": {
Ipv4Address: "10.1.0.100",
Ipv6Address: "2001:db8:0:1::100",
LinkLocalIPs: []string{
"fe80::1:95ff:fe20:100",
},
},
},
},
},
Networks: map[string]types.NetworkConfig{
"network1": {
Name: "network1",
Driver: "bridge",
EnableIPv6: true,
Ipam: types.IPAMConfig{
Config: []*types.IPAMPool{
{Subnet: "10.1.0.0/16"},
{Subnet: "2001:db8:0:1::/64"},
},
},
},
},
}
assert.DeepEqual(t, config, expected, cmpopts.EquateEmpty())
}

func TestLoadInit(t *testing.T) {
booleanTrue := true
booleanFalse := false
Expand Down
9 changes: 5 additions & 4 deletions types/types.go
Expand Up @@ -617,10 +617,11 @@ type PlacementPreferences struct {

// ServiceNetworkConfig is the network configuration for a service
type ServiceNetworkConfig struct {
Priority int `yaml:",omitempty" json:"priotirt,omitempty"`
Aliases []string `yaml:",omitempty" json:"aliases,omitempty"`
Ipv4Address string `mapstructure:"ipv4_address" yaml:"ipv4_address,omitempty" json:"ipv4_address,omitempty"`
Ipv6Address string `mapstructure:"ipv6_address" yaml:"ipv6_address,omitempty" json:"ipv6_address,omitempty"`
Priority int `yaml:",omitempty" json:"priority,omitempty"`
Aliases []string `yaml:",omitempty" json:"aliases,omitempty"`
Ipv4Address string `mapstructure:"ipv4_address" yaml:"ipv4_address,omitempty" json:"ipv4_address,omitempty"`
Ipv6Address string `mapstructure:"ipv6_address" yaml:"ipv6_address,omitempty" json:"ipv6_address,omitempty"`
LinkLocalIPs []string `mapstructure:"link_local_ips" yaml:"link_local_ips,omitempty" json:"link_local_ips,omitempty"`

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