Skip to content
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

perf: Remove with statement to avoid deepcopying data.inventory #252

Merged
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
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