remote-challenge-sync-airbus: Pass arguments through metadata files
This commit is contained in:
parent
3c8ba3ecc2
commit
1e24d0ea25
3 changed files with 72 additions and 6 deletions
|
|
@ -45,6 +45,16 @@ func main() {
|
|||
|
||||
if v, exists := os.LookupEnv("AIRBUS_BASEURL"); exists {
|
||||
api.BaseURL = v
|
||||
} else if v, exists := os.LookupEnv("AIRBUS_BASEURL_FILE"); exists {
|
||||
fd, err := os.Open(v)
|
||||
if err != nil {
|
||||
log.Fatal("Unable to open AIRBUS_BASEURL_FILE:", err)
|
||||
}
|
||||
|
||||
b, _ := ioutil.ReadAll(fd)
|
||||
api.BaseURL = strings.TrimSpace(string(b))
|
||||
|
||||
fd.Close()
|
||||
}
|
||||
if v, exists := os.LookupEnv("AIRBUS_SKIP_TLS_VERIFY"); exists {
|
||||
var err error
|
||||
|
|
@ -55,6 +65,16 @@ func main() {
|
|||
}
|
||||
if v, exists := os.LookupEnv("AIRBUS_TOKEN"); exists {
|
||||
api.Token = v
|
||||
} else if v, exists := os.LookupEnv("AIRBUS_TOKEN_FILE"); exists {
|
||||
fd, err := os.Open(v)
|
||||
if err != nil {
|
||||
log.Fatal("Unable to open AIRBUS_TOKEN_FILE:", err)
|
||||
}
|
||||
|
||||
b, _ := ioutil.ReadAll(fd)
|
||||
api.Token = strings.TrimSpace(string(b))
|
||||
|
||||
fd.Close()
|
||||
}
|
||||
|
||||
if v, exists := os.LookupEnv("AIRBUS_SESSIONID"); exists {
|
||||
|
|
@ -63,6 +83,34 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatal("AIRBUS_SESSIONID is invalid: ", err.Error())
|
||||
}
|
||||
} else if v, exists := os.LookupEnv("AIRBUS_SESSION_NAME_FILE"); exists {
|
||||
fd, err := os.Open(v)
|
||||
if err != nil {
|
||||
log.Fatal("Unable to open AIRBUS_SESSION_NAME_FILE:", err)
|
||||
}
|
||||
|
||||
b, _ := ioutil.ReadAll(fd)
|
||||
fd.Close()
|
||||
|
||||
v = strings.TrimSpace(string(b))
|
||||
|
||||
sessions, err := api.GetSessions()
|
||||
if err != nil {
|
||||
log.Fatal("Unable to retrieve session: ", err)
|
||||
}
|
||||
|
||||
for _, session := range sessions {
|
||||
if session.Name == v {
|
||||
api.SessionID = session.ID
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if api.SessionID == 0 {
|
||||
log.Fatal("Session ID not found")
|
||||
} else {
|
||||
log.Println("Session ID discovered: ", api.SessionID)
|
||||
}
|
||||
} else if v, exists := os.LookupEnv("AIRBUS_SESSION_NAME"); exists {
|
||||
sessions, err := api.GetSessions()
|
||||
if err != nil {
|
||||
|
|
|
|||
Reference in a new issue