mirror of
https://github.com/thegeeklab/drone-yaml.git
synced 2024-11-24 11:00:39 +00:00
implement basic cpu resource limits
This commit is contained in:
parent
a16b72d961
commit
5eb70c1034
@ -84,7 +84,7 @@ func toResourceObject(from *yaml.ResourceObject) *engine.ResourceObject {
|
||||
return nil
|
||||
}
|
||||
return &engine.ResourceObject{
|
||||
// TODO(bradrydzewski) set the CPU resource limit.
|
||||
CPU: from.CPU,
|
||||
Memory: int64(from.Memory),
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ type (
|
||||
// ResourceObject describes compute resource
|
||||
// requirements.
|
||||
ResourceObject struct {
|
||||
CPU string `json:"cpu"`
|
||||
CPU int64 `json:"cpu" yaml:"cpu"`
|
||||
Memory BytesSize `json:"memory"`
|
||||
}
|
||||
|
||||
|
4
yaml/pretty/testdata/pipeline_resources.yml
vendored
4
yaml/pretty/testdata/pipeline_resources.yml
vendored
@ -8,8 +8,8 @@ steps:
|
||||
- go build
|
||||
resources:
|
||||
limits:
|
||||
cpu: 200m
|
||||
cpu: 2
|
||||
memory: '100Mi'
|
||||
requests:
|
||||
cpu: 100m
|
||||
cpu: 1
|
||||
memory: '50Mi'
|
||||
|
@ -13,10 +13,10 @@ steps:
|
||||
- go build
|
||||
resources:
|
||||
limits:
|
||||
cpu: 200m
|
||||
cpu: 2
|
||||
memory: 100MiB
|
||||
requests:
|
||||
cpu: 100m
|
||||
cpu: 1
|
||||
memory: 50MiB
|
||||
|
||||
...
|
||||
|
@ -18,7 +18,7 @@ import "github.com/drone/drone-yaml/yaml"
|
||||
|
||||
func isPrimative(v interface{}) bool {
|
||||
switch v.(type) {
|
||||
case bool, string, int, float64:
|
||||
case bool, string, int, int64, float64:
|
||||
return true
|
||||
case yaml.BytesSize:
|
||||
return true
|
||||
|
@ -183,6 +183,12 @@ func writeInt(w writer, v int) {
|
||||
)
|
||||
}
|
||||
|
||||
func writeInt64(w writer, v int64) {
|
||||
w.WriteString(
|
||||
strconv.FormatInt(v, 10),
|
||||
)
|
||||
}
|
||||
|
||||
func writeEncode(w writer, v string) {
|
||||
if len(v) == 0 {
|
||||
w.WriteByte('"')
|
||||
@ -204,7 +210,7 @@ func writeValue(w writer, v interface{}) {
|
||||
return
|
||||
}
|
||||
switch v := v.(type) {
|
||||
case bool, int, float64, string:
|
||||
case bool, int, int64, float64, string:
|
||||
writeScalar(w, v)
|
||||
case []interface{}:
|
||||
writeSequence(w, v)
|
||||
@ -225,6 +231,8 @@ func writeScalar(w writer, v interface{}) {
|
||||
writeBool(w, v)
|
||||
case int:
|
||||
writeInt(w, v)
|
||||
case int64:
|
||||
writeInt64(w, v)
|
||||
case float64:
|
||||
writeFloat(w, v)
|
||||
case string:
|
||||
|
Loading…
Reference in New Issue
Block a user