Skip to content

Commit

Permalink
fix: addition of vertices for changes only results
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed May 13, 2024
1 parent adf702d commit cbf6f66
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions db/models/config_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ type ConfigItem struct {

func (ci ConfigItem) String() string {
if len(ci.ExternalID) == 0 {
return fmt.Sprintf("%s/%s", *ci.Type, *ci.Name)
return fmt.Sprintf("id=%s name=%s type=%s", ci.ID, *ci.Type, *ci.Name)
}
return fmt.Sprintf("%s/%s id=%s", *ci.Type, *ci.Name, ci.ExternalID[0])

return fmt.Sprintf("id=%s name=%s type=%s external_id=%s", ci.ID, *ci.Type, *ci.Name, ci.ExternalID[0])
}

func (ci ConfigItem) ConfigJSONStringMap() (map[string]interface{}, error) {
Expand Down
8 changes: 4 additions & 4 deletions db/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,10 +589,6 @@ func extractConfigsAndChangesFromResults(ctx api.ScrapeContext, scrapeStartTime
root = ci.ID
}

if err := tree.AddVertex(ci.ID); err != nil {
return nil, nil, nil, nil, fmt.Errorf("unable to add vertex(%s): %w", ci, err)
}

parentExternalKey := configExternalKey{externalID: ci.ExternalID[0], parentType: lo.FromPtr(ci.Type)}
parentTypeToConfigMap[parentExternalKey] = ci.ID

Expand All @@ -609,6 +605,10 @@ func extractConfigsAndChangesFromResults(ctx api.ScrapeContext, scrapeStartTime

allConfigs = append(allConfigs, ci)
if result.Config != nil {
if err := tree.AddVertex(ci.ID); err != nil {
return nil, nil, nil, nil, fmt.Errorf("unable to add vertex(%s): %w", ci, err)
}

if existing == nil || existing.ID == "" {
newConfigs = append(newConfigs, ci)
} else {
Expand Down

0 comments on commit cbf6f66

Please sign in to comment.