mirror of
https://github.com/drone/drone-cli.git
synced 2024-11-23 01:11:57 +01:00
bump yaml version with dag fix
This commit is contained in:
parent
03ba60a4dd
commit
9db53bbee4
2
Gopkg.lock
generated
2
Gopkg.lock
generated
@ -115,7 +115,7 @@
|
||||
"yaml/pretty",
|
||||
"yaml/signer"
|
||||
]
|
||||
revision = "9296fb754228249b0f67009abcb7aee2b3b811c8"
|
||||
revision = "2d2db75c210e6a546d018f8c8aa57859162d1066"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/drone/envsubst"
|
||||
|
12
vendor/github.com/drone/drone-yaml/yaml/compiler/compiler.go
generated
vendored
12
vendor/github.com/drone/drone-yaml/yaml/compiler/compiler.go
generated
vendored
@ -46,6 +46,14 @@ type Compiler struct {
|
||||
func (c *Compiler) Compile(from *yaml.Pipeline) *engine.Spec {
|
||||
namespace := rand.String()
|
||||
|
||||
isSerial := true
|
||||
for _, step := range from.Steps {
|
||||
if len(step.DependsOn) != 0 {
|
||||
isSerial = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
spec := &engine.Spec{
|
||||
Metadata: engine.Metadata{
|
||||
UID: namespace,
|
||||
@ -154,7 +162,7 @@ func (c *Compiler) Compile(from *yaml.Pipeline) *engine.Spec {
|
||||
// if the clone step is enabled, the service should
|
||||
// not start until the clone step is complete. Add
|
||||
// the clone step as a dependency in the graph.
|
||||
if !from.Clone.Disable {
|
||||
if isSerial == false && from.Clone.Disable == false {
|
||||
step.DependsOn = append(step.DependsOn, cloneStepName)
|
||||
}
|
||||
spec.Steps = append(spec.Steps, step)
|
||||
@ -193,7 +201,7 @@ func (c *Compiler) Compile(from *yaml.Pipeline) *engine.Spec {
|
||||
// not start until the clone step is complete. If
|
||||
// no dependencies are defined, at a minimum, the
|
||||
// step depends on the initial clone step completing.
|
||||
if !from.Clone.Disable && len(step.DependsOn) == 0 {
|
||||
if isSerial == false && from.Clone.Disable == false && len(step.DependsOn) == 0 {
|
||||
step.DependsOn = append(step.DependsOn, cloneStepName)
|
||||
}
|
||||
spec.Steps = append(spec.Steps, step)
|
||||
|
2
vendor/github.com/drone/drone-yaml/yaml/compiler/convert.go
generated
vendored
2
vendor/github.com/drone/drone-yaml/yaml/compiler/convert.go
generated
vendored
@ -70,7 +70,7 @@ func toResourceObject(from *yaml.ResourceObject) *engine.ResourceObject {
|
||||
return nil
|
||||
}
|
||||
return &engine.ResourceObject{
|
||||
// TODO(bradrydzewski) set the CPU resource limit.
|
||||
CPU: int64(from.CPU),
|
||||
Memory: int64(from.Memory),
|
||||
}
|
||||
}
|
||||
|
11
vendor/github.com/drone/drone-yaml/yaml/compiler/transform/limits.go
generated
vendored
11
vendor/github.com/drone/drone-yaml/yaml/compiler/transform/limits.go
generated
vendored
@ -1,10 +1,9 @@
|
||||
package transform
|
||||
|
||||
import "github.com/drone/drone-runtime/engine"
|
||||
|
||||
// WithLimits is a transform function that applies
|
||||
// resource limits to the container processes.
|
||||
func WithLimits(memlimit, cpulimit int64) func(*engine.Spec) {
|
||||
func WithLimits(memlimit int64, cpulimit int64) func(*engine.Spec) {
|
||||
return func(spec *engine.Spec) {
|
||||
// if no limits are defined exit immediately.
|
||||
if memlimit == 0 && cpulimit == 0 {
|
||||
@ -19,8 +18,12 @@ func WithLimits(memlimit, cpulimit int64) func(*engine.Spec) {
|
||||
if step.Resources.Limits == nil {
|
||||
step.Resources.Limits = &engine.ResourceObject{}
|
||||
}
|
||||
step.Resources.Limits.Memory = memlimit
|
||||
step.Resources.Limits.CPU = cpulimit
|
||||
if memlimit != 0 {
|
||||
step.Resources.Limits.Memory = memlimit
|
||||
}
|
||||
if cpulimit != 0 {
|
||||
step.Resources.Limits.CPU = cpulimit * 1000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
vendor/github.com/drone/drone-yaml/yaml/pipeline.go
generated
vendored
2
vendor/github.com/drone/drone-yaml/yaml/pipeline.go
generated
vendored
@ -81,7 +81,7 @@ type (
|
||||
// ResourceObject describes compute resource
|
||||
// requirements.
|
||||
ResourceObject struct {
|
||||
CPU string `json:"cpu"`
|
||||
CPU MilliSize `json:"cpu"`
|
||||
Memory BytesSize `json:"memory"`
|
||||
}
|
||||
|
||||
|
2
vendor/github.com/drone/drone-yaml/yaml/pretty/util.go
generated
vendored
2
vendor/github.com/drone/drone-yaml/yaml/pretty/util.go
generated
vendored
@ -8,6 +8,8 @@ func isPrimative(v interface{}) bool {
|
||||
return true
|
||||
case yaml.BytesSize:
|
||||
return true
|
||||
case yaml.MilliSize:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
2
vendor/github.com/drone/drone-yaml/yaml/pretty/writer.go
generated
vendored
2
vendor/github.com/drone/drone-yaml/yaml/pretty/writer.go
generated
vendored
@ -202,6 +202,8 @@ func writeValue(w writer, v interface{}) {
|
||||
writeMappingStr(w, v)
|
||||
case yaml.BytesSize:
|
||||
writeValue(w, v.String())
|
||||
case yaml.MilliSize:
|
||||
writeValue(w, v.String())
|
||||
}
|
||||
}
|
||||
|
||||
|
42
vendor/github.com/drone/drone-yaml/yaml/unit.go
generated
vendored
42
vendor/github.com/drone/drone-yaml/yaml/unit.go
generated
vendored
@ -1,7 +1,11 @@
|
||||
package yaml
|
||||
|
||||
import "github.com/docker/go-units"
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/go-units"
|
||||
)
|
||||
// BytesSize stores a human-readable size in bytes,
|
||||
// kibibytes, mebibytes, gibibytes, or tebibytes
|
||||
// (eg. "44kiB", "17MiB").
|
||||
@ -33,3 +37,39 @@ func (b *BytesSize) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
func (b BytesSize) String() string {
|
||||
return units.BytesSize(float64(b))
|
||||
}
|
||||
|
||||
// MilliSize will convert cpus to millicpus as int64.
|
||||
// for instance "1" will be converted to 1000 and "100m" to 100
|
||||
type MilliSize int64
|
||||
|
||||
// UnmarshalYAML implements yaml unmarshalling.
|
||||
func (m *MilliSize) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var intType int64
|
||||
if err := unmarshal(&intType); err == nil {
|
||||
*m = MilliSize(intType * 1000)
|
||||
return nil
|
||||
}
|
||||
|
||||
var stringType string
|
||||
if err := unmarshal(&stringType); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(stringType) > 0 {
|
||||
lastChar := string(stringType[len(stringType)-1:])
|
||||
if lastChar == "m" {
|
||||
// convert to int64
|
||||
i, err := strconv.ParseInt(strings.TrimSuffix(stringType, "m"), 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*m = MilliSize(i)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// String returns a human-readable cpu millis,
|
||||
// (eg. "1000", "10").
|
||||
func (m MilliSize) String() string {
|
||||
return strconv.FormatInt(int64(m), 10)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user