Skip to content

Commit

Permalink
Fixes merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
bomoko committed Nov 20, 2023
2 parents 0d08015 + 6553a3c commit 7d50dd0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
33 changes: 15 additions & 18 deletions internal/handler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,18 @@ func parserFilterLoopForPayloads(insights InsightsData, p PayloadInput, h *Messa

// processResultset will send results as facts to the lagoon api after processing via a parser filter
func processResultset(result []interface{}, err error, h *Messaging, apiClient graphql.Client, resource ResourceDestination, source string) {
project, environment, apiErr := determineResourceFromLagoonAPI(apiClient, resource)
if apiErr != nil {
log.Println(apiErr)
}

// Even if we don't find any new facts, we need to delete the existing ones
// since these may be the end product of a filter process
apiErr = h.deleteExistingFactsBySource(apiClient, environment, source, project)
if apiErr != nil {
log.Printf("%s", apiErr.Error())
}

for _, r := range result {
if fact, ok := r.(LagoonFact); ok {
// Handle single fact
Expand All @@ -347,31 +359,16 @@ func processResultset(result []interface{}, err error, h *Messaging, apiClient g
}

func (h *Messaging) sendFactsToLagoonAPI(facts []LagoonFact, apiClient graphql.Client, resource ResourceDestination, source string) error {
project, environment, apiErr := determineResourceFromLagoonAPI(apiClient, resource)
if apiErr != nil {
return apiErr
}
//if EnableDebug {
// log.Printf("Matched %d number of fact(s) for '%v:%v', from source '%s'", len(facts), project.Name, environment, source)
//}

slog.Debug("Matched facts",
"Number", len(facts),
"ProjectName", project.Name,
"EnvironmentId", environment.Id,
"EnvironmentName", environment.Name,
"ProjectName", resource.Project,
"EnvironmentId", resource.Environment,
"Source", source,
)

// Even if we don't find any new facts, we need to delete the existing ones
// since these may be the end product of a filter process
apiErr = h.deleteExistingFactsBySource(apiClient, environment, source, project)
if apiErr != nil {
return fmt.Errorf("%s", apiErr.Error())
}

if len(facts) > 0 {
apiErr = h.pushFactsToLagoonApi(facts, resource)
apiErr := h.pushFactsToLagoonApi(facts, resource)
if apiErr != nil {
return fmt.Errorf("%s", apiErr.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion internal/handler/registerFilters.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type FactTransformNameValue struct {
type FactLookupNameValue struct {
Name string `json:"name"`
Value string `json:"value"`
ExactMatch bool `json:"exactMatch"`
ExactMatch bool `json:"exactMatch" yaml:"exactMatch"`
}

type FactTransform struct {
Expand Down

0 comments on commit 7d50dd0

Please sign in to comment.