forked from devfile/library
/
devfile.go
101 lines (89 loc) · 2.21 KB
/
devfile.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
93
94
95
96
97
98
99
100
101
package testingutil
import (
v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
)
// GetFakeContainerComponent returns a fake container component for testing.
func GetFakeContainerComponent(name string) v1.Component {
image := "docker.io/maven:latest"
memoryLimit := "128Mi"
volumeName := "myvolume1"
volumePath := "/my/volume/mount/path1"
mountSources := true
return v1.Component{
Name: name,
ComponentUnion: v1.ComponentUnion{
Container: &v1.ContainerComponent{
Container: v1.Container{
Image: image,
Env: []v1.EnvVar{},
MemoryLimit: memoryLimit,
VolumeMounts: []v1.VolumeMount{
{
Name: volumeName,
Path: volumePath,
},
},
MountSources: &mountSources,
},
},
},
}
}
// GetFakeVolumeComponent returns a fake volume component for testing
func GetFakeVolumeComponent(name, size string) v1.Component {
return v1.Component{
Name: name,
ComponentUnion: v1.ComponentUnion{
Volume: &v1.VolumeComponent{
Volume: v1.Volume{
Size: size,
},
},
},
}
}
// GetFakeExecRunCommands returns fake commands for testing
func GetFakeExecRunCommands() []v1.ExecCommand {
return []v1.ExecCommand{
{
CommandLine: "ls -a",
Component: "alias1",
LabeledCommand: v1.LabeledCommand{
BaseCommand: v1.BaseCommand{
Group: &v1.CommandGroup{
Kind: v1.RunCommandGroupKind,
},
},
},
WorkingDir: "/root",
},
}
}
// GetFakeEnv returns a fake env for testing
func GetFakeEnv(name, value string) v1.EnvVar {
return v1.EnvVar{
Name: name,
Value: value,
}
}
// GetFakeEnvParentOverride returns a fake envParentOverride for testing
func GetFakeEnvParentOverride(name, value string) v1.EnvVarParentOverride {
return v1.EnvVarParentOverride{
Name: name,
Value: value,
}
}
// GetFakeVolumeMount returns a fake volume mount for testing
func GetFakeVolumeMount(name, path string) v1.VolumeMount {
return v1.VolumeMount{
Name: name,
Path: path,
}
}
// GetFakeVolumeMountParentOverride returns a fake volumeMountParentOverride for testing
func GetFakeVolumeMountParentOverride(name, path string) v1.VolumeMountParentOverride {
return v1.VolumeMountParentOverride{
Name: name,
Path: path,
}
}