func main() { if len(os.Args) < 2 { log.Fatal("Missing required authentication type") } authFd := os.NewFile(3, "") authData, err := readData(authFd) if err != nil { log.Fatal("Error reading authentication data ", err) } client := helpers.NewClient() response, loginErr := client.Login(string(os.Args[1]), string(authData)) if loginErr != nil { var respErr error response, respErr = jsonError(loginErr) if respErr != nil { log.Fatal("Error generating response ", respErr) } } sendAuthResponse(authFd, response) if loginErr == nil { if os.Getenv("XDG_RUNTIME_DIR") == "" { os.Setenv("XDG_RUNTIME_DIR", "/tmp") } syscall.Exec("/usr/libexec/cockpit-stub", nil, os.Environ()) } }
func haveOpenShiftEndpoint() (bool, error) { var isOpenShift bool = false creds, err := helpers.NewCredentialsForSystem() if err != nil { return isOpenShift, err } client := helpers.NewClient() resp, e := client.DoRequest("GET", "oapi", "", creds, nil) if e != nil { return isOpenShift, e } defer resp.Body.Close() if resp.StatusCode == 200 { isOpenShift = true } return isOpenShift, nil }