Skip to content

Commit 3d58e69

Browse files
authored
chore: removing unaudited resources (#5885)
* chore: removing unaudited resources * cleaned up tests * CI errors
1 parent e2bea2d commit 3d58e69

File tree

12 files changed

+11
-88
lines changed

12 files changed

+11
-88
lines changed

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"afero",
44
"apps",
55
"ASKPASS",
6+
"autostop",
67
"awsidentity",
78
"bodyclose",
89
"buildinfo",

coderd/apidoc/docs.go

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/audit.go

-2
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,6 @@ func auditSearchQuery(query string) (database.GetAuditLogsOffsetParams, []coders
452452

453453
func resourceTypeFromString(resourceTypeString string) string {
454454
switch codersdk.ResourceType(resourceTypeString) {
455-
case codersdk.ResourceTypeOrganization:
456-
return resourceTypeString
457455
case codersdk.ResourceTypeTemplate:
458456
return resourceTypeString
459457
case codersdk.ResourceTypeTemplateVersion:

coderd/audit/diff.go

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99
// AuditableResources, then add it to this interface.
1010
type Auditable interface {
1111
database.APIKey |
12-
database.Organization |
13-
database.OrganizationMember |
1412
database.Template |
1513
database.TemplateVersion |
1614
database.User |

coderd/audit/request.go

-6
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ type BuildAuditParams[T Auditable] struct {
4949

5050
func ResourceTarget[T Auditable](tgt T) string {
5151
switch typed := any(tgt).(type) {
52-
case database.Organization:
53-
return typed.Name
5452
case database.Template:
5553
return typed.Name
5654
case database.TemplateVersion:
@@ -73,8 +71,6 @@ func ResourceTarget[T Auditable](tgt T) string {
7371

7472
func ResourceID[T Auditable](tgt T) uuid.UUID {
7573
switch typed := any(tgt).(type) {
76-
case database.Organization:
77-
return typed.ID
7874
case database.Template:
7975
return typed.ID
8076
case database.TemplateVersion:
@@ -96,8 +92,6 @@ func ResourceID[T Auditable](tgt T) uuid.UUID {
9692

9793
func ResourceType[T Auditable](tgt T) database.ResourceType {
9894
switch any(tgt).(type) {
99-
case database.Organization:
100-
return database.ResourceTypeOrganization
10195
case database.Template:
10296
return database.ResourceTypeTemplate
10397
case database.TemplateVersion:

codersdk/audit.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
type ResourceType string
1515

1616
const (
17-
ResourceTypeOrganization ResourceType = "organization"
1817
ResourceTypeTemplate ResourceType = "template"
1918
ResourceTypeTemplateVersion ResourceType = "template_version"
2019
ResourceTypeUser ResourceType = "user"
@@ -27,8 +26,6 @@ const (
2726

2827
func (r ResourceType) FriendlyString() string {
2928
switch r {
30-
case ResourceTypeOrganization:
31-
return "organization"
3229
case ResourceTypeTemplate:
3330
return "template"
3431
case ResourceTypeTemplateVersion:
@@ -122,7 +119,7 @@ type AuditLogResponse struct {
122119

123120
type CreateTestAuditLogRequest struct {
124121
Action AuditAction `json:"action,omitempty" enums:"create,write,delete,start,stop"`
125-
ResourceType ResourceType `json:"resource_type,omitempty" enums:"organization,template,template_version,user,workspace,workspace_build,git_ssh_key,api_key,group"`
122+
ResourceType ResourceType `json:"resource_type,omitempty" enums:"template,template_version,user,workspace,workspace_build,git_ssh_key,auditable_group"`
126123
ResourceID uuid.UUID `json:"resource_id,omitempty" format:"uuid"`
127124
Time time.Time `json:"time,omitempty" format:"date-time"`
128125
BuildReason BuildReason `json:"build_reason,omitempty" enums:"autostart,autostop,initiator"`

docs/api/audit.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ curl -X GET http://coder-server:8080/api/v2/audit?q=string \
5454
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
5555
"resource_link": "string",
5656
"resource_target": "string",
57-
"resource_type": "organization",
57+
"resource_type": "template",
5858
"status_code": 0,
5959
"time": "2019-08-24T14:15:22Z",
6060
"user": {
@@ -108,7 +108,7 @@ curl -X POST http://coder-server:8080/api/v2/audit/testgenerate \
108108
"action": "create",
109109
"build_reason": "autostart",
110110
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
111-
"resource_type": "organization",
111+
"resource_type": "template",
112112
"time": "2019-08-24T14:15:22Z"
113113
}
114114
```

docs/api/schemas.md

+5-8
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@
330330
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
331331
"resource_link": "string",
332332
"resource_target": "string",
333-
"resource_type": "organization",
333+
"resource_type": "template",
334334
"status_code": 0,
335335
"time": "2019-08-24T14:15:22Z",
336336
"user": {
@@ -406,7 +406,7 @@
406406
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
407407
"resource_link": "string",
408408
"resource_target": "string",
409-
"resource_type": "organization",
409+
"resource_type": "template",
410410
"status_code": 0,
411411
"time": "2019-08-24T14:15:22Z",
412412
"user": {
@@ -785,7 +785,7 @@ CreateParameterRequest is a structure used to create a new parameter value for a
785785
"action": "create",
786786
"build_reason": "autostart",
787787
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
788-
"resource_type": "organization",
788+
"resource_type": "template",
789789
"time": "2019-08-24T14:15:22Z"
790790
}
791791
```
@@ -812,15 +812,13 @@ CreateParameterRequest is a structure used to create a new parameter value for a
812812
| `build_reason` | `autostart` |
813813
| `build_reason` | `autostop` |
814814
| `build_reason` | `initiator` |
815-
| `resource_type` | `organization` |
816815
| `resource_type` | `template` |
817816
| `resource_type` | `template_version` |
818817
| `resource_type` | `user` |
819818
| `resource_type` | `workspace` |
820819
| `resource_type` | `workspace_build` |
821820
| `resource_type` | `git_ssh_key` |
822-
| `resource_type` | `api_key` |
823-
| `resource_type` | `group` |
821+
| `resource_type` | `auditable_group` |
824822

825823
## codersdk.CreateTokenRequest
826824

@@ -3739,7 +3737,7 @@ Parameter represents a set value for the scope.
37393737
## codersdk.ResourceType
37403738

37413739
```json
3742-
"organization"
3740+
"template"
37433741
```
37443742

37453743
### Properties
@@ -3748,7 +3746,6 @@ Parameter represents a set value for the scope.
37483746

37493747
| Value |
37503748
| ------------------ |
3751-
| `organization` |
37523749
| `template` |
37533750
| `template_version` |
37543751
| `user` |

enterprise/audit/diff_internal_test.go

-38
Original file line numberDiff line numberDiff line change
@@ -275,44 +275,6 @@ func Test_diff(t *testing.T) {
275275
},
276276
})
277277

278-
runDiffTests(t, []diffTest{
279-
{
280-
name: "Create",
281-
left: audit.Empty[database.OrganizationMember](),
282-
right: database.OrganizationMember{
283-
UserID: uuid.UUID{1},
284-
OrganizationID: uuid.UUID{2},
285-
CreatedAt: time.Now(),
286-
UpdatedAt: time.Now(),
287-
Roles: []string{"auditor"},
288-
},
289-
exp: audit.Map{
290-
"user_id": audit.OldNew{Old: "", New: uuid.UUID{1}.String()},
291-
"organization_id": audit.OldNew{Old: "", New: uuid.UUID{2}.String()},
292-
"roles": audit.OldNew{Old: ([]string)(nil), New: []string{"auditor"}},
293-
},
294-
},
295-
})
296-
297-
runDiffTests(t, []diffTest{
298-
{
299-
name: "Create",
300-
left: audit.Empty[database.Organization](),
301-
right: database.Organization{
302-
ID: uuid.UUID{1},
303-
Name: "rust developers",
304-
Description: "an organization for rust developers",
305-
CreatedAt: time.Now(),
306-
UpdatedAt: time.Now(),
307-
},
308-
exp: audit.Map{
309-
"id": audit.OldNew{Old: "", New: uuid.UUID{1}.String()},
310-
"name": audit.OldNew{Old: "", New: "rust developers"},
311-
"description": audit.OldNew{Old: "", New: "an organization for rust developers"},
312-
},
313-
},
314-
})
315-
316278
runDiffTests(t, []diffTest{
317279
{
318280
name: "Create",

enterprise/audit/table.go

-14
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,6 @@ var AuditableResources = auditMap(map[any]map[string]Action{
3333
"private_key": ActionSecret, // We don't want to expose private keys in diffs.
3434
"public_key": ActionTrack, // Public keys are ok to expose in a diff.
3535
},
36-
&database.OrganizationMember{}: {
37-
"user_id": ActionTrack,
38-
"organization_id": ActionTrack,
39-
"created_at": ActionIgnore, // Never changes, but is implicit and not helpful in a diff.
40-
"updated_at": ActionIgnore, // Changes, but is implicit and not helpful in a diff.
41-
"roles": ActionTrack,
42-
},
43-
&database.Organization{}: {
44-
"id": ActionTrack,
45-
"name": ActionTrack,
46-
"description": ActionTrack,
47-
"created_at": ActionIgnore, // Never changes, but is implicit and not helpful in a diff.
48-
"updated_at": ActionIgnore, // Changes, but is implicit and not helpful in a diff.
49-
},
5036
&database.Template{}: {
5137
"id": ActionTrack,
5238
"created_at": ActionIgnore, // Never changes, but is implicit and not helpful in a diff.

site/src/api/typesGenerated.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,6 @@ export type ResourceType =
12011201
| "api_key"
12021202
| "git_ssh_key"
12031203
| "group"
1204-
| "organization"
12051204
| "template"
12061205
| "template_version"
12071206
| "user"
@@ -1211,7 +1210,6 @@ export const ResourceTypes: ResourceType[] = [
12111210
"api_key",
12121211
"git_ssh_key",
12131212
"group",
1214-
"organization",
12151213
"template",
12161214
"template_version",
12171215
"user",

0 commit comments

Comments
 (0)