MCPcopy Create free account
hub / github.com/devspace-sh/devspace / ExecuteRemotely

Method ExecuteRemotely

pkg/devspace/hook/download.go:31–57  ·  view source on GitHub ↗
(ctx devspacecontext.Context, hook *latest.HookConfig, podContainer *selector.SelectedPodContainer)

Source from the content-addressed store, hash-verified

29type remoteDownloadHook struct{}
30
31func (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
59func download(ctx context.Context, client kubectl.Client, pod *k8sv1.Pod, container string, localPath string, containerPath string, log logpkg.Logger) error {
60 prefix := getPrefix(containerPath)

Callers

nothing calls this directly

Calls 8

hookNameFunction · 0.85
downloadFunction · 0.85
ResolvePathMethod · 0.65
LogMethod · 0.65
ContextMethod · 0.65
KubeClientMethod · 0.65
InfofMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected