mirror of
https://github.com/thegeeklab/drone-yaml.git
synced 2024-11-24 19:10:40 +00:00
use float64 to support docker-compose cpu syntax
This commit is contained in:
parent
5eb70c1034
commit
7a5539b9af
@ -84,7 +84,14 @@ func toResourceObject(from *yaml.ResourceObject) *engine.ResourceObject {
|
||||
return nil
|
||||
}
|
||||
return &engine.ResourceObject{
|
||||
CPU: from.CPU,
|
||||
CPU: toCPUMillis(from.CPU),
|
||||
Memory: int64(from.Memory),
|
||||
}
|
||||
}
|
||||
|
||||
func toCPUMillis(f float64) int64 {
|
||||
if f > 0 {
|
||||
f *= 1000
|
||||
}
|
||||
return int64(f)
|
||||
}
|
||||
|
@ -136,9 +136,11 @@ func Test_toResources(t *testing.T) {
|
||||
Resources: &yaml.Resources{
|
||||
Limits: &yaml.ResourceObject{
|
||||
Memory: yaml.BytesSize(1000),
|
||||
CPU: 4,
|
||||
},
|
||||
Requests: &yaml.ResourceObject{
|
||||
Memory: yaml.BytesSize(2000),
|
||||
CPU: 0.1,
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -146,9 +148,11 @@ func Test_toResources(t *testing.T) {
|
||||
b = &engine.Resources{
|
||||
Limits: &engine.ResourceObject{
|
||||
Memory: 1000,
|
||||
CPU: 4000,
|
||||
},
|
||||
Requests: &engine.ResourceObject{
|
||||
Memory: 2000,
|
||||
CPU: 100,
|
||||
},
|
||||
}
|
||||
if diff := cmp.Diff(a, b); diff != "" {
|
||||
|
@ -97,7 +97,7 @@ type (
|
||||
// ResourceObject describes compute resource
|
||||
// requirements.
|
||||
ResourceObject struct {
|
||||
CPU int64 `json:"cpu" yaml:"cpu"`
|
||||
CPU float64 `json:"cpu" yaml:"cpu"`
|
||||
Memory BytesSize `json:"memory"`
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user