Skip to content

Commit ceb9b44

Browse files
committed
condition/types: Adds helper method to return the publish subject for a Condition
1 parent b957d57 commit ceb9b44

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

condition/types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package condition
22

33
import (
44
"encoding/json"
5+
"fmt"
56
"time"
67

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

144+
func (c *Condition) StreamPublishSubject(facilityCode string) string {
145+
// note: inband install conditions are published with the serverID in the subject suffix
146+
if c.Kind == FirmwareInstallInband {
147+
return fmt.Sprintf("%s.servers.%s.%s", facilityCode, c.Kind, c.Target.String())
148+
149+
}
150+
151+
return fmt.Sprintf("%s.servers.%s", facilityCode, c.Kind)
152+
}
153+
143154
// Fault is used to introduce faults into the controller when executing on a condition.
144155
//
145156
// Note: this depends on controllers implementing support to honor the given fault.

0 commit comments

Comments
 (0)