(ctx devspacecontext.Context, options targetselector.Options)
| 192 | } |
| 193 | |
| 194 | func restartContainer(ctx devspacecontext.Context, options targetselector.Options) error { |
| 195 | options = options.WithWait(false) |
| 196 | container, err := targetselector.NewTargetSelector(options).SelectSingleContainer(ctx.Context(), ctx.KubeClient(), ctx.Log()) |
| 197 | if err != nil { |
| 198 | return errors.Errorf("Error selecting pod: %v", err) |
| 199 | } |
| 200 | |
| 201 | err = inject.InjectDevSpaceHelper(ctx.Context(), ctx.KubeClient(), container.Pod, container.Container.Name, "", ctx.Log()) |
| 202 | if err != nil { |
| 203 | return errors.Wrap(err, "inject devspace helper") |
| 204 | } |
| 205 | |
| 206 | stdOut, stdErr, err := ctx.KubeClient().ExecBuffered(ctx.Context(), container.Pod, container.Container.Name, []string{inject.DevSpaceHelperContainerPath, "restart"}, nil) |
| 207 | if err != nil { |
| 208 | return fmt.Errorf("error restarting container %s in pod %s/%s: %s %s => %v", container.Container.Name, container.Pod.Namespace, container.Pod.Name, string(stdOut), string(stdErr), err) |
| 209 | } |
| 210 | |
| 211 | ctx.Log().Donef("Successfully restarted container %s in pod %s/%s", container.Container.Name, container.Pod.Namespace, container.Pod.Name) |
| 212 | return nil |
| 213 | } |
no test coverage detected