mirror of
https://gitea.elkins.co/Networking/ccl.git
synced 2025-03-09 12:41:40 -05:00
Add Expose{Tcp,Udp} to container def
This commit is contained in:
parent
e56d2c12d2
commit
07492e04b1
@ -52,6 +52,8 @@ type Container struct {
|
|||||||
Restart string `toml:"restart,omitempty"`
|
Restart string `toml:"restart,omitempty"`
|
||||||
Umask null.Int `toml:"umask,omitempty"`
|
Umask null.Int `toml:"umask,omitempty"`
|
||||||
User string `toml:"user,omitempty"`
|
User string `toml:"user,omitempty"`
|
||||||
|
ExposeTcp []uint16 `toml:"expose_tcp,omitempty"`
|
||||||
|
ExposeUdp []uint16 `toml:"expose_udp,omitempty"`
|
||||||
|
|
||||||
conn context.Context
|
conn context.Context
|
||||||
cdata *define.InspectContainerData
|
cdata *define.InspectContainerData
|
||||||
@ -115,8 +117,8 @@ func (c *Container) pull() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Container) newCommandSet(op string, cmds cmd.Commands) cmd.CommandSet {
|
func (c *Container) newCommandSet(op string, cmds cmd.Commands) cmd.CommandSet {
|
||||||
return cmd.CommandSet {
|
return cmd.CommandSet{
|
||||||
ID: fmt.Sprintf("%s-%s", op, c.Name),
|
ID: fmt.Sprintf("%s-%s", op, c.Name),
|
||||||
Commands: cmds,
|
Commands: cmds,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,6 +160,14 @@ func (c *Container) CreateCommands() cmd.CommandSet {
|
|||||||
dns = append(dns, c.Networks[i].DNS...)
|
dns = append(dns, c.Networks[i].DNS...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expose := map[uint16]string{}
|
||||||
|
for _, p := range c.ExposeTcp {
|
||||||
|
expose[p] = "tcp"
|
||||||
|
}
|
||||||
|
for _, p := range c.ExposeUdp {
|
||||||
|
expose[p] = "udp"
|
||||||
|
}
|
||||||
|
|
||||||
spec := specgen.SpecGenerator{
|
spec := specgen.SpecGenerator{
|
||||||
ContainerBasicConfig: specgen.ContainerBasicConfig{
|
ContainerBasicConfig: specgen.ContainerBasicConfig{
|
||||||
Name: c.Name,
|
Name: c.Name,
|
||||||
@ -174,8 +184,10 @@ func (c *Container) CreateCommands() cmd.CommandSet {
|
|||||||
Mounts: c.Mounts,
|
Mounts: c.Mounts,
|
||||||
},
|
},
|
||||||
ContainerNetworkConfig: specgen.ContainerNetworkConfig{
|
ContainerNetworkConfig: specgen.ContainerNetworkConfig{
|
||||||
Networks: nets,
|
Networks: nets,
|
||||||
DNSServers: dns,
|
DNSServers: dns,
|
||||||
|
Expose: expose,
|
||||||
|
PublishExposedPorts: len(expose) > 0,
|
||||||
},
|
},
|
||||||
ContainerSecurityConfig: specgen.ContainerSecurityConfig{
|
ContainerSecurityConfig: specgen.ContainerSecurityConfig{
|
||||||
User: c.User,
|
User: c.User,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user