FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

default to ignore · upbound/function-event-filter@d9b01db · GitHub

Commit d9b01db

Browse files
committed
default to ignore
1 parent 1ec8679 commit d9b01db

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

‎fn.go‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest)
3030
f.log.Info("Running function", "tag", req.GetMeta().GetTag())
3131

3232
rsp := response.To(req, response.DefaultTTL)
33+
fctx := req.GetContext()
34+
if len(fctx.AsMap()) == 0 {
35+
// init map
36+
fctx.Fields = make(map[string]*structpb.Value)
37+
}
38+
fctx.Fields["ops.upbound.io/ignored-resource"] = structpb.NewBoolValue(true)
39+
rsp.Context = fctx
3340

3441
in := &v1alpha1.Input{}
3542
if err := request.GetInput(req, in); err != nil {
@@ -80,13 +87,6 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest)
8087

8188
if !match(in, e) {
8289
f.log.Info("doesn't match", "event", fmt.Sprintf("%+v", e))
83-
fctx := req.GetContext()
84-
if len(fctx.AsMap()) == 0 {
85-
// init map
86-
fctx.Fields = make(map[string]*structpb.Value)
87-
}
88-
fctx.Fields["ops.upbound.io/ignored-resource"] = structpb.NewBoolValue(true)
89-
rsp.Context = fctx
9090

9191
response.ConditionTrue(rsp, "FunctionSuccess", "Success").TargetCompositeAndClaim()
9292
response.Normal(rsp, fmt.Sprintf("not interested in the given event %s, skipping", types.NamespacedName{Name: e.GetName(), Namespace: e.GetNamespace()}))
@@ -99,6 +99,10 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest)
9999
response.ConditionTrue(rsp, "FunctionSuccess", "Success").TargetCompositeAndClaim()
100100
response.Normal(rsp, "passing along given event")
101101
f.log.Info("matches", "event", fmt.Sprintf("%+v", e))
102+
103+
fctx.Fields["ops.upbound.io/ignored-resource"] = structpb.NewBoolValue(false)
104+
rsp.Context = fctx
105+
102106
return rsp, nil
103107
}
104108

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL