Skip to content

Commit

Permalink
Fix/token (#13)
Browse files Browse the repository at this point in the history
* feat(test): test

* fix(token): fix null token
  • Loading branch information
giangbui authored Mar 3, 2020
1 parent 3fed393 commit bf5df61
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion handlers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package handlers

import (
"encoding/json"
"fmt"
"io/ioutil"

k8sv1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -30,6 +31,10 @@ type SowerConfig struct {
func loadSowerConfigs(config string) []SowerConfig {
plan, _ := ioutil.ReadFile(config)
var data []SowerConfig
_ = json.Unmarshal(plan, &data)
err := json.Unmarshal(plan, &data)
if err != nil {
fmt.Println("ERROR: ", err)
return nil
}
return data
}
2 changes: 1 addition & 1 deletion handlers/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func createK8sJob(currentAction string, inputData string, accessToken string, us
randname := GetRandString(5)
name := fmt.Sprintf("%s-%s", conf.Name, randname)
fmt.Println("input data: ", inputData)
var deadline int64 = 3600
var deadline int64 = 7200
var backoff int32 = 1
labels := make(map[string]string)
labels["app"] = "sowerjob"
Expand Down
7 changes: 6 additions & 1 deletion handlers/sower.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ func dispatch(w http.ResponseWriter, r *http.Request) {

fmt.Println(string(out))

result, err := createK8sJob(currentAction, string(out), *accessToken, userName)
accessTokenVal := ""
if accessToken != nil {
accessTokenVal = *accessToken
}

result, err := createK8sJob(currentAction, string(out), accessTokenVal, userName)
if err != nil {
http.Error(w, err.Error(), 500)
return
Expand Down

0 comments on commit bf5df61

Please sign in to comment.