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 nil
|
||||||
}
|
}
|
||||||
return &engine.ResourceObject{
|
return &engine.ResourceObject{
|
||||||
CPU: from.CPU,
|
CPU: toCPUMillis(from.CPU),
|
||||||
Memory: int64(from.Memory),
|
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{
|
Resources: &yaml.Resources{
|
||||||
Limits: &yaml.ResourceObject{
|
Limits: &yaml.ResourceObject{
|
||||||
Memory: yaml.BytesSize(1000),
|
Memory: yaml.BytesSize(1000),
|
||||||
|
CPU: 4,
|
||||||
},
|
},
|
||||||
Requests: &yaml.ResourceObject{
|
Requests: &yaml.ResourceObject{
|
||||||
Memory: yaml.BytesSize(2000),
|
Memory: yaml.BytesSize(2000),
|
||||||
|
CPU: 0.1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -146,9 +148,11 @@ func Test_toResources(t *testing.T) {
|
|||||||
b = &engine.Resources{
|
b = &engine.Resources{
|
||||||
Limits: &engine.ResourceObject{
|
Limits: &engine.ResourceObject{
|
||||||
Memory: 1000,
|
Memory: 1000,
|
||||||
|
CPU: 4000,
|
||||||
},
|
},
|
||||||
Requests: &engine.ResourceObject{
|
Requests: &engine.ResourceObject{
|
||||||
Memory: 2000,
|
Memory: 2000,
|
||||||
|
CPU: 100,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if diff := cmp.Diff(a, b); diff != "" {
|
if diff := cmp.Diff(a, b); diff != "" {
|
||||||
|
@ -97,7 +97,7 @@ type (
|
|||||||
// ResourceObject describes compute resource
|
// ResourceObject describes compute resource
|
||||||
// requirements.
|
// requirements.
|
||||||
ResourceObject struct {
|
ResourceObject struct {
|
||||||
CPU int64 `json:"cpu" yaml:"cpu"`
|
CPU float64 `json:"cpu" yaml:"cpu"`
|
||||||
Memory BytesSize `json:"memory"`
|
Memory BytesSize `json:"memory"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user