Skip to content

Commit

Permalink
Pass Status to eventing layer
Browse files Browse the repository at this point in the history
  • Loading branch information
josejulio committed Sep 18, 2024
1 parent d886e37 commit 12bac6a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type K8SPolicyIsPropagatedToK8SCluster struct {

MetadataID int64
Metadata common.RelationshipMetadata

Status string
}

// K8SPolicyIsPropagatedToK8SClusterRepo is a K8SPolicyIsPropagatedToK8SCluster repo.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ type K8SPolicyIsPropagatedToK8SClusterRepo struct {
Eventer eventingapi.Manager
}

type K8SPolicyIsPropagatedToK8SClusterDetail struct {
Status string
}

func New(g *gorm.DB, e eventingapi.Manager) *K8SPolicyIsPropagatedToK8SClusterRepo {
return &K8SPolicyIsPropagatedToK8SClusterRepo{
DB: g,
Expand All @@ -35,9 +39,12 @@ func (r *K8SPolicyIsPropagatedToK8SClusterRepo) Save(ctx context.Context, model
if r.Eventer != nil {
// TODO: Update the Object that's sent. This is going to be what we actually emit.
producer, _ := r.Eventer.Lookup(identity, biz.RelationType, model.ID)
evt := eventingapi.NewCreatedResourcesRelationshipEvent(biz.RelationType, model.Metadata.Reporters[0].SubjectLocalResourceId, model.Metadata.UpdatedAt, &eventingapi.EventRelationship[struct{}]{
evt := eventingapi.NewCreatedResourcesRelationshipEvent(biz.RelationType, model.Metadata.Reporters[0].SubjectLocalResourceId, model.Metadata.UpdatedAt, &eventingapi.EventRelationship[K8SPolicyIsPropagatedToK8SClusterDetail]{
Metadata: &model.Metadata,
ReporterData: model.Metadata.Reporters[0],
RelationshipData: &K8SPolicyIsPropagatedToK8SClusterDetail{
Status: model.Status,
},
})
err = producer.Produce(ctx, evt)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func fromCreateRequest(r *relationships.CreateK8SPolicyIsPropagatedToK8SClusterR

return &biz.K8SPolicyIsPropagatedToK8SCluster{
Metadata: *conv.RelationshipMetadataFromPb(metadata, r.K8SpolicyIspropagatedtoK8Scluster.ReporterData, identity),
Status: r.K8SpolicyIspropagatedtoK8Scluster.RelationshipData.Status.String(),
}, nil
}

Expand Down

0 comments on commit 12bac6a

Please sign in to comment.