Skip to content

Commit 4874a29

Browse files
robmryndeloof
authored andcommitted
Add enable_ipv4
Signed-off-by: Rob Murray <[email protected]>
1 parent 1b86894 commit 4874a29

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed

loader/interpolate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ var interpolateTypeCastMapping = map[tree.Path]interp.Cast{
6464
iPath("networks", tree.PathMatchAll, "external"): toBoolean,
6565
iPath("networks", tree.PathMatchAll, "internal"): toBoolean,
6666
iPath("networks", tree.PathMatchAll, "attachable"): toBoolean,
67+
iPath("networks", tree.PathMatchAll, "enable_ipv4"): toBoolean,
6768
iPath("networks", tree.PathMatchAll, "enable_ipv6"): toBoolean,
6869
iPath("volumes", tree.PathMatchAll, "external"): toBoolean,
6970
iPath("secrets", tree.PathMatchAll, "external"): toBoolean,

loader/loader_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,6 +1725,54 @@ networks:
17251725
assert.DeepEqual(t, config, expected, cmpopts.EquateEmpty())
17261726
}
17271727

1728+
func TestLoadIPv6Only(t *testing.T) {
1729+
config, err := loadYAML(`
1730+
name: load-network-ipv6only
1731+
services:
1732+
foo:
1733+
image: alpine
1734+
networks:
1735+
network1:
1736+
networks:
1737+
network1:
1738+
driver: bridge
1739+
enable_ipv4: false
1740+
enable_ipv6: true
1741+
name: network1
1742+
`)
1743+
assert.NilError(t, err)
1744+
1745+
workingDir, err := os.Getwd()
1746+
assert.NilError(t, err)
1747+
enableIPv4 := false
1748+
enableIPv6 := true
1749+
expected := &types.Project{
1750+
Name: "load-network-ipv6only",
1751+
WorkingDir: workingDir,
1752+
Services: types.Services{
1753+
"foo": {
1754+
Name: "foo",
1755+
Image: "alpine",
1756+
Networks: map[string]*types.ServiceNetworkConfig{
1757+
"network1": nil,
1758+
},
1759+
},
1760+
},
1761+
Networks: map[string]types.NetworkConfig{
1762+
"network1": {
1763+
Name: "network1",
1764+
Driver: "bridge",
1765+
EnableIPv4: &enableIPv4,
1766+
EnableIPv6: &enableIPv6,
1767+
},
1768+
},
1769+
Environment: types.Mapping{
1770+
"COMPOSE_PROJECT_NAME": "load-network-ipv6only",
1771+
},
1772+
}
1773+
assert.DeepEqual(t, config, expected, cmpopts.EquateEmpty())
1774+
}
1775+
17281776
func TestLoadNetworkLinkLocalIPs(t *testing.T) {
17291777
config, err := loadYAML(`
17301778
name: load-network-link-local-ips

schema/compose-spec.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@
743743
"patternProperties": {"^x-": {}}
744744
},
745745
"internal": {"type": ["boolean", "string"]},
746+
"enable_ipv4": {"type": ["boolean", "string"]},
746747
"enable_ipv6": {"type": ["boolean", "string"]},
747748
"attachable": {"type": ["boolean", "string"]},
748749
"labels": {"$ref": "#/definitions/list_or_dict"}

types/derived.gen.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ type NetworkConfig struct {
688688
Attachable bool `yaml:"attachable,omitempty" json:"attachable,omitempty"`
689689
Labels Labels `yaml:"labels,omitempty" json:"labels,omitempty"`
690690
CustomLabels Labels `yaml:"-" json:"-"`
691+
EnableIPv4 *bool `yaml:"enable_ipv4,omitempty" json:"enable_ipv4,omitempty"`
691692
EnableIPv6 *bool `yaml:"enable_ipv6,omitempty" json:"enable_ipv6,omitempty"`
692693
Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
693694
}

0 commit comments

Comments
 (0)