mirror of
https://github.com/rancher/os.git
synced 2025-07-16 16:11:03 +00:00
Add option to disable startup of services
This commit is contained in:
parent
a1f912c4d5
commit
36f5b16194
@ -47,17 +47,17 @@ type Config struct {
|
|||||||
CloudInit CloudInit `yaml:"cloud_init,omitempty"`
|
CloudInit CloudInit `yaml:"cloud_init,omitempty"`
|
||||||
Console ConsoleConfig `yaml:"console,omitempty"`
|
Console ConsoleConfig `yaml:"console,omitempty"`
|
||||||
Debug bool `yaml:"debug,omitempty"`
|
Debug bool `yaml:"debug,omitempty"`
|
||||||
//Disable []string `yaml:"disable,omitempty"`
|
Disable []string `yaml:"disable,omitempty"`
|
||||||
EnabledAddons []string `yaml:"enabled_addons,omitempty"`
|
EnabledAddons []string `yaml:"enabled_addons,omitempty"`
|
||||||
Modules []string `yaml:"modules,omitempty"`
|
Modules []string `yaml:"modules,omitempty"`
|
||||||
Network NetworkConfig `yaml:"network,omitempty"`
|
Network NetworkConfig `yaml:"network,omitempty"`
|
||||||
Ssh SshConfig `yaml:"ssh,omitempty"`
|
Ssh SshConfig `yaml:"ssh,omitempty"`
|
||||||
State StateConfig `yaml:"state,omitempty"`
|
State StateConfig `yaml:"state,omitempty"`
|
||||||
SystemContainers map[string]*project.ServiceConfig `yaml:"system_containers,omitempty"`
|
SystemContainers map[string]*project.ServiceConfig `yaml:"system_containers,omitempty"`
|
||||||
SystemDocker DockerConfig `yaml:"system_docker,omitempty"`
|
SystemDocker DockerConfig `yaml:"system_docker,omitempty"`
|
||||||
Upgrade UpgradeConfig `yaml:"upgrade,omitempty"`
|
Upgrade UpgradeConfig `yaml:"upgrade,omitempty"`
|
||||||
UserContainers []ContainerConfig `yaml:"user_containers,omitempty"`
|
UserContainers []ContainerConfig `yaml:"user_containers,omitempty"`
|
||||||
UserDocker DockerConfig `yaml:"user_docker,omitempty"`
|
UserDocker DockerConfig `yaml:"user_docker,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConsoleConfig struct {
|
type ConsoleConfig struct {
|
||||||
|
@ -4,10 +4,12 @@ import (
|
|||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/rancherio/os/config"
|
"github.com/rancherio/os/config"
|
||||||
|
"github.com/rancherio/os/util"
|
||||||
"github.com/rancherio/rancher-compose/project"
|
"github.com/rancherio/rancher-compose/project"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ContainerFactory struct {
|
type ContainerFactory struct {
|
||||||
|
cfg *config.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
type containerBasedService struct {
|
type containerBasedService struct {
|
||||||
@ -18,11 +20,23 @@ type containerBasedService struct {
|
|||||||
cfg *config.Config
|
cfg *config.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewContainerFactory(cfg *config.Config) *ContainerFactory {
|
||||||
|
return &ContainerFactory{
|
||||||
|
cfg: cfg,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *containerBasedService) Up() error {
|
func (c *containerBasedService) Up() error {
|
||||||
container := c.container
|
container := c.container
|
||||||
containerCfg := c.container.ContainerCfg
|
containerCfg := c.container.ContainerCfg
|
||||||
|
|
||||||
if containerCfg.CreateOnly {
|
create := containerCfg.CreateOnly
|
||||||
|
|
||||||
|
if util.Contains(c.cfg.Disable, c.name) {
|
||||||
|
create = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if create {
|
||||||
container.Create()
|
container.Create()
|
||||||
c.project.Notify(project.CONTAINER_CREATED, c, map[string]string{
|
c.project.Notify(project.CONTAINER_CREATED, c, map[string]string{
|
||||||
project.CONTAINER_ID: container.Container.ID,
|
project.CONTAINER_ID: container.Container.ID,
|
||||||
@ -65,5 +79,6 @@ func (c *ContainerFactory) Create(project *project.Project, name string, service
|
|||||||
project: project,
|
project: project,
|
||||||
container: container,
|
container: container,
|
||||||
serviceConfig: serviceConfig,
|
serviceConfig: serviceConfig,
|
||||||
|
cfg: c.cfg,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user