Commit 976cf802 authored by Kunal Taitkar's avatar Kunal Taitkar
Browse files

Pre/Post hook changes

parent f51c37e5
Branches
Tags MEP19.03.2020
3 merge requests!220Release v2.0.0 alpha,!219Add: Support for branches,!216Pre/Post hook changes
Showing with 11 additions and 8 deletions
...@@ -145,18 +145,19 @@ func validateRoleFromToken(principalObj servicebuildermdl.Principal, service Ser ...@@ -145,18 +145,19 @@ func validateRoleFromToken(principalObj servicebuildermdl.Principal, service Ser
func (s ServiceCache) preHooksExec(rs *gjson.Result, principalObj *servicebuildermdl.Principal) { func (s ServiceCache) preHooksExec(rs *gjson.Result, principalObj *servicebuildermdl.Principal) {
for i := 0; i < len(s.PreHooks); i++ { for i := 0; i < len(s.PreHooks); i++ {
var service interface{} var service interface{}
activityName := ConcatenateEntityWithBranch(s.PreHooks[i].ActivityName, s.PreHooks[i].Branch)
var found bool var found bool
if s.PreHooks[i].ActorType == "ROLEBASED" { if s.PreHooks[i].ActorType == "ROLEBASED" {
service, found = roleBasedServices.Get(s.PreHooks[i].ActivityName) service, found = roleBasedServices.Get(activityName)
} }
if s.PreHooks[i].ActorType == "RESTRICTED" { if s.PreHooks[i].ActorType == "RESTRICTED" {
service, found = restrictedServices.Get(s.PreHooks[i].ActivityName) service, found = restrictedServices.Get(activityName)
} }
if s.PreHooks[i].ActorType == "OPEN" { if s.PreHooks[i].ActorType == "OPEN" {
service, found = openServices.Get(s.PreHooks[i].ActivityName) service, found = openServices.Get(activityName)
} }
if !found { if !found {
loggermdl.LogError("Pre Hook Not found: ", s.PreHooks[i].ActivityName, " for actor type: ", s.PreHooks[i].ActorType) loggermdl.LogError("Pre Hook Not found: ", activityName, " for actor type: ", s.PreHooks[i].ActorType, " branch:", s.PreHooks[i].Branch)
return return
} }
tmpServiceCache := service.(ServiceCache) tmpServiceCache := service.(ServiceCache)
...@@ -179,19 +180,20 @@ func (s ServiceCache) postHooksExec(data interface{}, principalObj *servicebuild ...@@ -179,19 +180,20 @@ func (s ServiceCache) postHooksExec(data interface{}, principalObj *servicebuild
} }
} }
for i := 0; i < len(s.PostHooks); i++ { for i := 0; i < len(s.PostHooks); i++ {
activityName := ConcatenateEntityWithBranch(s.PostHooks[i].ActivityName, s.PostHooks[i].Branch)
var service interface{} var service interface{}
var found bool var found bool
if s.PostHooks[i].ActorType == "ROLEBASED" { if s.PostHooks[i].ActorType == "ROLEBASED" {
service, found = roleBasedServices.Get(s.PostHooks[i].ActivityName) service, found = roleBasedServices.Get(activityName)
} }
if s.PostHooks[i].ActorType == "RESTRICTED" { if s.PostHooks[i].ActorType == "RESTRICTED" {
service, found = restrictedServices.Get(s.PostHooks[i].ActivityName) service, found = restrictedServices.Get(activityName)
} }
if s.PostHooks[i].ActorType == "OPEN" { if s.PostHooks[i].ActorType == "OPEN" {
service, found = openServices.Get(s.PostHooks[i].ActivityName) service, found = openServices.Get(activityName)
} }
if !found { if !found {
loggermdl.LogError("Post Hook Not found: ", s.PostHooks[i].ActivityName, " for actor type: ", s.PostHooks[i].ActorType) loggermdl.LogError("Post Hook Not found: ", activityName, " for actor type: ", s.PostHooks[i].ActorType, " Branch:", s.PostHooks[i].Branch)
return return
} }
tmpServiceCache := service.(ServiceCache) tmpServiceCache := service.(ServiceCache)
......
...@@ -35,6 +35,7 @@ func init() { ...@@ -35,6 +35,7 @@ func init() {
type Hook struct { type Hook struct {
ActivityName string ActivityName string
ActorType string ActorType string
Branch string
} }
// ServiceCache ServiceCache object // ServiceCache ServiceCache object
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment