Skip to content

Commit

Permalink
Merge pull request #143 from atomist-skills/expose-skill-status-witho…
Browse files Browse the repository at this point in the history
…ut-request-context

expose skill status without request context
  • Loading branch information
chrispatrick authored Dec 2, 2024
2 parents 318cc86 + f0ab299 commit 14bdaa8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions status.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func NewRunningStatus(reason string) Status {
}

func SendStatus(ctx context.Context, req RequestContext, status Status) error {
return SendEventStatus(ctx, req.Event, req.Log, status)
}

func SendEventStatus(ctx context.Context, event EventIncoming, logger Logger, status Status) error {
// Don't send the status when evaluating policies locally
if os.Getenv("SCOUT_LOCAL_POLICY_EVALUATION") == "true" {
return nil
Expand All @@ -68,10 +72,10 @@ func SendStatus(ctx context.Context, req RequestContext, status Status) error {
return err
}

req.Log.Debugf("Sending status: %s", string(bs))
logger.Debugf("Sending status: %s", string(bs))
client := http.DefaultClient
httpReq, err := http.NewRequestWithContext(ctx, http.MethodPatch, req.Event.Urls.Execution, bytes.NewBuffer(bs))
httpReq.Header.Set("Authorization", "Bearer "+req.Event.Token)
httpReq, err := http.NewRequestWithContext(ctx, http.MethodPatch, event.Urls.Execution, bytes.NewBuffer(bs))
httpReq.Header.Set("Authorization", "Bearer "+event.Token)
httpReq.Header.Set("Content-Type", "application/edn")
if err != nil {
return err
Expand Down

0 comments on commit 14bdaa8

Please sign in to comment.