Skip to content

Commit 8fe39cf

Browse files
committed
dockerfile: split Mount struct to dockerui/types
Will be used in the follow-up commits for implementing "Dockerfile hooks" (issue 4576) Signed-off-by: Akihiro Suda <[email protected]>
1 parent 85401df commit 8fe39cf

File tree

2 files changed

+46
-24
lines changed

2 files changed

+46
-24
lines changed

frontend/dockerfile/instructions/commands_runmount.go

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@ import (
77
"strings"
88

99
"github.com/docker/go-units"
10+
"github.com/moby/buildkit/frontend/dockerui/types"
1011
"github.com/moby/buildkit/util/suggest"
1112
"github.com/pkg/errors"
1213
)
1314

14-
type MountType string
15+
type MountType = types.MountType
1516

1617
const (
17-
MountTypeBind MountType = "bind"
18-
MountTypeCache MountType = "cache"
19-
MountTypeTmpfs MountType = "tmpfs"
20-
MountTypeSecret MountType = "secret"
21-
MountTypeSSH MountType = "ssh"
18+
MountTypeBind = types.MountTypeBind
19+
MountTypeCache = types.MountTypeCache
20+
MountTypeTmpfs = types.MountTypeTmpfs
21+
MountTypeSecret = types.MountTypeSecret
22+
MountTypeSSH = types.MountTypeSSH
2223
)
2324

2425
var allowedMountTypes = map[MountType]struct{}{
@@ -29,12 +30,12 @@ var allowedMountTypes = map[MountType]struct{}{
2930
MountTypeSSH: {},
3031
}
3132

32-
type ShareMode string
33+
type ShareMode = types.ShareMode
3334

3435
const (
35-
MountSharingShared ShareMode = "shared"
36-
MountSharingPrivate ShareMode = "private"
37-
MountSharingLocked ShareMode = "locked"
36+
MountSharingShared = types.MountSharingShared
37+
MountSharingPrivate = types.MountSharingPrivate
38+
MountSharingLocked = types.MountSharingLocked
3839
)
3940

4041
var allowedSharingModes = map[ShareMode]struct{}{
@@ -113,20 +114,7 @@ type mountState struct {
113114
mounts []*Mount
114115
}
115116

116-
type Mount struct {
117-
Type MountType
118-
From string
119-
Source string
120-
Target string
121-
ReadOnly bool
122-
SizeLimit int64
123-
CacheID string
124-
CacheSharing ShareMode
125-
Required bool
126-
Mode *uint64
127-
UID *uint64
128-
GID *uint64
129-
}
117+
type Mount = types.Mount
130118

131119
func parseMount(val string, expander SingleWordExpander) (*Mount, error) {
132120
csvReader := csv.NewReader(strings.NewReader(val))

frontend/dockerui/types/mount.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package types
2+
3+
type MountType string
4+
5+
const (
6+
MountTypeBind MountType = "bind"
7+
MountTypeCache MountType = "cache"
8+
MountTypeTmpfs MountType = "tmpfs"
9+
MountTypeSecret MountType = "secret"
10+
MountTypeSSH MountType = "ssh"
11+
)
12+
13+
type ShareMode string
14+
15+
const (
16+
MountSharingShared ShareMode = "shared"
17+
MountSharingPrivate ShareMode = "private"
18+
MountSharingLocked ShareMode = "locked"
19+
)
20+
21+
type Mount struct {
22+
Type MountType
23+
From string
24+
Source string
25+
Target string
26+
ReadOnly bool
27+
SizeLimit int64
28+
CacheID string
29+
CacheSharing ShareMode
30+
Required bool
31+
Mode *uint64
32+
UID *uint64
33+
GID *uint64
34+
}

0 commit comments

Comments
 (0)