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

[client.Client] Record matchers for constraints #176

Closed
willbeason opened this issue Dec 16, 2021 · 1 comment
Closed

[client.Client] Record matchers for constraints #176

willbeason opened this issue Dec 16, 2021 · 1 comment
Assignees

Comments

@willbeason
Copy link
Member

Prerequisites: #175 and #170

Now that we've copied over matching logic into frameworks, and callers explicitly call "AddConstraint" and "RemoveConstraint", we can start doing bookkeeping in local.Driver which we need to have in order to move matching from Rego to Go. For this issue, we're just keeping a copy of the matchers for each Constraint.

Add a field to local.Driver called matchers. You can probably make this a map similar to the following:

type matcherKey struct {
  Kind, Name string
}
type Driver struct {
  ...
  matchers map[matcherKey]*Matcher
}

All that needs to happen is when Constraints are added to the Driver, we unmarshal the Matcher field into the Matcher type we copied over previously. Use the bytes := json.Marshal(unstructured) and json.Unmarshal(bytes, matcher) pattern used elsewhere to conver to the Match type.

We can't actually use these matchers yet since we haven't sharded the compilation environment - but we need these ready for when we do.

@willbeason willbeason added this to the Rego Environment Sharding milestone Dec 16, 2021
@willbeason willbeason changed the title [local.Driver] Record matchers for constraints [client.Client] Record matchers for constraints Feb 1, 2022
@willbeason willbeason self-assigned this Feb 1, 2022
@willbeason
Copy link
Member Author

Decided to do this for client.Client since driver can be target-agnostic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant