layer1: add namespace event helpers step 15

This commit is contained in:
Naeel
2026-04-26 10:05:51 +03:00
parent db4499d8c7
commit 834c0de941
3 changed files with 55 additions and 2 deletions
+17 -1
View File
@@ -61,6 +61,22 @@ type NamespaceEvent struct {
ObservedAt time.Time
}
func NewNamespaceEvent(eventType NamespaceEventType, name string, labels map[string]string, source NamespaceSource, observedAt time.Time) NamespaceEvent {
return NamespaceEvent{
Type: eventType,
Name: name,
Labels: cloneStringMap(labels),
Source: source,
ObservedAt: observedAt,
}
}
func ManagedNamespaceEvent(eventType NamespaceEventType, name string, source NamespaceSource, observedAt time.Time) NamespaceEvent {
return NewNamespaceEvent(eventType, name, map[string]string{
ManagedNamespaceLabelKey: ManagedNamespaceLabelValue,
}, source, observedAt)
}
func (nr NamespaceRecord) Clone() NamespaceRecord {
clone := nr
clone.Labels = cloneStringMap(nr.Labels)
@@ -98,4 +114,4 @@ func cloneNamespacePartStates(input map[string]NamespacePartState) map[string]Na
clone[key] = value
}
return clone
}
}