(ctx devspacecontext.Context, hook *latest.HookConfig, podContainer *selector.SelectedPodContainer)
| 29 | type remoteDownloadHook struct{} |
| 30 | |
| 31 | func (r *remoteDownloadHook) ExecuteRemotely(ctx devspacecontext.Context, hook *latest.HookConfig, podContainer *selector.SelectedPodContainer) error { |
| 32 | containerPath := "." |
| 33 | if hook.Download.ContainerPath != "" { |
| 34 | containerPath = hook.Download.ContainerPath |
| 35 | } |
| 36 | localPath := "." |
| 37 | if hook.Download.LocalPath != "" { |
| 38 | localPath = hook.Download.LocalPath |
| 39 | } |
| 40 | localPath = ctx.ResolvePath(localPath) |
| 41 | |
| 42 | ctx.Log().Infof("Execute hook '%s' in container '%s/%s/%s'", ansi.Color(hookName(hook), "white+b"), podContainer.Pod.Namespace, podContainer.Pod.Name, podContainer.Container.Name) |
| 43 | ctx.Log().Infof("Copy container '%s' -> local '%s'", containerPath, localPath) |
| 44 | // Make sure the target folder exists |
| 45 | destDir := path.Dir(localPath) |
| 46 | if len(destDir) > 0 { |
| 47 | _ = os.MkdirAll(destDir, 0755) |
| 48 | } |
| 49 | |
| 50 | // Download the files |
| 51 | err := download(ctx.Context(), ctx.KubeClient(), podContainer.Pod, podContainer.Container.Name, localPath, containerPath, ctx.Log()) |
| 52 | if err != nil { |
| 53 | return errors.Errorf("error in container '%s/%s/%s': %v", podContainer.Pod.Namespace, podContainer.Pod.Name, podContainer.Container.Name, err) |
| 54 | } |
| 55 | |
| 56 | return nil |
| 57 | } |
| 58 | |
| 59 | func download(ctx context.Context, client kubectl.Client, pod *k8sv1.Pod, container string, localPath string, containerPath string, log logpkg.Logger) error { |
| 60 | prefix := getPrefix(containerPath) |
nothing calls this directly
no test coverage detected