Skip to content

Commit

Permalink
add optional HTTP basic authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Hoffman committed Jun 25, 2015
1 parent eb4923f commit f1ca094
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ Configuration in the `production.json` file can be overridden with environment v
Environment Variable | Corresponds To
---------------------|---------------
`MARATHON_ENDPOINT` | Marathon.Endpoint
`MARATHON_USER` | Marathon.User
`MARATHON_PASSWORD` | Marathon.Password
`BAMBOO_ENDPOINT` | Bamboo.Endpoint
`BAMBOO_ZK_HOST` | Bamboo.Zookeeper.Host
`BAMBOO_ZK_PATH` | Bamboo.Zookeeper.Path
Expand Down
2 changes: 2 additions & 0 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func FromFile(filePath string) (Configuration, error) {
conf := &Configuration{}
err := conf.FromFile(filePath)
setValueFromEnv(&conf.Marathon.Endpoint, "MARATHON_ENDPOINT")
setValueFromEnv(&conf.Marathon.User, "MARATHON_USER")
setValueFromEnv(&conf.Marathon.Password, "MARATHON_PASSWORD")

setValueFromEnv(&conf.Bamboo.Endpoint, "BAMBOO_ENDPOINT")
setValueFromEnv(&conf.Bamboo.Zookeeper.Host, "BAMBOO_ZK_HOST")
Expand Down
2 changes: 2 additions & 0 deletions configuration/marathon.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
type Marathon struct {
// comma separated marathon http endpoints including port number
Endpoint string
User string
Password string
}

func (m Marathon) Endpoints() []string {
Expand Down
3 changes: 3 additions & 0 deletions main/bamboo/bamboo.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ func registerMarathonEvent(conf *configuration.Configuration) {
url := marathon + "/v2/eventSubscriptions?callbackUrl=" + conf.Bamboo.Endpoint + "/api/marathon/event_callback"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Content-Type", "application/json")
if (len(conf.Marathon.User)>0 && len(conf.Marathon.Password)>0) {
req.SetBasicAuth(conf.Marathon.User, conf.Marathon.Password)
}
resp, err := client.Do(req)
if err != nil {
errorMsg := "An error occurred while accessing Marathon callback system: %s\n"
Expand Down

0 comments on commit f1ca094

Please sign in to comment.