Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9402013

Browse files
authored
chore: remove org_id from audit diffs (coder#4668)
* chore: remove org_id from audit diffs * PR feedback * fix tests
1 parent 47cb9ab commit 9402013

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

enterprise/audit/diff_internal_test.go

+7-10
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ func Test_diff(t *testing.T) {
256256
},
257257
exp: audit.Map{
258258
"id": audit.OldNew{Old: "", New: uuid.UUID{1}.String()},
259-
"organization_id": audit.OldNew{Old: "", New: uuid.UUID{2}.String()},
260259
"name": audit.OldNew{Old: "", New: "rust"},
261260
"provisioner": audit.OldNew{Old: database.ProvisionerType(""), New: database.ProvisionerTypeTerraform},
262261
"active_version_id": audit.OldNew{Old: "", New: uuid.UUID{3}.String()},
@@ -281,11 +280,10 @@ func Test_diff(t *testing.T) {
281280
CreatedBy: uuid.NullUUID{UUID: uuid.UUID{4}, Valid: true},
282281
},
283282
exp: audit.Map{
284-
"id": audit.OldNew{Old: "", New: uuid.UUID{1}.String()},
285-
"template_id": audit.OldNew{Old: "", New: uuid.UUID{2}.String()},
286-
"organization_id": audit.OldNew{Old: "", New: uuid.UUID{3}.String()},
287-
"created_by": audit.OldNew{Old: "", New: uuid.UUID{4}.String()},
288-
"name": audit.OldNew{Old: "", New: "rust"},
283+
"id": audit.OldNew{Old: "", New: uuid.UUID{1}.String()},
284+
"template_id": audit.OldNew{Old: "", New: uuid.UUID{2}.String()},
285+
"created_by": audit.OldNew{Old: "", New: uuid.UUID{4}.String()},
286+
"name": audit.OldNew{Old: "", New: "rust"},
289287
},
290288
},
291289
{
@@ -301,10 +299,9 @@ func Test_diff(t *testing.T) {
301299
CreatedBy: uuid.NullUUID{UUID: uuid.UUID{4}, Valid: true},
302300
},
303301
exp: audit.Map{
304-
"id": audit.OldNew{Old: "", New: uuid.UUID{1}.String()},
305-
"organization_id": audit.OldNew{Old: "", New: uuid.UUID{3}.String()},
306-
"created_by": audit.OldNew{Old: "null", New: uuid.UUID{4}.String()},
307-
"name": audit.OldNew{Old: "", New: "rust"},
302+
"id": audit.OldNew{Old: "", New: uuid.UUID{1}.String()},
303+
"created_by": audit.OldNew{Old: "null", New: uuid.UUID{4}.String()},
304+
"name": audit.OldNew{Old: "", New: "rust"},
308305
},
309306
},
310307
})

enterprise/audit/table.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var AuditableResources = auditMap(map[any]map[string]Action{
5151
"id": ActionTrack,
5252
"created_at": ActionIgnore, // Never changes, but is implicit and not helpful in a diff.
5353
"updated_at": ActionIgnore, // Changes, but is implicit and not helpful in a diff.
54-
"organization_id": ActionTrack,
54+
"organization_id": ActionIgnore, /// Never changes.
5555
"deleted": ActionIgnore, // Changes, but is implicit when a delete event is fired.
5656
"name": ActionTrack,
5757
"provisioner": ActionTrack,
@@ -68,7 +68,7 @@ var AuditableResources = auditMap(map[any]map[string]Action{
6868
&database.TemplateVersion{}: {
6969
"id": ActionTrack,
7070
"template_id": ActionTrack,
71-
"organization_id": ActionTrack,
71+
"organization_id": ActionIgnore, // Never changes.
7272
"created_at": ActionIgnore, // Never changes, but is implicit and not helpful in a diff.
7373
"updated_at": ActionIgnore, // Changes, but is implicit and not helpful in a diff.
7474
"name": ActionTrack,
@@ -95,7 +95,7 @@ var AuditableResources = auditMap(map[any]map[string]Action{
9595
"created_at": ActionIgnore, // Never changes.
9696
"updated_at": ActionIgnore, // Changes, but is implicit and not helpful in a diff.
9797
"owner_id": ActionTrack,
98-
"organization_id": ActionTrack,
98+
"organization_id": ActionIgnore, // Never changes.
9999
"template_id": ActionTrack,
100100
"deleted": ActionIgnore, // Changes, but is implicit when a delete event is fired.
101101
"name": ActionTrack,
@@ -106,7 +106,7 @@ var AuditableResources = auditMap(map[any]map[string]Action{
106106
&database.Group{}: {
107107
"id": ActionTrack,
108108
"name": ActionTrack,
109-
"organization_id": ActionTrack,
109+
"organization_id": ActionIgnore, // Never changes.
110110
"avatar_url": ActionTrack,
111111
},
112112
})

0 commit comments

Comments
 (0)