@@ -196,12 +196,14 @@ func Handle(req []byte) string {
196196 sdk .FunctionLabelPrefix + "git-sha" : event .SHA ,
197197 sdk .FunctionLabelPrefix + "git-private" : fmt .Sprintf ("%d" , private ),
198198 sdk .FunctionLabelPrefix + "git-scm" : event .SCM ,
199- sdk .FunctionLabelPrefix + "git-repo-url" : event .RepoURL ,
200199 "faas_function" : serviceValue ,
201200 "app" : serviceValue ,
202201 "com.openfaas.scale.min" : scalingMinLimit ,
203202 "com.openfaas.scale.max" : scalingMaxLimit ,
204203 },
204+ Annotations : map [string ]string {
205+ sdk .FunctionLabelPrefix + "git-repo-url" : event .RepoURL ,
206+ },
205207 Limits : Limits {
206208 Memory : defaultMemoryLimit ,
207209 },
@@ -218,19 +220,22 @@ func Handle(req []byte) string {
218220
219221 deployResult , err := deployFunction (deploy , gatewayURL , c )
220222
223+ log .Println (deployResult )
224+
221225 if err != nil {
222226 status .AddStatus (sdk .StatusFailure , err .Error (), sdk .BuildFunctionContext (event .Service ))
223227 reportStatus (status )
224- log . Fatal ( err . Error ())
228+
225229 auditEvent .Message = fmt .Sprintf ("buildshiprun failure: %s" , err .Error ())
230+ sdk .PostAudit (auditEvent )
231+ log .Fatalf ("buildshiprun failure: %s" , err .Error ())
226232 } else {
227233 auditEvent .Message = fmt .Sprintf ("buildshiprun succeeded: deployed %s" , imageName )
234+ sdk .PostAudit (auditEvent )
228235 }
229236
230- log .Println (deployResult )
231237 }
232238
233- sdk .PostAudit (auditEvent )
234239 status .AddStatus (sdk .StatusSuccess , fmt .Sprintf ("deployed: %s" , serviceValue ), sdk .BuildFunctionContext (event .Service ))
235240 reportStatus (status )
236241 return fmt .Sprintf ("buildStatus %s %s" , imageName , res .Status )
@@ -411,17 +416,19 @@ func deployFunction(deploy deployment, gatewayURL string, c *http.Client) (strin
411416 res , err = c .Do (httpReq )
412417
413418 if err != nil {
414- fmt . Println ( err )
419+ log . Printf ( "error %s to system/functions %s" , method , err )
415420 return "" , err
416421 }
417422
418423 defer res .Body .Close ()
419424
420- fmt .Println ("Deploy status: " + res .Status )
425+ log .Printf ("Deploy status [%s] - %d" , method , res .StatusCode )
426+
427+ buildStatus , _ := ioutil .ReadAll (res .Body )
428+
421429 if res .StatusCode < 200 || res .StatusCode > 299 {
422- return "" , fmt .Errorf ("http status code %d" , res .StatusCode )
430+ return "" , fmt .Errorf ("http status code %d, error: %s " , res .StatusCode , string ( buildStatus ) )
423431 }
424- buildStatus , _ := ioutil .ReadAll (res .Body )
425432
426433 return string (buildStatus ), err
427434}
@@ -479,6 +486,7 @@ type deployment struct {
479486 Secrets []string
480487 ReadOnlyRootFilesystem bool `json:"readOnlyRootFilesystem"`
481488 RegistryAuth string `json:"registryAuth"`
489+ Annotations map [string ]string
482490}
483491
484492type Limits struct {
0 commit comments