mirror of https://github.com/coder/coder.git
chore: removing unaudited resources (#5885)
* chore: removing unaudited resources * cleaned up tests * CI errors
This commit is contained in:
parent
e2bea2d20f
commit
3d58e6912a
|
@ -3,6 +3,7 @@
|
||||||
"afero",
|
"afero",
|
||||||
"apps",
|
"apps",
|
||||||
"ASKPASS",
|
"ASKPASS",
|
||||||
|
"autostop",
|
||||||
"awsidentity",
|
"awsidentity",
|
||||||
"bodyclose",
|
"bodyclose",
|
||||||
"buildinfo",
|
"buildinfo",
|
||||||
|
|
|
@ -5648,15 +5648,13 @@ const docTemplate = `{
|
||||||
},
|
},
|
||||||
"resource_type": {
|
"resource_type": {
|
||||||
"enum": [
|
"enum": [
|
||||||
"organization",
|
|
||||||
"template",
|
"template",
|
||||||
"template_version",
|
"template_version",
|
||||||
"user",
|
"user",
|
||||||
"workspace",
|
"workspace",
|
||||||
"workspace_build",
|
"workspace_build",
|
||||||
"git_ssh_key",
|
"git_ssh_key",
|
||||||
"api_key",
|
"auditable_group"
|
||||||
"group"
|
|
||||||
],
|
],
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
|
@ -7114,7 +7112,6 @@ const docTemplate = `{
|
||||||
"codersdk.ResourceType": {
|
"codersdk.ResourceType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"organization",
|
|
||||||
"template",
|
"template",
|
||||||
"template_version",
|
"template_version",
|
||||||
"user",
|
"user",
|
||||||
|
@ -7125,7 +7122,6 @@ const docTemplate = `{
|
||||||
"group"
|
"group"
|
||||||
],
|
],
|
||||||
"x-enum-varnames": [
|
"x-enum-varnames": [
|
||||||
"ResourceTypeOrganization",
|
|
||||||
"ResourceTypeTemplate",
|
"ResourceTypeTemplate",
|
||||||
"ResourceTypeTemplateVersion",
|
"ResourceTypeTemplateVersion",
|
||||||
"ResourceTypeUser",
|
"ResourceTypeUser",
|
||||||
|
|
|
@ -4996,15 +4996,13 @@
|
||||||
},
|
},
|
||||||
"resource_type": {
|
"resource_type": {
|
||||||
"enum": [
|
"enum": [
|
||||||
"organization",
|
|
||||||
"template",
|
"template",
|
||||||
"template_version",
|
"template_version",
|
||||||
"user",
|
"user",
|
||||||
"workspace",
|
"workspace",
|
||||||
"workspace_build",
|
"workspace_build",
|
||||||
"git_ssh_key",
|
"git_ssh_key",
|
||||||
"api_key",
|
"auditable_group"
|
||||||
"group"
|
|
||||||
],
|
],
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
|
@ -6369,7 +6367,6 @@
|
||||||
"codersdk.ResourceType": {
|
"codersdk.ResourceType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"organization",
|
|
||||||
"template",
|
"template",
|
||||||
"template_version",
|
"template_version",
|
||||||
"user",
|
"user",
|
||||||
|
@ -6380,7 +6377,6 @@
|
||||||
"group"
|
"group"
|
||||||
],
|
],
|
||||||
"x-enum-varnames": [
|
"x-enum-varnames": [
|
||||||
"ResourceTypeOrganization",
|
|
||||||
"ResourceTypeTemplate",
|
"ResourceTypeTemplate",
|
||||||
"ResourceTypeTemplateVersion",
|
"ResourceTypeTemplateVersion",
|
||||||
"ResourceTypeUser",
|
"ResourceTypeUser",
|
||||||
|
|
|
@ -452,8 +452,6 @@ func auditSearchQuery(query string) (database.GetAuditLogsOffsetParams, []coders
|
||||||
|
|
||||||
func resourceTypeFromString(resourceTypeString string) string {
|
func resourceTypeFromString(resourceTypeString string) string {
|
||||||
switch codersdk.ResourceType(resourceTypeString) {
|
switch codersdk.ResourceType(resourceTypeString) {
|
||||||
case codersdk.ResourceTypeOrganization:
|
|
||||||
return resourceTypeString
|
|
||||||
case codersdk.ResourceTypeTemplate:
|
case codersdk.ResourceTypeTemplate:
|
||||||
return resourceTypeString
|
return resourceTypeString
|
||||||
case codersdk.ResourceTypeTemplateVersion:
|
case codersdk.ResourceTypeTemplateVersion:
|
||||||
|
|
|
@ -9,8 +9,6 @@ import (
|
||||||
// AuditableResources, then add it to this interface.
|
// AuditableResources, then add it to this interface.
|
||||||
type Auditable interface {
|
type Auditable interface {
|
||||||
database.APIKey |
|
database.APIKey |
|
||||||
database.Organization |
|
|
||||||
database.OrganizationMember |
|
|
||||||
database.Template |
|
database.Template |
|
||||||
database.TemplateVersion |
|
database.TemplateVersion |
|
||||||
database.User |
|
database.User |
|
||||||
|
|
|
@ -49,8 +49,6 @@ type BuildAuditParams[T Auditable] struct {
|
||||||
|
|
||||||
func ResourceTarget[T Auditable](tgt T) string {
|
func ResourceTarget[T Auditable](tgt T) string {
|
||||||
switch typed := any(tgt).(type) {
|
switch typed := any(tgt).(type) {
|
||||||
case database.Organization:
|
|
||||||
return typed.Name
|
|
||||||
case database.Template:
|
case database.Template:
|
||||||
return typed.Name
|
return typed.Name
|
||||||
case database.TemplateVersion:
|
case database.TemplateVersion:
|
||||||
|
@ -73,8 +71,6 @@ func ResourceTarget[T Auditable](tgt T) string {
|
||||||
|
|
||||||
func ResourceID[T Auditable](tgt T) uuid.UUID {
|
func ResourceID[T Auditable](tgt T) uuid.UUID {
|
||||||
switch typed := any(tgt).(type) {
|
switch typed := any(tgt).(type) {
|
||||||
case database.Organization:
|
|
||||||
return typed.ID
|
|
||||||
case database.Template:
|
case database.Template:
|
||||||
return typed.ID
|
return typed.ID
|
||||||
case database.TemplateVersion:
|
case database.TemplateVersion:
|
||||||
|
@ -96,8 +92,6 @@ func ResourceID[T Auditable](tgt T) uuid.UUID {
|
||||||
|
|
||||||
func ResourceType[T Auditable](tgt T) database.ResourceType {
|
func ResourceType[T Auditable](tgt T) database.ResourceType {
|
||||||
switch any(tgt).(type) {
|
switch any(tgt).(type) {
|
||||||
case database.Organization:
|
|
||||||
return database.ResourceTypeOrganization
|
|
||||||
case database.Template:
|
case database.Template:
|
||||||
return database.ResourceTypeTemplate
|
return database.ResourceTypeTemplate
|
||||||
case database.TemplateVersion:
|
case database.TemplateVersion:
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
type ResourceType string
|
type ResourceType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ResourceTypeOrganization ResourceType = "organization"
|
|
||||||
ResourceTypeTemplate ResourceType = "template"
|
ResourceTypeTemplate ResourceType = "template"
|
||||||
ResourceTypeTemplateVersion ResourceType = "template_version"
|
ResourceTypeTemplateVersion ResourceType = "template_version"
|
||||||
ResourceTypeUser ResourceType = "user"
|
ResourceTypeUser ResourceType = "user"
|
||||||
|
@ -27,8 +26,6 @@ const (
|
||||||
|
|
||||||
func (r ResourceType) FriendlyString() string {
|
func (r ResourceType) FriendlyString() string {
|
||||||
switch r {
|
switch r {
|
||||||
case ResourceTypeOrganization:
|
|
||||||
return "organization"
|
|
||||||
case ResourceTypeTemplate:
|
case ResourceTypeTemplate:
|
||||||
return "template"
|
return "template"
|
||||||
case ResourceTypeTemplateVersion:
|
case ResourceTypeTemplateVersion:
|
||||||
|
@ -122,7 +119,7 @@ type AuditLogResponse struct {
|
||||||
|
|
||||||
type CreateTestAuditLogRequest struct {
|
type CreateTestAuditLogRequest struct {
|
||||||
Action AuditAction `json:"action,omitempty" enums:"create,write,delete,start,stop"`
|
Action AuditAction `json:"action,omitempty" enums:"create,write,delete,start,stop"`
|
||||||
ResourceType ResourceType `json:"resource_type,omitempty" enums:"organization,template,template_version,user,workspace,workspace_build,git_ssh_key,api_key,group"`
|
ResourceType ResourceType `json:"resource_type,omitempty" enums:"template,template_version,user,workspace,workspace_build,git_ssh_key,auditable_group"`
|
||||||
ResourceID uuid.UUID `json:"resource_id,omitempty" format:"uuid"`
|
ResourceID uuid.UUID `json:"resource_id,omitempty" format:"uuid"`
|
||||||
Time time.Time `json:"time,omitempty" format:"date-time"`
|
Time time.Time `json:"time,omitempty" format:"date-time"`
|
||||||
BuildReason BuildReason `json:"build_reason,omitempty" enums:"autostart,autostop,initiator"`
|
BuildReason BuildReason `json:"build_reason,omitempty" enums:"autostart,autostop,initiator"`
|
||||||
|
|
|
@ -54,7 +54,7 @@ curl -X GET http://coder-server:8080/api/v2/audit?q=string \
|
||||||
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
|
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
|
||||||
"resource_link": "string",
|
"resource_link": "string",
|
||||||
"resource_target": "string",
|
"resource_target": "string",
|
||||||
"resource_type": "organization",
|
"resource_type": "template",
|
||||||
"status_code": 0,
|
"status_code": 0,
|
||||||
"time": "2019-08-24T14:15:22Z",
|
"time": "2019-08-24T14:15:22Z",
|
||||||
"user": {
|
"user": {
|
||||||
|
@ -108,7 +108,7 @@ curl -X POST http://coder-server:8080/api/v2/audit/testgenerate \
|
||||||
"action": "create",
|
"action": "create",
|
||||||
"build_reason": "autostart",
|
"build_reason": "autostart",
|
||||||
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
|
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
|
||||||
"resource_type": "organization",
|
"resource_type": "template",
|
||||||
"time": "2019-08-24T14:15:22Z"
|
"time": "2019-08-24T14:15:22Z"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -330,7 +330,7 @@
|
||||||
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
|
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
|
||||||
"resource_link": "string",
|
"resource_link": "string",
|
||||||
"resource_target": "string",
|
"resource_target": "string",
|
||||||
"resource_type": "organization",
|
"resource_type": "template",
|
||||||
"status_code": 0,
|
"status_code": 0,
|
||||||
"time": "2019-08-24T14:15:22Z",
|
"time": "2019-08-24T14:15:22Z",
|
||||||
"user": {
|
"user": {
|
||||||
|
@ -406,7 +406,7 @@
|
||||||
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
|
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
|
||||||
"resource_link": "string",
|
"resource_link": "string",
|
||||||
"resource_target": "string",
|
"resource_target": "string",
|
||||||
"resource_type": "organization",
|
"resource_type": "template",
|
||||||
"status_code": 0,
|
"status_code": 0,
|
||||||
"time": "2019-08-24T14:15:22Z",
|
"time": "2019-08-24T14:15:22Z",
|
||||||
"user": {
|
"user": {
|
||||||
|
@ -785,7 +785,7 @@ CreateParameterRequest is a structure used to create a new parameter value for a
|
||||||
"action": "create",
|
"action": "create",
|
||||||
"build_reason": "autostart",
|
"build_reason": "autostart",
|
||||||
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
|
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
|
||||||
"resource_type": "organization",
|
"resource_type": "template",
|
||||||
"time": "2019-08-24T14:15:22Z"
|
"time": "2019-08-24T14:15:22Z"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -812,15 +812,13 @@ CreateParameterRequest is a structure used to create a new parameter value for a
|
||||||
| `build_reason` | `autostart` |
|
| `build_reason` | `autostart` |
|
||||||
| `build_reason` | `autostop` |
|
| `build_reason` | `autostop` |
|
||||||
| `build_reason` | `initiator` |
|
| `build_reason` | `initiator` |
|
||||||
| `resource_type` | `organization` |
|
|
||||||
| `resource_type` | `template` |
|
| `resource_type` | `template` |
|
||||||
| `resource_type` | `template_version` |
|
| `resource_type` | `template_version` |
|
||||||
| `resource_type` | `user` |
|
| `resource_type` | `user` |
|
||||||
| `resource_type` | `workspace` |
|
| `resource_type` | `workspace` |
|
||||||
| `resource_type` | `workspace_build` |
|
| `resource_type` | `workspace_build` |
|
||||||
| `resource_type` | `git_ssh_key` |
|
| `resource_type` | `git_ssh_key` |
|
||||||
| `resource_type` | `api_key` |
|
| `resource_type` | `auditable_group` |
|
||||||
| `resource_type` | `group` |
|
|
||||||
|
|
||||||
## codersdk.CreateTokenRequest
|
## codersdk.CreateTokenRequest
|
||||||
|
|
||||||
|
@ -3739,7 +3737,7 @@ Parameter represents a set value for the scope.
|
||||||
## codersdk.ResourceType
|
## codersdk.ResourceType
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"organization"
|
"template"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Properties
|
### Properties
|
||||||
|
@ -3748,7 +3746,6 @@ Parameter represents a set value for the scope.
|
||||||
|
|
||||||
| Value |
|
| Value |
|
||||||
| ------------------ |
|
| ------------------ |
|
||||||
| `organization` |
|
|
||||||
| `template` |
|
| `template` |
|
||||||
| `template_version` |
|
| `template_version` |
|
||||||
| `user` |
|
| `user` |
|
||||||
|
|
|
@ -275,44 +275,6 @@ func Test_diff(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
runDiffTests(t, []diffTest{
|
|
||||||
{
|
|
||||||
name: "Create",
|
|
||||||
left: audit.Empty[database.OrganizationMember](),
|
|
||||||
right: database.OrganizationMember{
|
|
||||||
UserID: uuid.UUID{1},
|
|
||||||
OrganizationID: uuid.UUID{2},
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
UpdatedAt: time.Now(),
|
|
||||||
Roles: []string{"auditor"},
|
|
||||||
},
|
|
||||||
exp: audit.Map{
|
|
||||||
"user_id": audit.OldNew{Old: "", New: uuid.UUID{1}.String()},
|
|
||||||
"organization_id": audit.OldNew{Old: "", New: uuid.UUID{2}.String()},
|
|
||||||
"roles": audit.OldNew{Old: ([]string)(nil), New: []string{"auditor"}},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
runDiffTests(t, []diffTest{
|
|
||||||
{
|
|
||||||
name: "Create",
|
|
||||||
left: audit.Empty[database.Organization](),
|
|
||||||
right: database.Organization{
|
|
||||||
ID: uuid.UUID{1},
|
|
||||||
Name: "rust developers",
|
|
||||||
Description: "an organization for rust developers",
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
UpdatedAt: time.Now(),
|
|
||||||
},
|
|
||||||
exp: audit.Map{
|
|
||||||
"id": audit.OldNew{Old: "", New: uuid.UUID{1}.String()},
|
|
||||||
"name": audit.OldNew{Old: "", New: "rust developers"},
|
|
||||||
"description": audit.OldNew{Old: "", New: "an organization for rust developers"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
runDiffTests(t, []diffTest{
|
runDiffTests(t, []diffTest{
|
||||||
{
|
{
|
||||||
name: "Create",
|
name: "Create",
|
||||||
|
|
|
@ -33,20 +33,6 @@ var AuditableResources = auditMap(map[any]map[string]Action{
|
||||||
"private_key": ActionSecret, // We don't want to expose private keys in diffs.
|
"private_key": ActionSecret, // We don't want to expose private keys in diffs.
|
||||||
"public_key": ActionTrack, // Public keys are ok to expose in a diff.
|
"public_key": ActionTrack, // Public keys are ok to expose in a diff.
|
||||||
},
|
},
|
||||||
&database.OrganizationMember{}: {
|
|
||||||
"user_id": ActionTrack,
|
|
||||||
"organization_id": ActionTrack,
|
|
||||||
"created_at": ActionIgnore, // Never changes, but is implicit and not helpful in a diff.
|
|
||||||
"updated_at": ActionIgnore, // Changes, but is implicit and not helpful in a diff.
|
|
||||||
"roles": ActionTrack,
|
|
||||||
},
|
|
||||||
&database.Organization{}: {
|
|
||||||
"id": ActionTrack,
|
|
||||||
"name": ActionTrack,
|
|
||||||
"description": ActionTrack,
|
|
||||||
"created_at": ActionIgnore, // Never changes, but is implicit and not helpful in a diff.
|
|
||||||
"updated_at": ActionIgnore, // Changes, but is implicit and not helpful in a diff.
|
|
||||||
},
|
|
||||||
&database.Template{}: {
|
&database.Template{}: {
|
||||||
"id": ActionTrack,
|
"id": ActionTrack,
|
||||||
"created_at": ActionIgnore, // Never changes, but is implicit and not helpful in a diff.
|
"created_at": ActionIgnore, // Never changes, but is implicit and not helpful in a diff.
|
||||||
|
|
|
@ -1201,7 +1201,6 @@ export type ResourceType =
|
||||||
| "api_key"
|
| "api_key"
|
||||||
| "git_ssh_key"
|
| "git_ssh_key"
|
||||||
| "group"
|
| "group"
|
||||||
| "organization"
|
|
||||||
| "template"
|
| "template"
|
||||||
| "template_version"
|
| "template_version"
|
||||||
| "user"
|
| "user"
|
||||||
|
@ -1211,7 +1210,6 @@ export const ResourceTypes: ResourceType[] = [
|
||||||
"api_key",
|
"api_key",
|
||||||
"git_ssh_key",
|
"git_ssh_key",
|
||||||
"group",
|
"group",
|
||||||
"organization",
|
|
||||||
"template",
|
"template",
|
||||||
"template_version",
|
"template_version",
|
||||||
"user",
|
"user",
|
||||||
|
|
Loading…
Reference in New Issue