diff --git a/yaml/constraint.go b/yaml/constraint.go index 6c6488bac..07608a68f 100644 --- a/yaml/constraint.go +++ b/yaml/constraint.go @@ -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 diff --git a/yaml/transform/plugin.go b/yaml/transform/plugin.go index bd84b9152..7bc1463d5 100644 --- a/yaml/transform/plugin.go +++ b/yaml/transform/plugin.go @@ -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 } diff --git a/yaml/types/bool.go b/yaml/types/bool.go index ac7d295c7..17a7aa9af 100644 --- a/yaml/types/bool.go +++ b/yaml/types/bool.go @@ -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 } diff --git a/yaml/types/bool_test.go b/yaml/types/bool_test.go index 641b74c0f..b864349f8 100644 --- a/yaml/types/bool_test.go +++ b/yaml/types/bool_test.go @@ -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() {