support for mem_limit and memswap_limit
This commit is contained in:
@@ -48,6 +48,14 @@ func createStep(spec *resource.Pipeline, src *resource.Step) *engine.Step {
|
||||
// Resources: toResources(src), // TODO
|
||||
}
|
||||
|
||||
// set container limits
|
||||
if v := int64(src.MemLimit); v > 0 {
|
||||
dst.MemLimit = v
|
||||
}
|
||||
if v := int64(src.MemSwapLimit); v > 0 {
|
||||
dst.MemSwapLimit = v
|
||||
}
|
||||
|
||||
// appends the volumes to the container def.
|
||||
for _, vol := range src.Volumes {
|
||||
dst.Volumes = append(dst.Volumes, &engine.VolumeMount{
|
||||
|
||||
@@ -76,6 +76,8 @@ func TestParse(t *testing.T) {
|
||||
"GOOS": &manifest.Variable{Value: "linux"},
|
||||
"GOARCH": &manifest.Variable{Value: "arm64"},
|
||||
},
|
||||
MemLimit: manifest.BytesSize(1073741824),
|
||||
MemSwapLimit: manifest.BytesSize(2147483648),
|
||||
Failure: "ignore",
|
||||
When: manifest.Conditions{
|
||||
Event: manifest.Condition{
|
||||
|
||||
@@ -95,6 +95,8 @@ type (
|
||||
ExtraHosts []string `json:"extra_hosts,omitempty" yaml:"extra_hosts"`
|
||||
Failure string `json:"failure,omitempty"`
|
||||
Image string `json:"image,omitempty"`
|
||||
MemLimit manifest.BytesSize `json:"mem_limit,omitempty" yaml:"mem_limit"`
|
||||
MemSwapLimit manifest.BytesSize `json:"memswap_limit,omitempty" yaml:"memswap_limit"`
|
||||
Network string `json:"network_mode,omitempty" yaml:"network_mode"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Privileged bool `json:"privileged,omitempty"`
|
||||
|
||||
2
engine/resource/testdata/manifest.yml
vendored
2
engine/resource/testdata/manifest.yml
vendored
@@ -32,6 +32,8 @@ steps:
|
||||
image: golang
|
||||
detach: false
|
||||
failure: ignore
|
||||
mem_limit: 1GiB
|
||||
memswap_limit: 2GiB
|
||||
commands:
|
||||
- go build
|
||||
- go test
|
||||
|
||||
Reference in New Issue
Block a user