From bd042047b3611713518c68c3a94ae80fecfebbae Mon Sep 17 00:00:00 2001 From: Blaize M Kaye Date: Fri, 20 Oct 2023 10:55:58 +1300 Subject: [PATCH] Comments out prob processor --- internal/handler/processing.go | 121 +++++++++++++++++---------------- 1 file changed, 61 insertions(+), 60 deletions(-) diff --git a/internal/handler/processing.go b/internal/handler/processing.go index 732f0c3..92b51ab 100644 --- a/internal/handler/processing.go +++ b/internal/handler/processing.go @@ -74,63 +74,64 @@ func processItemsDirectly(message mq.Message, h *Messaging) string { return facts } -func processProblemsDirectly(message mq.Message, h *Messaging) string { - var directProblems DirectProblems - json.Unmarshal(message.Body(), &directProblems) - err := json.Unmarshal(message.Body(), &directProblems) - if err != nil { - log.Println("Error unmarshaling JSON:", err) - return "exciting, unable to process direct problems" - } - - // since its useful to allow int and string json definitions, we need to convert strings here to ints. - environmentId, err := strconv.Atoi(directProblems.EnvironmentId.String()) - if err != nil { - log.Println("Error converting EnvironmentId to int:", err) - return "exciting, unable to process direct facts" - } - - if h.EnableDebug { - log.Print("[DEBUG] problems", directProblems) - } - - apiClient := graphql.NewClient(h.LagoonAPI.Endpoint, &http.Client{Transport: &authedTransport{wrapped: http.DefaultTransport, h: h}}) - - factSources := map[string]string{} - - processedFacts := make([]lagoonclient.AddProblem, len(directProblems.Facts)) - for i, fact := range directProblems.Facts { - - vartypeString := FactTypeText - if fact.Type == FactTypeText || fact.Type == FactTypeSemver || fact.Type == FactTypeUrl { - vartypeString = fact.Type - } - - processedFacts[i] = lagoonclient.AddFactInput{ - Environment: environmentId, - Name: fact.Name, - Value: fact.Value, - Source: fact.Source, - Description: fact.Description, - KeyFact: false, - Type: lagoonclient.FactType(vartypeString), - Category: fact.Category, - } - factSources[fact.Source] = fact.Source - } - - for _, s := range factSources { - _, err = lagoonclient.DeleteFactsFromSource(context.TODO(), apiClient, environmentId, s) - if err != nil { - log.Println(err) - } - log.Printf("Deleted facts on '%v:%v' for source %v", directProblems.ProjectName, directProblems.EnvironmentName, s) - } - - facts, err := lagoonclient.AddFacts(context.TODO(), apiClient, processedFacts) - if err != nil { - log.Println(err) - } - - return facts -} +// +//func processProblemsDirectly(message mq.Message, h *Messaging) string { +// var directProblems DirectProblems +// json.Unmarshal(message.Body(), &directProblems) +// err := json.Unmarshal(message.Body(), &directProblems) +// if err != nil { +// log.Println("Error unmarshaling JSON:", err) +// return "exciting, unable to process direct problems" +// } +// +// // since its useful to allow int and string json definitions, we need to convert strings here to ints. +// environmentId, err := strconv.Atoi(directProblems.EnvironmentId.String()) +// if err != nil { +// log.Println("Error converting EnvironmentId to int:", err) +// return "exciting, unable to process direct facts" +// } +// +// if h.EnableDebug { +// log.Print("[DEBUG] problems", directProblems) +// } +// +// apiClient := graphql.NewClient(h.LagoonAPI.Endpoint, &http.Client{Transport: &authedTransport{wrapped: http.DefaultTransport, h: h}}) +// +// factSources := map[string]string{} +// +// processedFacts := make([]lagoonclient.AddProblem, len(directProblems.Facts)) +// for i, fact := range directProblems.Facts { +// +// vartypeString := FactTypeText +// if fact.Type == FactTypeText || fact.Type == FactTypeSemver || fact.Type == FactTypeUrl { +// vartypeString = fact.Type +// } +// +// processedFacts[i] = lagoonclient.AddFactInput{ +// Environment: environmentId, +// Name: fact.Name, +// Value: fact.Value, +// Source: fact.Source, +// Description: fact.Description, +// KeyFact: false, +// Type: lagoonclient.FactType(vartypeString), +// Category: fact.Category, +// } +// factSources[fact.Source] = fact.Source +// } +// +// for _, s := range factSources { +// _, err = lagoonclient.DeleteFactsFromSource(context.TODO(), apiClient, environmentId, s) +// if err != nil { +// log.Println(err) +// } +// log.Printf("Deleted facts on '%v:%v' for source %v", directProblems.ProjectName, directProblems.EnvironmentName, s) +// } +// +// facts, err := lagoonclient.AddFacts(context.TODO(), apiClient, processedFacts) +// if err != nil { +// log.Println(err) +// } +// +// return facts +//}