github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/pkg/webhook/formation_lifecycle.go (about) 1 package webhook 2 3 import ( 4 "bytes" 5 "encoding/json" 6 "net/http" 7 8 "github.com/kyma-incubator/compass/components/director/internal/model" 9 ) 10 11 // FormationLifecycleInput struct contains the input for FORMATION_LIFECYCLE webhook 12 type FormationLifecycleInput struct { 13 Operation model.FormationOperation 14 Formation *model.Formation 15 CustomerTenantContext *CustomerTenantContext 16 } 17 18 // ParseURLTemplate parses the URL template 19 func (fl *FormationLifecycleInput) ParseURLTemplate(tmpl *string) (*URL, error) { 20 var url URL 21 return &url, parseTemplate(tmpl, *fl, &url) 22 } 23 24 // ParseInputTemplate parses the input template 25 func (fl *FormationLifecycleInput) ParseInputTemplate(tmpl *string) ([]byte, error) { 26 res := json.RawMessage{} 27 if err := parseTemplate(tmpl, *fl, &res); err != nil { 28 return nil, err 29 } 30 res = bytes.ReplaceAll(res, []byte("<nil>"), nil) 31 return res, nil 32 } 33 34 // ParseHeadersTemplate parses the headers template 35 func (fl *FormationLifecycleInput) ParseHeadersTemplate(tmpl *string) (http.Header, error) { 36 var headers http.Header 37 return headers, parseTemplate(tmpl, *fl, &headers) 38 }