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 enable_ipv4 (for moby 28.0) #730

Merged
merged 1 commit into from
Jan 22, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions loader/interpolate.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ var interpolateTypeCastMapping = map[tree.Path]interp.Cast{
iPath("networks", tree.PathMatchAll, "external"): toBoolean,
iPath("networks", tree.PathMatchAll, "internal"): toBoolean,
iPath("networks", tree.PathMatchAll, "attachable"): toBoolean,
iPath("networks", tree.PathMatchAll, "enable_ipv4"): toBoolean,
iPath("networks", tree.PathMatchAll, "enable_ipv6"): toBoolean,
iPath("volumes", tree.PathMatchAll, "external"): toBoolean,
iPath("secrets", tree.PathMatchAll, "external"): toBoolean,
Expand Down
48 changes: 48 additions & 0 deletions loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,54 @@ networks:
assert.DeepEqual(t, config, expected, cmpopts.EquateEmpty())
}

func TestLoadIPv6Only(t *testing.T) {
config, err := loadYAML(`
name: load-network-ipv6only
services:
foo:
image: alpine
networks:
network1:
networks:
network1:
driver: bridge
enable_ipv4: false
enable_ipv6: true
name: network1
`)
assert.NilError(t, err)

workingDir, err := os.Getwd()
assert.NilError(t, err)
enableIPv4 := false
enableIPv6 := true
expected := &types.Project{
Name: "load-network-ipv6only",
WorkingDir: workingDir,
Services: types.Services{
"foo": {
Name: "foo",
Image: "alpine",
Networks: map[string]*types.ServiceNetworkConfig{
"network1": nil,
},
},
},
Networks: map[string]types.NetworkConfig{
"network1": {
Name: "network1",
Driver: "bridge",
EnableIPv4: &enableIPv4,
EnableIPv6: &enableIPv6,
},
},
Environment: types.Mapping{
"COMPOSE_PROJECT_NAME": "load-network-ipv6only",
},
}
assert.DeepEqual(t, config, expected, cmpopts.EquateEmpty())
}

func TestLoadNetworkLinkLocalIPs(t *testing.T) {
config, err := loadYAML(`
name: load-network-link-local-ips
Expand Down
1 change: 1 addition & 0 deletions schema/compose-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@
"patternProperties": {"^x-": {}}
},
"internal": {"type": ["boolean", "string"]},
"enable_ipv4": {"type": ["boolean", "string"]},
"enable_ipv6": {"type": ["boolean", "string"]},
"attachable": {"type": ["boolean", "string"]},
"labels": {"$ref": "#/definitions/list_or_dict"}
Expand Down
6 changes: 6 additions & 0 deletions types/derived.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ type NetworkConfig struct {
Attachable bool `yaml:"attachable,omitempty" json:"attachable,omitempty"`
Labels Labels `yaml:"labels,omitempty" json:"labels,omitempty"`
CustomLabels Labels `yaml:"-" json:"-"`
EnableIPv4 *bool `yaml:"enable_ipv4,omitempty" json:"enable_ipv4,omitempty"`
EnableIPv6 *bool `yaml:"enable_ipv6,omitempty" json:"enable_ipv6,omitempty"`
Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
Expand Down
Loading