-
Notifications
You must be signed in to change notification settings - Fork 0
/
targets.go
77 lines (62 loc) · 1.51 KB
/
targets.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package config
import (
"strings"
"github.com/dronestock/docker/internal/internal/constant"
"github.com/goexl/gox"
)
type Targets []*Target
func (t *Targets) Runnable(registries *Registries, docker *Docker) (runnable bool) {
buildPushedCount := 0
for _, target := range *t {
if target.BuildWithPush(registries, docker) {
buildPushedCount = buildPushedCount + 1
}
}
if len(*t) == buildPushedCount { // 如果全部都在编译时就推送了,不执行推送步骤
runnable = false
} else { // 视仓库数量为准
runnable = 0 != len(*registries)
}
return
}
func (t *Targets) Registries() (registries Registries) {
registries = make(Registries, 0, len(*t))
for _, target := range *t {
registries = append(registries, target.AllRegistries()...)
}
return
}
func (t *Targets) Platforms() (platforms string) {
all := make([]string, 0, len(*t))
for _, target := range *t {
all = gox.Ift("" != target.PlatformArgument(), append(all, target.PlatformArgument()), all)
}
if 0 != len(all) {
platforms = strings.Join(all, constant.Comma)
}
return
}
func (t *Targets) BinfmtNeedSetup(docker *Docker) (fmt bool) {
if "/var/run/docker.sock" == docker.Host {
fmt = t.qemu()
}
return
}
func (t *Targets) DriverNeedSetup() (need bool) {
for _, target := range *t {
need = strings.Contains(target.PlatformArgument(), constant.Comma)
if need {
break
}
}
return
}
func (t *Targets) qemu() (qemu bool) {
for _, target := range *t {
qemu = target.Qemu()
if qemu {
break
}
}
return
}