-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add status controller and status events table.
Signed-off-by: morvencao <[email protected]>
- Loading branch information
Showing
21 changed files
with
588 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package api | ||
|
||
import ( | ||
"time" | ||
|
||
"gorm.io/datatypes" | ||
"gorm.io/gorm" | ||
) | ||
|
||
type StatusEventType string | ||
|
||
const ( | ||
StatusUpdateEventType StatusEventType = "StatusUpdate" | ||
StatusDeleteEventType StatusEventType = "StatusDelete" | ||
) | ||
|
||
type StatusEvent struct { | ||
Meta | ||
ResourceID string | ||
Status datatypes.JSONMap | ||
StatusEventType StatusEventType // Update|Delete | ||
ReconciledDate *time.Time `json:"gorm:null"` | ||
} | ||
|
||
type StatusEventList []*StatusEvent | ||
type StatusEventIndex map[string]*StatusEvent | ||
|
||
func (l StatusEventList) Index() StatusEventIndex { | ||
index := StatusEventIndex{} | ||
for _, o := range l { | ||
index[o.ID] = o | ||
} | ||
return index | ||
} | ||
|
||
func (e *StatusEvent) BeforeCreate(tx *gorm.DB) error { | ||
e.ID = NewID() | ||
return nil | ||
} |
Oops, something went wrong.