Skip to content

Commit

Permalink
fix: removing junk code
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0elliot committed Sep 3, 2023
1 parent 0e721cc commit d26c7a7
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions health.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ func RunOpsWorkflow() (WorkflowHealth, error) {
_ = id
_ = orgId

workflowJson, _ := json.Marshal(workflow)
baseUrl := os.Getenv("SHUFFLE_CLOUDRUN_URL")
if len(baseUrl) == 0 {
baseUrl = "https://shuffler.io"
Expand All @@ -523,7 +522,7 @@ func RunOpsWorkflow() (WorkflowHealth, error) {
// prepare the request
url := baseUrl + "/api/v1/workflows/" + id + "/execute"
log.Printf("[DEBUG] Running health check workflow with URL: %s", url)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(workflowJson))
req, err := http.NewRequest("POST", url, nil)
if err != nil {
log.Printf("[ERROR] Failed creating HTTP request: %s", err)
return workflowHealth, err
Expand All @@ -533,18 +532,18 @@ func RunOpsWorkflow() (WorkflowHealth, error) {
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+os.Getenv("SHUFFLE_OPS_DASHBOARD_APIKEY"))

startId := "98713d6a-dd6b-4bd6-a11c-9778b80f2a28"
body := map[string]string{"execution_argument": "", "start": startId}
// startId := "98713d6a-dd6b-4bd6-a11c-9778b80f2a28"
// body := map[string]string{"execution_argument": "", "start": startId}

// convert the body to JSON
bodyJson, err := json.Marshal(body)
if err != nil {
log.Printf("[ERROR] Failed marshalling body: %s", err)
return workflowHealth, err
}
// bodyJson, err := json.Marshal(body)
// if err != nil {
// log.Printf("[ERROR] Failed marshalling body: %s", err)
// return workflowHealth, err
// }

// set the body
req.Body = ioutil.NopCloser(bytes.NewBuffer(bodyJson))
// req.Body = ioutil.NopCloser(bytes.NewBuffer(bodyJson))

// send the request
client := &http.Client{}
Expand Down Expand Up @@ -643,7 +642,7 @@ func RunOpsWorkflow() (WorkflowHealth, error) {

updateCache(workflowHealth)

log.Printf("[DEBUG] Workflow Health execution Result Status: %#v", executionResults.Status)
log.Printf("[DEBUG] Workflow Health execution Result Status: %#v for executionID: %s", executionResults.Status, workflowHealth.ExecutionId)
}

// 4. Delete workflow
Expand Down Expand Up @@ -710,7 +709,7 @@ func InitOpsWorkflow() (string, error) {
}

if len(user.Id) == 0 && len(user.Username) == 0 {
fmt.Println("[ERROR] Ops dashboard user not found. Not setting up ops workflow")
log.Println("[ERROR] Ops dashboard user not found. Not setting up ops workflow")
return "", errors.New("Ops dashboard user not found")
}

Expand All @@ -726,14 +725,14 @@ func InitOpsWorkflow() (string, error) {
// Create a new HTTP GET request
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println("[ERROR] creating HTTP request:", err)
log.Println("[ERROR] creating HTTP request:", err)
return "", errors.New("Error creating HTTP request: " + err.Error())
}

// Send the HTTP request using the default HTTP client
resp, err := http.DefaultClient.Do(req)
if err != nil {
fmt.Println("[ERROR] sending Ops fetch app HTTP request:", err)
log.Println("[ERROR] sending Ops fetch app HTTP request:", err)
return "", errors.New("Error sending HTTP request: " + err.Error())
}

Expand All @@ -742,15 +741,15 @@ func InitOpsWorkflow() (string, error) {
// Read the response body
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("[ERROR] reading HTTP response body:", err)
log.Println("[ERROR] reading HTTP response body:", err)
return "", errors.New("Error reading HTTP App response response body: " + err.Error())
}

// Unmarshal the JSON data into a Workflow instance
var workflowData Workflow
err = json.Unmarshal(body, &workflowData)
if err != nil {
fmt.Println("[ERROR] unmarshalling Ops workflowData JSON data:", err)
log.Println("[ERROR] unmarshalling Ops workflowData JSON data:", err)
return "", errors.New("Error unmarshalling JSON data: " + err.Error())
}

Expand Down Expand Up @@ -820,10 +819,10 @@ func InitOpsWorkflow() (string, error) {
err = SetWorkflow(ctx, workflowData, workflowData.ID)

if err != nil {
fmt.Println("[ERROR] saving ops dashboard workflow:", err)
log.Println("[ERROR] saving ops dashboard workflow:", err)
return "", errors.New("Error saving ops dashboard workflow: " + err.Error())
}

fmt.Println("[INFO] Ops dashboard workflow saved successfully with ID: workflowData.ID")
log.Println("[INFO] Ops dashboard workflow saved successfully with ID: %s", workflowData.ID)
return workflowData.ID, nil
}

0 comments on commit d26c7a7

Please sign in to comment.