feat: add auditing for groups (#4527)

- Clean up `database.TemplateACL` implementation.
This commit is contained in:
Jon Ayers
2022-10-19 02:00:45 -05:00
committed by GitHub
parent d4585fefb8
commit 0d1096da6c
27 changed files with 405 additions and 213 deletions
+2 -1
View File
@@ -15,7 +15,8 @@ type Auditable interface {
database.TemplateVersion |
database.User |
database.Workspace |
database.GitSSHKey
database.GitSSHKey |
database.Group
}
// Map is a map of changed fields in an audited resource. It maps field names to
+6
View File
@@ -45,6 +45,8 @@ func ResourceTarget[T Auditable](tgt T) string {
return typed.Name
case database.GitSSHKey:
return typed.PublicKey
case database.Group:
return typed.Name
default:
panic(fmt.Sprintf("unknown resource %T", tgt))
}
@@ -64,6 +66,8 @@ func ResourceID[T Auditable](tgt T) uuid.UUID {
return typed.ID
case database.GitSSHKey:
return typed.UserID
case database.Group:
return typed.ID
default:
panic(fmt.Sprintf("unknown resource %T", tgt))
}
@@ -83,6 +87,8 @@ func ResourceType[T Auditable](tgt T) database.ResourceType {
return database.ResourceTypeWorkspace
case database.GitSSHKey:
return database.ResourceTypeGitSshKey
case database.Group:
return database.ResourceTypeGroup
default:
panic(fmt.Sprintf("unknown resource %T", tgt))
}