forked from helmutkemper/iotmaker.docker.builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuncContainerCopyTo.go
More file actions
67 lines (62 loc) · 1.32 KB
/
funcContainerCopyTo.go
File metadata and controls
67 lines (62 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package iotmakerdockerbuilder
import (
"github.com/helmutkemper/util"
"io"
"os"
)
// ContainerCopyTo
//
// Português:
//
// Copia um arquivo contido no computador local para dentro do container
//
// Entrada:
// hostPathList: lista de arquivos a serem salvos no computador hospedeiro (caminho + nome do
// arquivo)
// containerPathList: lista de arquivos contidos no container (apenas o caminho)
//
// Saída:
// err: Objeto de erro padrão
//
// English:
//
// Copy a file contained on the local computer into the container
//
// Input:
// hostPathList: list of files to be saved on the host computer (path + filename)
// containerPathList: list of files contained in the container (path only)
//
// Output:
// err: standard error object
func (e *ContainerBuilder) ContainerCopyTo(
hostPathList []string,
containerPathList []string,
) (
err error,
) {
if e.containerID == "" {
err = e.getIdByContainerName()
if err != nil {
util.TraceToLog()
return
}
}
var content io.Reader
for k, destinationPath := range hostPathList {
content, err = os.Open(destinationPath)
if err != nil {
util.TraceToLog()
return
}
err = e.dockerSys.ContainerCopyTo(
e.containerID,
containerPathList[k],
content,
)
if err != nil {
util.TraceToLog()
return
}
}
return
}