Skip to content
This repository has been archived by the owner on Mar 10, 2023. It is now read-only.

Commit

Permalink
Fixes for git-flow
Browse files Browse the repository at this point in the history
- buildshiprun: shorter status message to fit into UI
- git-tar: panic when checking for non-existing err variable
- import-secrets: checked wrong name for HMAC secret, fixed

Tested "in production" on o6s.io cluster.

Signed-off-by: Alex Ellis (VMware) <[email protected]>
  • Loading branch information
alexellis committed Aug 13, 2018
1 parent 197a147 commit 10a092c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion buildshiprun/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func Handle(req []byte) string {
}

sdk.PostAudit(auditEvent)
status.AddStatus(sdk.StatusSuccess, fmt.Sprintf("function successfully deployed as: %s", serviceValue), sdk.BuildFunctionContext(event.Service))
status.AddStatus(sdk.StatusSuccess, fmt.Sprintf("deployed: %s", serviceValue), sdk.BuildFunctionContext(event.Service))
reportStatus(status)
return fmt.Sprintf("buildStatus %s %s %s", buildStatus, imageName, res.Status)
}
Expand Down
18 changes: 12 additions & 6 deletions git-tar/function/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,21 @@ func importSecrets(pushEvent sdk.PushEvent, stack *stack.Services, clonePath str
fmt.Fprintf(os.Stderr, fmt.Errorf("error reaching import-secrets function: %s", reqErr.Error()).Error())
}

defer res.Body.Close()
if res.Body != nil {
defer res.Body.Close()
}

if res.StatusCode != http.StatusAccepted && res.StatusCode != http.StatusOK {
resBytes, err := ioutil.ReadAll(res.Body)
if err != nil {
return fmt.Errorf("error reading response from import-secrets: %s", err.Error())
}
if res.Body != nil {
resBytes, err := ioutil.ReadAll(res.Body)
if err != nil {
return fmt.Errorf("error reading response from import-secrets: %s", err.Error())
}

return fmt.Errorf("import-secrets returned unexpected status: %s", string(resBytes))

return fmt.Errorf("import-secrets returned error: %s, res: %s", err.Error(), string(resBytes))
}
return fmt.Errorf("import-secrets returned unknown error, status: %d", res.StatusCode)
}

auditEvent := sdk.AuditEvent{
Expand Down
3 changes: 2 additions & 1 deletion import-secrets/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func Handle(req []byte) string {
event := getEventFromHeader()

if hmacEnabled() {
key, err := sdk.ReadSecret("github-secret-key")
key, err := sdk.ReadSecret("github-webhook-secret")
if err != nil {
fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1)
Expand All @@ -31,6 +31,7 @@ func Handle(req []byte) string {
}

digest := os.Getenv("Http_X_Hub_Signature")

validated := hmac.Validate(req, digest, key)

if validated != nil {
Expand Down

0 comments on commit 10a092c

Please sign in to comment.