Skip to content

Commit 6b0de65

Browse files
Aaron Schlesingeraledbf
authored andcommitted
ref(k8s_util.go): add utilities for creating pods in-memory for k8s
1 parent 3b0c36d commit 6b0de65

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

pkg/gitreceive/k8s_util.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package gitreceive
2+
3+
import (
4+
"fmt"
5+
6+
"code.google.com/p/go-uuid/uuid"
7+
"k8s.io/kubernetes/pkg/api"
8+
)
9+
10+
const (
11+
podKind = "Pod"
12+
v1Version = "v1"
13+
)
14+
15+
func dockerBuilderPodName(appName, shortSha) string {
16+
uid := uuid.New()[:8]
17+
return fmt.Sprintf("dockerbuild-%s-%s-%s", appName, shortSha, uid)
18+
}
19+
20+
func slugBuilderPodName(appName, shortSha) string {
21+
uid := uuid.New()[:8]
22+
return fmt.Sprintf("slugbuild-%s-%s-%s", appName, shortSha, uid)
23+
}
24+
25+
func dockerBuilderPod(debug, withAuth bool, name, namespace, heritageLabel, versionLabel, tarURL, imageName string) *api.Pod {
26+
return &api.Pod{
27+
Kind: podKind,
28+
APIVersion: v1Version,
29+
Name: name,
30+
Namespace: namespace,
31+
Labels: map[string]string{
32+
"heritage": heritageLabel,
33+
"version": versionLabel,
34+
},
35+
Spec: api.PodSpec{},
36+
}
37+
}
38+
39+
func slugbuilderPod(debug, withAuth bool, name, namespace, heritageLabel, versionLabel, tarURL, putURL, buildpackURL string) *api.Pod {
40+
return &api.Pod{
41+
Kind: podKind,
42+
APIVersion: v1Version,
43+
Name: name,
44+
Namespace: namespace,
45+
Labels: map[string]string{
46+
"heritage": heritageLabel,
47+
"version": versionLabel,
48+
},
49+
Spec: api.PodSpec{},
50+
}
51+
}

0 commit comments

Comments
 (0)