Skip to content

Commit

Permalink
send addon's ansible event
Browse files Browse the repository at this point in the history
  • Loading branch information
coddmeistr committed Feb 14, 2025
1 parent c8d8a8a commit e3a1e1c
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pkg/graph/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,24 @@ func (ctrl *instancesController) Create(ctx context.Context, group driver.Docume
if err = ctrl.ansPs.Publish("hooks", services_registry.Topic("ansible_hooks"), &c); err != nil {
log.Error("Failed to publish ansible hook", zap.Error(err))
}
for _, a := range i.GetAddons() {
addon, err := ctrl.addons.Get(ctx, a)
if err != nil {
log.Error("Failed to get instance addon", zap.Error(err), zap.String("addon", a))
continue
}
if addon.Action != nil && addon.Action.GetPlaybook() != "" {
c := pb.Context{
Instance: i.GetUuid(),
Sp: sp,
Event: "START",
Addon: &a,
}
if err = ctrl.ansPs.Publish("hooks", services_registry.Topic("ansible_hooks"), &c); err != nil {
log.Error("Failed to publish ansible hook addon event", zap.Error(err))
}
}
}
}
e := epb.Event{
Uuid: i.GetUuid(),
Expand Down Expand Up @@ -785,6 +803,24 @@ func (ctrl *instancesController) Update(ctx context.Context, _ string, inst, old
if err = ctrl.ansPs.Publish("hooks", services_registry.Topic("ansible_hooks"), &c); err != nil {
log.Error("Failed to publish ansible hook", zap.Error(err))
}
for _, a := range inst.GetAddons() {
addon, err := ctrl.addons.Get(ctx, a)
if err != nil {
log.Error("Failed to get instance addon", zap.Error(err), zap.String("addon", a))
continue
}
if addon.Action != nil && addon.Action.GetPlaybook() != "" {
c := pb.Context{
Instance: inst.GetUuid(),
Sp: sp,
Event: "START",
Addon: &a,
}
if err = ctrl.ansPs.Publish("hooks", services_registry.Topic("ansible_hooks"), &c); err != nil {
log.Error("Failed to publish ansible hook addon event", zap.Error(err))
}
}
}
}
c := pb.Context{
Instance: uuid,
Expand Down

0 comments on commit e3a1e1c

Please sign in to comment.