@@ -69,15 +69,13 @@ func runRun(ctx context.Context, opts runOptions) error {
69
69
return err
70
70
}
71
71
72
- originalServices := project .Services
73
72
_ , err = progress .Run (ctx , func (ctx context.Context ) (string , error ) {
74
- return "" , startDependencies (ctx , c , project , opts .Service )
73
+ return "" , startDependencies (ctx , c , * project , opts .Service )
75
74
})
76
75
if err != nil {
77
76
return err
78
77
}
79
78
80
- project .Services = originalServices
81
79
// start container and attach to container streams
82
80
runOpts := compose.RunOptions {
83
81
Service : opts .Service ,
@@ -90,21 +88,24 @@ func runRun(ctx context.Context, opts runOptions) error {
90
88
return c .ComposeService ().RunOneOffContainer (ctx , project , runOpts )
91
89
}
92
90
93
- func startDependencies (ctx context.Context , c * client.Client , project * types.Project , requestedService string ) error {
94
- originalServices := project .Services
91
+ func startDependencies (ctx context.Context , c * client.Client , project types.Project , requestedServiceName string ) error {
95
92
dependencies := types.Services {}
96
- for _ , service := range originalServices {
97
- if service .Name != requestedService {
93
+ var requestedService types.ServiceConfig
94
+ for _ , service := range project .Services {
95
+ if service .Name != requestedServiceName {
98
96
dependencies = append (dependencies , service )
97
+ } else {
98
+ requestedService = service
99
99
}
100
100
}
101
+
101
102
project .Services = dependencies
102
- if err := c .ComposeService ().Create (ctx , project , compose.CreateOptions {}); err != nil {
103
+ project .DisabledServices = append (project .DisabledServices , requestedService )
104
+ if err := c .ComposeService ().Create (ctx , & project , compose.CreateOptions {}); err != nil {
103
105
return err
104
106
}
105
- if err := c .ComposeService ().Start (ctx , project , compose.StartOptions {}); err != nil {
107
+ if err := c .ComposeService ().Start (ctx , & project , compose.StartOptions {}); err != nil {
106
108
return err
107
109
}
108
110
return nil
109
-
110
111
}
0 commit comments