mirror of
https://github.com/docker/compose.git
synced 2026-08-30 13:31:54 +00:00
Fix linter problems
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
This commit is contained in:
parent
762f462d80
commit
d2fece3311
3 changed files with 3 additions and 57 deletions
|
|
@ -1,54 +0,0 @@
|
|||
package run
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/api/containers"
|
||||
)
|
||||
|
||||
type runOpts struct {
|
||||
name string
|
||||
publish []string
|
||||
volumes []string
|
||||
}
|
||||
|
||||
func toPorts(ports []string) ([]containers.Port, error) {
|
||||
var result []containers.Port
|
||||
|
||||
for _, port := range ports {
|
||||
parts := strings.Split(port, ":")
|
||||
if len(parts) != 2 {
|
||||
return nil, fmt.Errorf("unable to parse ports %q", port)
|
||||
}
|
||||
source, err := strconv.Atoi(parts[0])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
destination, err := strconv.Atoi(parts[1])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result = append(result, containers.Port{
|
||||
HostPort: uint32(source),
|
||||
ContainerPort: uint32(destination),
|
||||
})
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *runOpts) toContainerConfig(image string) (containers.ContainerConfig, error) {
|
||||
publish, err := toPorts(r.publish)
|
||||
if err != nil {
|
||||
return containers.ContainerConfig{}, err
|
||||
}
|
||||
|
||||
return containers.ContainerConfig{
|
||||
ID: r.name,
|
||||
Image: image,
|
||||
Ports: publish,
|
||||
Volumes: r.volumes,
|
||||
}, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue