Skip to content

Commit

Permalink
perf: Remove with statement to avoid deepcopying data.inventory (#252)
Browse files Browse the repository at this point in the history
Signed-off-by: Max Smythe <smythe@google.com>

Signed-off-by: Max Smythe <smythe@google.com>
  • Loading branch information
maxsmythe authored Oct 6, 2022
1 parent 1ed2724 commit a3d297b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion constraint/pkg/client/drivers/local/driver_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ func TestDriver_RemoveData_StorageErrors(t *testing.T) {
name: "commit error",
storage: &commitErrorStorage{
fakeStorage: fakeStorage{values: map[string]interface{}{
"/external/foo": "bar",
"/inventory/foo": "bar",
}},
},
wantErr: clienterrors.ErrTransaction,
Expand Down
10 changes: 1 addition & 9 deletions constraint/pkg/client/drivers/local/rego.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ violation[response] {
}
# Run the Template with Constraint.
inventory[inv]
data.template.violation[r] with input as inp with data.inventory as inv
data.template.violation[r] with input as inp
# Construct the response, defaulting "details" to empty object if it is not
# specified.
Expand All @@ -45,13 +44,6 @@ violation[response] {
"msg": r.msg,
}
}
inventory[inv] {
inv = data.external
}
inventory[{}] {
not data.external
}
`
)

Expand Down
2 changes: 1 addition & 1 deletion constraint/pkg/client/drivers/local/storages.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (d *storages) getStorage(ctx context.Context, target string) (storage.Store
}

func inventoryPath(path []string) storage.Path {
return append([]string{"external"}, path...)
return append([]string{"inventory"}, path...)
}

func addData(ctx context.Context, store storage.Store, path storage.Path, data interface{}) error {
Expand Down

0 comments on commit a3d297b

Please sign in to comment.