Skip to content

Commit

Permalink
fix(webhook): do not set ssh key in environment
Browse files Browse the repository at this point in the history
Remove dead code and possible race condition.
  • Loading branch information
adamreese committed Dec 1, 2017
1 parent 184acd2 commit cd23d1d
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions pkg/webhook/github.go
Expand Up @@ -6,7 +6,6 @@ import (
"io/ioutil"
"log"
"net/http"
"os"

"github.com/google/go-github/github"
"gopkg.in/gin-gonic/gin.v1"
Expand Down Expand Up @@ -131,23 +130,6 @@ func (s *githubHook) handleEvent(c *gin.Context, eventType string) {

// buildStatus runs a build, and sets upstream status accordingly.
func (s *githubHook) buildStatus(eventType, commit string, payload []byte, proj *brigade.Project) {
// If we need an SSH key, set it here
if proj.Repo.SSHKey != "" {
key, err := ioutil.TempFile("", "")
if err != nil {
log.Printf("error creating ssh key cache: %s", err)
return
}
keyfile := key.Name()
defer os.Remove(keyfile)
if _, err := key.WriteString(proj.Repo.SSHKey); err != nil {
log.Printf("error writing ssh key cache: %s", err)
return
}
os.Setenv("BRIGADE_REPO_KEY", keyfile)
defer os.Unsetenv("BRIGADE_REPO_KEY") // purely defensive... not really necessary
}

msg := "Building"
svc := StatusContext
status := new(github.RepoStatus)
Expand Down

0 comments on commit cd23d1d

Please sign in to comment.