forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.go
28 lines (25 loc) · 831 Bytes
/
util.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
package builder
import (
buildapi "github.com/openshift/origin/pkg/build/api"
)
type Builder interface {
Build() error
}
// getBuildEnvVars returns a map with the environment variables that should be added
// to the built image
func getBuildEnvVars(build *buildapi.Build) map[string]string {
envVars := map[string]string{
"OPENSHIFT_BUILD_NAME": build.Name,
"OPENSHIFT_BUILD_NAMESPACE": build.Namespace,
"OPENSHIFT_BUILD_SOURCE": build.Parameters.Source.Git.URI,
}
if build.Parameters.Source.Git.Ref != "" {
envVars["OPENSHIFT_BUILD_REFERENCE"] = build.Parameters.Source.Git.Ref
}
if build.Parameters.Revision != nil &&
build.Parameters.Revision.Git != nil &&
build.Parameters.Revision.Git.Commit != "" {
envVars["OPENSHIFT_BUILD_COMMIT"] = build.Parameters.Revision.Git.Commit
}
return envVars
}