Skip to content

chore: removing unaudited resources #5885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"afero",
"apps",
"ASKPASS",
"autostop",
"awsidentity",
"bodyclose",
"buildinfo",
Expand Down
6 changes: 1 addition & 5 deletions coderd/apidoc/docs.go

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

6 changes: 1 addition & 5 deletions coderd/apidoc/swagger.json

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

2 changes: 0 additions & 2 deletions coderd/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,6 @@ func auditSearchQuery(query string) (database.GetAuditLogsOffsetParams, []coders

func resourceTypeFromString(resourceTypeString string) string {
switch codersdk.ResourceType(resourceTypeString) {
case codersdk.ResourceTypeOrganization:
return resourceTypeString
case codersdk.ResourceTypeTemplate:
return resourceTypeString
case codersdk.ResourceTypeTemplateVersion:
Expand Down
2 changes: 0 additions & 2 deletions coderd/audit/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
// AuditableResources, then add it to this interface.
type Auditable interface {
database.APIKey |
database.Organization |
database.OrganizationMember |
database.Template |
database.TemplateVersion |
database.User |
Expand Down
6 changes: 0 additions & 6 deletions coderd/audit/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ type BuildAuditParams[T Auditable] struct {

func ResourceTarget[T Auditable](tgt T) string {
switch typed := any(tgt).(type) {
case database.Organization:
return typed.Name
case database.Template:
return typed.Name
case database.TemplateVersion:
Expand All @@ -73,8 +71,6 @@ func ResourceTarget[T Auditable](tgt T) string {

func ResourceID[T Auditable](tgt T) uuid.UUID {
switch typed := any(tgt).(type) {
case database.Organization:
return typed.ID
case database.Template:
return typed.ID
case database.TemplateVersion:
Expand All @@ -96,8 +92,6 @@ func ResourceID[T Auditable](tgt T) uuid.UUID {

func ResourceType[T Auditable](tgt T) database.ResourceType {
switch any(tgt).(type) {
case database.Organization:
return database.ResourceTypeOrganization
case database.Template:
return database.ResourceTypeTemplate
case database.TemplateVersion:
Expand Down
5 changes: 1 addition & 4 deletions codersdk/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
type ResourceType string

const (
ResourceTypeOrganization ResourceType = "organization"
ResourceTypeTemplate ResourceType = "template"
ResourceTypeTemplateVersion ResourceType = "template_version"
ResourceTypeUser ResourceType = "user"
Expand All @@ -27,8 +26,6 @@ const (

func (r ResourceType) FriendlyString() string {
switch r {
case ResourceTypeOrganization:
return "organization"
case ResourceTypeTemplate:
return "template"
case ResourceTypeTemplateVersion:
Expand Down Expand Up @@ -122,7 +119,7 @@ type AuditLogResponse struct {

type CreateTestAuditLogRequest struct {
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"`
Time time.Time `json:"time,omitempty" format:"date-time"`
BuildReason BuildReason `json:"build_reason,omitempty" enums:"autostart,autostop,initiator"`
Expand Down
4 changes: 2 additions & 2 deletions docs/api/audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ curl -X GET http://coder-server:8080/api/v2/audit?q=string \
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"resource_link": "string",
"resource_target": "string",
"resource_type": "organization",
"resource_type": "template",
"status_code": 0,
"time": "2019-08-24T14:15:22Z",
"user": {
Expand Down Expand Up @@ -108,7 +108,7 @@ curl -X POST http://coder-server:8080/api/v2/audit/testgenerate \
"action": "create",
"build_reason": "autostart",
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"resource_type": "organization",
"resource_type": "template",
"time": "2019-08-24T14:15:22Z"
}
```
Expand Down
13 changes: 5 additions & 8 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"resource_link": "string",
"resource_target": "string",
"resource_type": "organization",
"resource_type": "template",
"status_code": 0,
"time": "2019-08-24T14:15:22Z",
"user": {
Expand Down Expand Up @@ -406,7 +406,7 @@
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"resource_link": "string",
"resource_target": "string",
"resource_type": "organization",
"resource_type": "template",
"status_code": 0,
"time": "2019-08-24T14:15:22Z",
"user": {
Expand Down Expand Up @@ -785,7 +785,7 @@ CreateParameterRequest is a structure used to create a new parameter value for a
"action": "create",
"build_reason": "autostart",
"resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
"resource_type": "organization",
"resource_type": "template",
"time": "2019-08-24T14:15:22Z"
}
```
Expand All @@ -812,15 +812,13 @@ CreateParameterRequest is a structure used to create a new parameter value for a
| `build_reason` | `autostart` |
| `build_reason` | `autostop` |
| `build_reason` | `initiator` |
| `resource_type` | `organization` |
| `resource_type` | `template` |
| `resource_type` | `template_version` |
| `resource_type` | `user` |
| `resource_type` | `workspace` |
| `resource_type` | `workspace_build` |
| `resource_type` | `git_ssh_key` |
| `resource_type` | `api_key` |
| `resource_type` | `group` |
| `resource_type` | `auditable_group` |

## codersdk.CreateTokenRequest

Expand Down Expand Up @@ -3739,7 +3737,7 @@ Parameter represents a set value for the scope.
## codersdk.ResourceType

```json
"organization"
"template"
```

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

| Value |
| ------------------ |
| `organization` |
| `template` |
| `template_version` |
| `user` |
Expand Down
38 changes: 0 additions & 38 deletions enterprise/audit/diff_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
{
name: "Create",
Expand Down
14 changes: 0 additions & 14 deletions enterprise/audit/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"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{}: {
"id": ActionTrack,
"created_at": ActionIgnore, // Never changes, but is implicit and not helpful in a diff.
Expand Down
2 changes: 0 additions & 2 deletions site/src/api/typesGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,6 @@ export type ResourceType =
| "api_key"
| "git_ssh_key"
| "group"
| "organization"
| "template"
| "template_version"
| "user"
Expand All @@ -1211,7 +1210,6 @@ export const ResourceTypes: ResourceType[] = [
"api_key",
"git_ssh_key",
"group",
"organization",
"template",
"template_version",
"user",
Expand Down