From 593ac3170209dc8228d047acce0410ce4b42e634 Mon Sep 17 00:00:00 2001 From: Jim Sheldon Date: Tue, 5 Nov 2019 13:31:13 -0500 Subject: [PATCH] fix for when pipelines and steps are excluded (#3) --- plugin/parse.go | 12 ++++++++++-- plugin/plugin.go | 8 +++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/plugin/parse.go b/plugin/parse.go index d399d13..0f69ec8 100644 --- a/plugin/parse.go +++ b/plugin/parse.go @@ -92,7 +92,11 @@ func parsePipelines(data string, build drone.Build, repo drone.Repo, token strin "name": repo.Name, }).Infoln("excluding pipeline", resource.Attrs["name"]) - resource.Trigger.Event.Exclude = []string{"*"} + // if only Trigger.Paths is set, Trigger.Attrs will be unset, so it must be initialized + if resource.Trigger.Attrs == nil { + resource.Trigger.Attrs = make(map[string]interface{}) + } + resource.Trigger.Attrs["event"] = map[string][]string{"exclude": []string{"*"}} } } @@ -135,7 +139,11 @@ func parsePipelines(data string, build drone.Build, repo drone.Repo, token strin "name": repo.Name, }).Infoln("excluding step", step.Attrs["name"]) - step.When.Event.Exclude = []string{"*"} + // if only When.Paths is set, When.Attrs will be unset, so it must be initialized + if step.When.Attrs == nil { + step.When.Attrs = make(map[string]interface{}) + } + step.When.Attrs["event"] = map[string][]string{"exclude": []string{"*"}} } } } diff --git a/plugin/plugin.go b/plugin/plugin.go index 30b788a..96139e6 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -35,7 +35,6 @@ type ( } conditions struct { - Event condition `yaml:"event,omitempty"` Paths condition `yaml:"paths,omitempty"` Attrs map[string]interface{} `yaml:",inline"` } @@ -96,6 +95,13 @@ func (p *plugin) Convert(ctx context.Context, req *converter.Request) (*drone.Co data := req.Config.Data resources, pathsSeen, err := parsePipelines(data, req.Build, req.Repo, p.token) if err != nil { + logrus.WithFields(logrus.Fields{ + "action": req.Build.Action, + "after": req.Build.After, + "before": req.Build.Before, + "namespace": req.Repo.Namespace, + "name": req.Repo.Name, + }).Errorln(err) return nil, nil }