MCPcopy Index your code
hub / github.com/devspace-sh/devspace / restartContainer

Function restartContainer

cmd/restart.go:194–213  ·  view source on GitHub ↗
(ctx devspacecontext.Context, options targetselector.Options)

Source from the content-addressed store, hash-verified

192}
193
194func 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}

Callers 1

RunMethod · 0.85

Calls 10

NewTargetSelectorFunction · 0.92
InjectDevSpaceHelperFunction · 0.92
WithWaitMethod · 0.80
SelectSingleContainerMethod · 0.65
ContextMethod · 0.65
KubeClientMethod · 0.65
LogMethod · 0.65
ExecBufferedMethod · 0.65
ErrorfMethod · 0.45
DonefMethod · 0.45

Tested by

no test coverage detected