Init all the fields of a compose project at once

This commit is contained in:
Djordje Lukic 2020-05-04 11:51:40 +02:00
parent 28808f3f6d
commit 092c432028
1 changed files with 10 additions and 7 deletions

View File

@ -92,8 +92,6 @@ func (cs *containerService) List(ctx context.Context) ([]containers.Container, e
}
func (cs *containerService) Run(ctx context.Context, r containers.ContainerConfig) error {
var project compose.Project
project.Name = r.ID
var ports []types.ServicePortConfig
for _, p := range r.Ports {
ports = append(ports, types.ServicePortConfig{
@ -101,12 +99,17 @@ func (cs *containerService) Run(ctx context.Context, r containers.ContainerConfi
Published: p.Source,
})
}
project.Services = []types.ServiceConfig{
project := compose.Project{
Name: r.ID,
Config: types.Config{
Services: []types.ServiceConfig{
{
Name: r.ID,
Image: r.Image,
Ports: ports,
},
},
},
}
logrus.Debugf("Running container %q with name %q\n", r.Image, r.ID)