(ctx context.Context, explanation string, cfg *ServiceConfig)
| 119 | } |
| 120 | |
| 121 | func (env *Environment) AddService(ctx context.Context, explanation string, cfg *ServiceConfig) (*Service, error) { |
| 122 | if env.State.Config.Services.Get(cfg.Name) != nil { |
| 123 | return nil, fmt.Errorf("service %s already exists", cfg.Name) |
| 124 | } |
| 125 | svc, err := env.startService(ctx, cfg) |
| 126 | if err != nil { |
| 127 | return nil, err |
| 128 | } |
| 129 | env.State.Config.Services = append(env.State.Config.Services, cfg) |
| 130 | env.Services = append(env.Services, svc) |
| 131 | |
| 132 | state := env.container().WithServiceBinding(cfg.Name, svc.svc) |
| 133 | if err := env.apply(ctx, state); err != nil { |
| 134 | return nil, err |
| 135 | } |
| 136 | |
| 137 | env.Notes.Add("Add service %s\n%s\n\n", cfg.Name, explanation) |
| 138 | |
| 139 | return svc, nil |
| 140 | } |
no test coverage detected