HTTP Triggers hookup (#1086)

* Initial suypport for invoking tiggers

* dupe method

* tighten server constraints

* runner tests not working yet

* basic route tests passing

* post rebase fixes

* add hybrid support for trigger invoke and tests

* consoloidate all hybrid evil into one place

* cleanup and make triggers unique by source

* fix oops with Agent

* linting

* review fixes
This commit is contained in:
Owen Cliffe
2018-07-05 18:56:07 +01:00
committed by Reed Allman
parent b07a000a18
commit b8b544ed25
38 changed files with 2208 additions and 865 deletions

View File

@@ -15,7 +15,7 @@ type TriggerAnnotator interface {
type requestBasedTriggerAnnotator struct{}
func annotateTriggerWithBaseUrl(baseURL string, app *models.App, t *models.Trigger) (*models.Trigger, error) {
func annotateTriggerWithBaseURL(baseURL string, app *models.App, t *models.Trigger) (*models.Trigger, error) {
if t.Type != models.TriggerTypeHTTP {
return t, nil
}
@@ -41,23 +41,25 @@ func (tp *requestBasedTriggerAnnotator) AnnotateTrigger(ctx *gin.Context, app *m
scheme = "https"
}
return annotateTriggerWithBaseUrl(fmt.Sprintf("%s://%s", scheme, ctx.Request.Host), app, t)
return annotateTriggerWithBaseURL(fmt.Sprintf("%s://%s", scheme, ctx.Request.Host), app, t)
}
//NewRequestBasedTriggerAnnotator creates a TriggerAnnotator that inspects the incoming request host and port, and uses this to generate http trigger endpoint URLs based on those
func NewRequestBasedTriggerAnnotator() TriggerAnnotator {
return &requestBasedTriggerAnnotator{}
}
type staticUrlTriggerAnnotator struct {
urlBase string
type staticURLTriggerAnnotator struct {
baseURL string
}
func NewStaticURLTriggerAnnotator(baseUrl string) TriggerAnnotator {
//NewStaticURLTriggerAnnotator annotates triggers bases on a given, specified URL base - e.g. "https://my.domain" ---> "https://my.domain/t/app/source"
func NewStaticURLTriggerAnnotator(baseURL string) TriggerAnnotator {
return &staticUrlTriggerAnnotator{urlBase: baseUrl}
return &staticURLTriggerAnnotator{baseURL: baseURL}
}
func (s *staticUrlTriggerAnnotator) AnnotateTrigger(ctx *gin.Context, app *models.App, trigger *models.Trigger) (*models.Trigger, error) {
return annotateTriggerWithBaseUrl(s.urlBase, app, trigger)
func (s *staticURLTriggerAnnotator) AnnotateTrigger(ctx *gin.Context, app *models.App, trigger *models.Trigger) (*models.Trigger, error) {
return annotateTriggerWithBaseURL(s.baseURL, app, trigger)
}