-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.go
More file actions
82 lines (71 loc) · 1.6 KB
/
common.go
File metadata and controls
82 lines (71 loc) · 1.6 KB
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
package kubeclient
import (
"fmt"
"github.com/codegp/env"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
)
const localStoreVolumeName string = "local-store-vol"
func registry(image string) string {
return fmt.Sprintf("gcr.io/%s/%s:latest", env.GCloudProjectID(), image)
}
func configEnv() []api.EnvVar {
return []api.EnvVar{
configEnvVar("GCLOUD_PROJECT_ID", "gcloud-project-id"),
configEnvVar("IS_LOCAL", "is-local"),
configEnvVar("DATASTORE_EMULATOR_HOST", "datastore-emulator-host"),
}
}
func configEnvVar(envVarName, configName string) api.EnvVar {
return api.EnvVar{
Name: envVarName,
ValueFrom: &api.EnvVarSource{
ConfigMapKeyRef: &api.ConfigMapKeySelector{
LocalObjectReference: api.LocalObjectReference{
Name: "codegp-config",
},
Key: configName,
},
},
}
}
func ipEnvVar() api.EnvVar {
return api.EnvVar{
Name: "POD_IP",
ValueFrom: &api.EnvVarSource{
FieldRef: &api.ObjectFieldSelector{
APIVersion: "v1",
FieldPath: "status.podIP",
},
},
}
}
func envVar(key, value string) api.EnvVar {
return api.EnvVar{
Name: key,
Value: value,
}
}
func podTypeMeta() unversioned.TypeMeta {
return unversioned.TypeMeta{
Kind: "Pod",
APIVersion: "v1",
}
}
func localStoreVolume() api.Volume {
return api.Volume{
Name: localStoreVolumeName,
VolumeSource: api.VolumeSource{
HostPath: &api.HostPathVolumeSource{
Path: env.LocalStorePath,
},
},
}
}
func localStoreVolumeMount() api.VolumeMount {
return api.VolumeMount{
Name: localStoreVolumeName,
ReadOnly: false,
MountPath: env.LocalStorePath,
}
}