Skip to content

Commit

Permalink
Add KMS trace type (#318)
Browse files Browse the repository at this point in the history
Bonus: Add function to return trace type from a string.
  • Loading branch information
klauspost authored Dec 12, 2024
1 parent b02ebd2 commit 15df789
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
20 changes: 20 additions & 0 deletions trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package madmin
import (
"math/bits"
"net/http"
"strings"
"time"
)

Expand Down Expand Up @@ -61,6 +62,8 @@ const (
TraceFTP
// TraceILM will trace events during MinIO ILM operations
TraceILM
// TraceKMS are traces for interactions with KMS.
TraceKMS
// Add more here...

// TraceAll contains all valid trace modes.
Expand All @@ -73,6 +76,23 @@ const (
TraceBatch = TraceBatchReplication | TraceBatchKeyRotation | TraceBatchExpire // |TraceBatch<NextFeature>
)

// FindTraceType will find a single trace type from a string,
// as returned by String(). Matching is not case sensitive.
// Will return 0 if not found.
func FindTraceType(s string) TraceType {
bitIdx := uint(0)
for {
idx := TraceType(1 << bitIdx)
if idx > TraceAll {
return 0
}
if strings.EqualFold(idx.String(), s) {
return idx
}
bitIdx++
}
}

// Contains returns whether all flags in other is present in t.
func (t TraceType) Contains(other TraceType) bool {
return t&other == other
Expand Down
8 changes: 5 additions & 3 deletions tracetype_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 15df789

Please sign in to comment.