Skip to content

Commit

Permalink
Moves problem write
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaize Kaye committed Apr 16, 2024
1 parent 5bfb578 commit b6ef367
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 0 additions & 1 deletion internal/handler/insightsParserFilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func processSbomInsightsData(h *Messaging, insights InsightsData, v string, apiC
}

// we process the SBOM here
// TODO: This should actually live in its own function somewhere else.
if h.ProblemsFromSBOM == true {
isAlive, err := IsTrivyServerIsAlive(h.TrivyServerEndpoint)
if err != nil {
Expand Down
14 changes: 13 additions & 1 deletion internal/handler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,19 @@ func (h *Messaging) deleteExistingFactsBySource(apiClient graphql.Client, enviro
}

func (h *Messaging) SendProblemSliceToLagoon(result []lagoonclient.LagoonProblem, resource ResourceDestination, source string) error {
slog.Info(fmt.Sprintf("Found the following problems for Project '%v', environment '%v', source '%v"), resource.Project, resource.Environment, source)

apiClient := h.getApiClient()
_, environment, apiErr := determineResourceFromLagoonAPI(apiClient, resource)

if apiErr != nil {
return apiErr
}

slog.Info(fmt.Sprintf("Found the following problems for Project '%v', environment '%v', source '%v", resource.Project, resource.Environment, source))
err := writeProblemsArrayToApi(apiClient, environment.Id, problemSource, resource.Service, result)
if err != nil {
return fmt.Errorf("unable to write problems to api: %v", err.Error())
}
return nil
}

Expand Down
4 changes: 0 additions & 4 deletions internal/handler/trivyProcessing.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ func SbomToProblems(apiClient graphql.Client, trivyRemoteAddress string, bomWrit
problemsArray[i].Source = problemSource
}

err = writeProblemsArrayToApi(apiClient, environmentId, problemSource, service, problemsArray)
if err != nil {
return problemsArray, fmt.Errorf("unable to execute trivy processing- writing problems to api: %v", err.Error())
}
return problemsArray, nil
}

Expand Down

0 comments on commit b6ef367

Please sign in to comment.