Add updated-at to scripts, fix prefix-filtering

This commit is contained in:
Denis Arh
2020-07-23 19:06:15 +02:00
parent ed0fc88690
commit d6b7157463
4 changed files with 14 additions and 1 deletions
+4
View File
@@ -64,6 +64,10 @@ func (f *Filter) procRTPrefixes(service string) {
hasService, hasUi bool
)
if service == "" {
return
}
for i, rtp := range f.ResourceTypePrefixes {
if rtp == service {
hasService = true
+2
View File
@@ -470,6 +470,7 @@ func (svc *service) registerServerScripts(ctx context.Context, ss ...*ServerScri
Errors: script.Errors,
Triggers: script.Triggers,
Iterator: script.Iterator,
UpdatedAt: script.UpdatedAt,
}
if len(s.Errors) == 0 {
@@ -871,6 +872,7 @@ func (svc *service) registerClientScripts(ss ...*ClientScript) {
Triggers: script.Triggers,
Bundle: script.Bundle,
Type: script.Type,
UpdatedAt: script.UpdatedAt,
}
}
}
+1
View File
@@ -27,6 +27,7 @@ type (
Triggers []*Trigger `json:"triggers"`
Iterator *Iterator `json:"iterator"`
Security *ScriptSecurity `json:"security"`
UpdatedAt string `json:"updatedAt,omitempty"`
// If bundle or type is set, consider
// this a frontend script
+7 -1
View File
@@ -97,7 +97,13 @@ func encodeArguments(args map[string]string, key string, val interface{}) (err e
// GenericListHandler returns filtered list of scripts
func GenericListHandler(ctx context.Context, svc *service, f Filter, resourcePrefix string) (p *automationListSetPayload, err error) {
f.procRTPrefixes(resourcePrefix)
if f.ExcludeInvalid {
// resource prefix filtering is only applicable when we want to
// exclude invalid scripts, because invalid scripts do not have
// (usually, depends at what level error occurred) information
// about triggers and resources
f.procRTPrefixes(resourcePrefix)
}
p = &automationListSetPayload{}
p.Set, p.Filter, err = svc.Find(ctx, f)