-
Notifications
You must be signed in to change notification settings - Fork 1
/
funcAddFileOrFolderToLinkBetweenConputerHostAndContainer.go
58 lines (52 loc) · 1.45 KB
/
funcAddFileOrFolderToLinkBetweenConputerHostAndContainer.go
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
package iotmakerdockerbuilder
import (
"github.com/docker/docker/api/types/mount"
iotmakerdocker "github.com/helmutkemper/iotmaker.docker/v1.0.1"
"github.com/helmutkemper/util"
"path/filepath"
)
// AddFileOrFolderToLinkBetweenConputerHostAndContainer
//
// English:
//
// Links a file or folder between the computer host and the container.
//
// Input:
// computerHostPath: Path of the file or folder inside the host computer.
// insideContainerPath: Path inside the container.
//
// Output:
// err: Default error object.
//
// Português:
//
// Vincula um arquivo ou pasta entre o computador e o container.
//
// Entrada:
// computerHostPath: Caminho do arquivo ou pasta no computador hospedeiro.
// insideContainerPath: Caminho dentro do container.
//
// Output:
// err: Objeto de erro padrão.
func (e *ContainerBuilder) AddFileOrFolderToLinkBetweenConputerHostAndContainer(computerHostPath, insideContainerPath string) (err error) {
if e.volumes == nil {
e.volumes = make([]mount.Mount, 0)
}
computerHostPath, err = filepath.Abs(computerHostPath)
if err != nil {
util.TraceToLog()
return
}
e.volumes = append(
e.volumes,
mount.Mount{
// bind - is the type for mounting host dir (real folder inside computer where this code work)
Type: iotmakerdocker.KVolumeMountTypeBindString,
// path inside host machine
Source: computerHostPath,
// path inside image
Target: insideContainerPath,
},
)
return
}