use when.local=false to disable plugin steps locally

This commit is contained in:
Brad Rydzewski 2017-01-20 18:06:08 +07:00
parent def995b164
commit e4740667c0
4 changed files with 8 additions and 12 deletions

View file

@ -10,13 +10,13 @@ import (
type Constraints struct {
Repo Constraint
Ref Constraint
Runtime Constraint
Platform Constraint
Environment Constraint
Event Constraint
Branch Constraint
Status Constraint
Matrix ConstraintMap
Local types.BoolTrue
}
// Match returns true if all constraints match the given input. If a single constraint

View file

@ -7,18 +7,14 @@ import "github.com/drone/drone/yaml"
// locally on your own computer.
func PluginDisable(conf *yaml.Config, local bool) error {
for _, container := range conf.Pipeline {
if len(container.Commands) != 0 || container.Detached { // skip build steps
continue
if local && !container.Constraints.Local.Bool() {
container.Disabled = true
}
if isClone(container) {
container.Disabled = true
continue
}
if local && container.Constraints.Runtime.Match("cli") {
container.Disabled = true
}
}
return nil
}

View file

@ -15,14 +15,14 @@ func (b *BoolTrue) UnmarshalYAML(unmarshal func(interface{}) error) error {
return err
}
b.value, err = strconv.ParseBool(s)
if err != nil {
b.value = true
value, err := strconv.ParseBool(s)
if err == nil {
b.value = !value
}
return nil
}
// Bool returns the bool value.
func (b BoolTrue) Bool() bool {
return b.value
return !b.value
}

View file

@ -40,7 +40,7 @@ func TestBoolTrue(t *testing.T) {
if err != nil {
g.Fail(err)
}
g.Assert(out.Bool()).Equal(false)
g.Assert(out.Bool()).Equal(true)
})
g.It("should throw error when invalid", func() {