-
Notifications
You must be signed in to change notification settings - Fork 26
/
service.go
42 lines (35 loc) · 1023 Bytes
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package stack
import (
"fmt"
"github.com/docker/docker/api/types/container"
)
const (
// ContainerNamePrefix is the prefix added to all neo-local containers.
ContainerNamePrefix = "coz_neo-local_"
)
type (
// Service defines a Docker container to run within the stack.
Service struct {
Author string
ContainerConfig *container.Config
DependsOn []string
HostConfig *container.HostConfig
Image string
Name string
Tag string
}
)
// Config returns the full launch config for creating the container.
func (s Service) Config() *container.Config {
config := s.ContainerConfig
config.Image = s.ImageName()
return config
}
// ContainerName is the Docker container name.
func (s Service) ContainerName() string {
return fmt.Sprintf("%s%s", ContainerNamePrefix, s.Name)
}
// ImageName is the full Docker image name for the service, including the tag.
func (s Service) ImageName() string {
return fmt.Sprintf("%s/%s:%s", s.Author, s.Image, s.Tag)
}