forked from vmware-archive/atc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
container_spec.go
74 lines (59 loc) · 1.51 KB
/
container_spec.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
package worker
import (
"fmt"
"io"
"strings"
"github.com/concourse/atc"
)
type WorkerSpec struct {
Platform string
ResourceType string
Tags []string
TeamID int
}
type ContainerSpec struct {
Platform string
Tags []string
TeamID int
ImageSpec ImageSpec
Ephemeral bool
Env []string
// Not Copy-on-Write. Used for a single mount in Get containers.
Inputs []VolumeMount
// Copy-on-Write. Used for mounting multiple resources into a Put container.
Outputs []VolumeMount
// Optional user to run processes as. Overwrites the one specified in the docker image.
User string
}
type ImageSpec struct {
ResourceType string
ImageURL string
ImageResource *atc.ImageResource
ImageVolumeAndMetadata ImageVolumeAndMetadata
Privileged bool
}
type ImageVolumeAndMetadata struct {
Volume Volume
MetadataReader io.ReadCloser
}
func (spec ContainerSpec) WorkerSpec() WorkerSpec {
return WorkerSpec{
ResourceType: spec.ImageSpec.ResourceType,
Platform: spec.Platform,
Tags: spec.Tags,
TeamID: spec.TeamID,
}
}
func (spec WorkerSpec) Description() string {
var attrs []string
if spec.ResourceType != "" {
attrs = append(attrs, fmt.Sprintf("resource type '%s'", spec.ResourceType))
}
if spec.Platform != "" {
attrs = append(attrs, fmt.Sprintf("platform '%s'", spec.Platform))
}
for _, tag := range spec.Tags {
attrs = append(attrs, fmt.Sprintf("tag '%s'", tag))
}
return strings.Join(attrs, ", ")
}