mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
34 lines
700 B
Go
34 lines
700 B
Go
package audit
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"cdr.dev/slog"
|
|
)
|
|
|
|
type BackgroundSubsystem string
|
|
|
|
const (
|
|
BackgroundSubsystemDormancy BackgroundSubsystem = "dormancy"
|
|
)
|
|
|
|
func BackgroundTaskFields(subsystem BackgroundSubsystem) map[string]string {
|
|
return map[string]string{
|
|
"automatic_actor": "coder",
|
|
"automatic_subsystem": string(subsystem),
|
|
}
|
|
}
|
|
|
|
func BackgroundTaskFieldsBytes(ctx context.Context, logger slog.Logger, subsystem BackgroundSubsystem) []byte {
|
|
af := BackgroundTaskFields(subsystem)
|
|
|
|
wriBytes, err := json.Marshal(af)
|
|
if err != nil {
|
|
logger.Error(ctx, "marshal additional fields for dormancy audit", slog.Error(err))
|
|
return []byte("{}")
|
|
}
|
|
|
|
return wriBytes
|
|
}
|