mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
encode and decode published ports using container labels
This commit is contained in:
@@ -238,6 +238,18 @@ func (cli *Client) runContainer(
|
||||
config.Labels[api.LabelServiceMode] = api.ServiceModeGlobal
|
||||
}
|
||||
|
||||
if len(spec.Ports) > 0 {
|
||||
encodedPorts := make([]string, len(spec.Ports))
|
||||
for i, p := range spec.Ports {
|
||||
encodedPorts[i], err = p.String()
|
||||
if err != nil {
|
||||
return resp, fmt.Errorf("encode service port spec: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
config.Labels[api.LabelServicePorts] = strings.Join(encodedPorts, ",")
|
||||
}
|
||||
|
||||
hostConfig := &container.HostConfig{
|
||||
Init: spec.Container.Init,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user