Skip to content

Commit

Permalink
condition/types: Adds helper method to return the publish subject for…
Browse files Browse the repository at this point in the history
… a Condition
  • Loading branch information
joelrebel committed Jun 26, 2024
1 parent b957d57 commit ceb9b44
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions condition/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package condition

import (
"encoding/json"
"fmt"
"time"

"github.com/google/uuid"
Expand Down Expand Up @@ -140,6 +141,16 @@ type Condition struct {
CreatedAt time.Time `json:"createdAt,omitempty"`
}

func (c *Condition) StreamPublishSubject(facilityCode string) string {
// note: inband install conditions are published with the serverID in the subject suffix
if c.Kind == FirmwareInstallInband {
return fmt.Sprintf("%s.servers.%s.%s", facilityCode, c.Kind, c.Target.String())

}

return fmt.Sprintf("%s.servers.%s", facilityCode, c.Kind)
}

// Fault is used to introduce faults into the controller when executing on a condition.
//
// Note: this depends on controllers implementing support to honor the given fault.
Expand Down

0 comments on commit ceb9b44

Please sign in to comment.