mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: audit addition and removal of licenses (#6125)
* added license audit resource * audit delete licenses * added filtering * remove logs * making the best of the current UUID situation * fixed lint * fix tests * regen docs * PR feedback * PR feedback
This commit is contained in:
@@ -15,7 +15,8 @@ type Auditable interface {
|
||||
database.Workspace |
|
||||
database.GitSSHKey |
|
||||
database.WorkspaceBuild |
|
||||
database.AuditableGroup
|
||||
database.AuditableGroup |
|
||||
database.License
|
||||
}
|
||||
|
||||
// Map is a map of changed fields in an audited resource. It maps field names to
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/tabbed/pqtype"
|
||||
@@ -71,6 +72,8 @@ func ResourceTarget[T Auditable](tgt T) string {
|
||||
case database.APIKey:
|
||||
// this isn't used
|
||||
return ""
|
||||
case database.License:
|
||||
return strconv.Itoa(int(typed.ID))
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown resource %T", tgt))
|
||||
}
|
||||
@@ -94,6 +97,8 @@ func ResourceID[T Auditable](tgt T) uuid.UUID {
|
||||
return typed.Group.ID
|
||||
case database.APIKey:
|
||||
return typed.UserID
|
||||
case database.License:
|
||||
return typed.UUID
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown resource %T", tgt))
|
||||
}
|
||||
@@ -117,6 +122,8 @@ func ResourceType[T Auditable](tgt T) database.ResourceType {
|
||||
return database.ResourceTypeGroup
|
||||
case database.APIKey:
|
||||
return database.ResourceTypeApiKey
|
||||
case database.License:
|
||||
return database.ResourceTypeLicense
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown resource %T", tgt))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user