forked from palantir/godel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.go
92 lines (80 loc) · 2.58 KB
/
docker.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright 2016 Palantir Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package params
import (
"github.com/pkg/errors"
)
type DockerDepType string
type DockerImageType string
const (
DockerDepSLS DockerDepType = "sls"
DockerDepBin DockerDepType = "bin"
DockerDepRPM DockerDepType = "rpm"
DockerDepDocker DockerDepType = "docker"
DefaultDockerImageType DockerImageType = "default"
SLSDockerImageType DockerImageType = "sls"
)
type DockerDep struct {
Product string
Type DockerDepType
TargetFile string
}
type DockerImage struct {
// Repository and Tag are the part of the image coordinates.
// For example, in alpine:latest, alpine is the repository
// and the latest is the tag
Repository string
Tag string
// ContextDir is the directory in which the docker build task is executed.
ContextDir string
BuildArgsScript string
// DistDeps is a slice of DockerDistDep.
// DockerDistDep contains a product, dist type and target file.
// For a particular product's dist type, we create a link from its output
// inside the ContextDir with the name specified in target file.
// This will be used to order the dist tasks such that all the dependent
// products' dist tasks will be executed first, after which the dist tasks for the
// current product are executed.
Deps []DockerDep
Info DockerImageInfo
}
type DockerImageInfo interface {
Type() DockerImageType
}
type DefaultDockerImageInfo struct{}
func (info *DefaultDockerImageInfo) Type() DockerImageType {
return DefaultDockerImageType
}
type SLSDockerImageInfo struct {
GroupID string
ProuductType string
Extensions map[string]interface{}
}
func (info *SLSDockerImageInfo) Type() DockerImageType {
return SLSDockerImageType
}
func ToDockerDepType(dep string) (DockerDepType, error) {
switch dep {
case "sls":
return DockerDepSLS, nil
case "rpm":
return DockerDepRPM, nil
case "bin":
return DockerDepBin, nil
case "docker":
return DockerDepDocker, nil
default:
return "", errors.New("Invalid docker dependency type")
}
}