Skip to content

Commit

Permalink
Change to newer auth cookie names
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeppe-pivotal committed Nov 20, 2018
1 parent 69673a1 commit 4704379
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions src/fly-utils/fly-log/main.go
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
package main

import (
"encoding/json"
"flag"
"net/url"
"log"
"fly-utils/flyrc"
"fmt"
"net/http"
"github.com/donovanhide/eventsource"
"fly-utils/flyrc"
"io/ioutil"
"encoding/json"
"log"
"net/http"
"net/url"
)

type Build struct {
ApiUrl string `json:"api_url"`
EndTime int `json:"end_time"`
Id int `json:"id"`
JobName string `json:"job_name"`
Name string `json:"name"`
PipelineName string `json:"pipeline_name"`
StartTime int `json:"start_time"`
Status string `json:"status"`
TeamName string `json:"team_name"`
Url string `json:"url"`
ApiUrl string `json:"api_url"`
EndTime int `json:"end_time"`
Id int `json:"id"`
JobName string `json:"job_name"`
Name string `json:"name"`
PipelineName string `json:"pipeline_name"`
StartTime int `json:"start_time"`
Status string `json:"status"`
TeamName string `json:"team_name"`
Url string `json:"url"`
}

type EventData struct {
Data struct {
Origin struct {
Source string `json:"source",omitempty`
} `json:"origin",omitempty`
Payload string `json:"payload",omitempty`
Time int `json:"time",omitempty`
ExitStatus int `json:"exit_status",omitempty`
Status string `json:"status",omitempty`
} `json:"data",omitempty`
Event string `json:"event",omitempty`
Data struct {
Origin struct {
Source string `json:"source",omitempty`
} `json:"origin",omitempty`
Payload string `json:"payload",omitempty`
Time int `json:"time",omitempty`
ExitStatus int `json:"exit_status",omitempty`
Status string `json:"status",omitempty`
} `json:"data",omitempty`
Event string `json:"event",omitempty`
}

func main() {
Expand All @@ -57,13 +57,13 @@ func main() {
}

cookie := &http.Cookie{
Name: "ATC-Authorization",
Name: "skymarshal_auth",
Value: fmt.Sprintf("Bearer %s", token),
}

build, err := getBuild(u, cookie)
if err != nil {
log.Fatal(err)
log.Fatal(fmt.Sprintf("Unable to get build: %s", err))
}

eventUrl, err := url.Parse(fmt.Sprintf("%s://%s/api/v1/builds/%d/events", u.Scheme, u.Host, build.Id))
Expand Down Expand Up @@ -128,12 +128,12 @@ func getBuild(u *url.URL, cookie *http.Cookie) (*Build, error) {
resp, err := client.Do(req)
defer resp.Body.Close()
if err != nil {
log.Fatal(err)
log.Fatal(fmt.Sprintf("Error calling endpoint for build: %s", err))
}

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
log.Fatal(fmt.Sprintf("Error reading body from endpoint for build: %s", err))
}

var build Build
Expand Down

0 comments on commit 4704379

Please sign in to comment.