Skip to content

Commit

Permalink
chore: inject component data in selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Sep 23, 2024
1 parent 178768e commit 39014e7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/topology/component_relationship.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@ import (
"github.com/flanksource/duty/job"
"github.com/flanksource/duty/models"
"github.com/flanksource/duty/query"
"github.com/flanksource/duty/types"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/samber/lo"
"gorm.io/gorm/clause"
)

func injectComponentDataInSelectors(comp models.Component) types.ResourceSelectors {
for i, rs := range comp.Selectors {
if rs.Functions.ComponentConfigTraversal != nil {

Check failure on line 20 in pkg/topology/component_relationship.go

View workflow job for this annotation

GitHub Actions / lint

rs.Functions undefined (type "github.com/flanksource/duty/types".ResourceSelector has no field or method Functions)

Check failure on line 20 in pkg/topology/component_relationship.go

View workflow job for this annotation

GitHub Actions / lint

rs.Functions undefined (type "github.com/flanksource/duty/types".ResourceSelector has no field or method Functions)

Check failure on line 20 in pkg/topology/component_relationship.go

View workflow job for this annotation

GitHub Actions / lint

rs.Functions undefined (type "github.com/flanksource/duty/types".ResourceSelector has no field or method Functions)

Check failure on line 20 in pkg/topology/component_relationship.go

View workflow job for this annotation

GitHub Actions / test

rs.Functions undefined (type "github.com/flanksource/duty/types".ResourceSelector has no field or method Functions)
comp.Selectors[i].Functions.ComponentConfigTraversal.ComponentID = comp.ID.String()

Check failure on line 21 in pkg/topology/component_relationship.go

View workflow job for this annotation

GitHub Actions / lint

comp.Selectors[i].Functions undefined (type "github.com/flanksource/duty/types".ResourceSelector has no field or method Functions) (typecheck)

Check failure on line 21 in pkg/topology/component_relationship.go

View workflow job for this annotation

GitHub Actions / lint

comp.Selectors[i].Functions undefined (type "github.com/flanksource/duty/types".ResourceSelector has no field or method Functions)) (typecheck)

Check failure on line 21 in pkg/topology/component_relationship.go

View workflow job for this annotation

GitHub Actions / lint

comp.Selectors[i].Functions undefined (type "github.com/flanksource/duty/types".ResourceSelector has no field or method Functions)) (typecheck)

Check failure on line 21 in pkg/topology/component_relationship.go

View workflow job for this annotation

GitHub Actions / test

comp.Selectors[i].Functions undefined (type "github.com/flanksource/duty/types".ResourceSelector has no field or method Functions)
}
}
return comp.Selectors
}

var ComponentRelationshipSync = &job.Job{
Name: "ComponentRelationshipSync",
Schedule: "@every 5m",
Expand All @@ -30,7 +40,8 @@ var ComponentRelationshipSync = &job.Job{

for _, component := range components {
hash := component.Selectors.Hash()
comps, err := query.FindComponents(ctx.Context, -1, component.Selectors...)
selectors := injectComponentDataInSelectors(component)
comps, err := query.FindComponents(ctx.Context, -1, selectors...)
if err != nil {
ctx.History.AddError(fmt.Sprintf("error getting components with selectors: %v. err: %v", component.Selectors, err))
continue
Expand Down

0 comments on commit 39014e7

Please sign in to comment.