mirror of
https://github.com/rancher/os.git
synced 2025-08-31 14:23:11 +00:00
Add option to disable startup of services
This commit is contained in:
@@ -4,10 +4,12 @@ import (
|
||||
log "github.com/Sirupsen/logrus"
|
||||
|
||||
"github.com/rancherio/os/config"
|
||||
"github.com/rancherio/os/util"
|
||||
"github.com/rancherio/rancher-compose/project"
|
||||
)
|
||||
|
||||
type ContainerFactory struct {
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
type containerBasedService struct {
|
||||
@@ -18,11 +20,23 @@ type containerBasedService struct {
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
func NewContainerFactory(cfg *config.Config) *ContainerFactory {
|
||||
return &ContainerFactory{
|
||||
cfg: cfg,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *containerBasedService) Up() error {
|
||||
container := c.container
|
||||
containerCfg := c.container.ContainerCfg
|
||||
|
||||
if containerCfg.CreateOnly {
|
||||
create := containerCfg.CreateOnly
|
||||
|
||||
if util.Contains(c.cfg.Disable, c.name) {
|
||||
create = true
|
||||
}
|
||||
|
||||
if create {
|
||||
container.Create()
|
||||
c.project.Notify(project.CONTAINER_CREATED, c, map[string]string{
|
||||
project.CONTAINER_ID: container.Container.ID,
|
||||
@@ -65,5 +79,6 @@ func (c *ContainerFactory) Create(project *project.Project, name string, service
|
||||
project: project,
|
||||
container: container,
|
||||
serviceConfig: serviceConfig,
|
||||
cfg: c.cfg,
|
||||
}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user