This repository was archived by the owner on Dec 12, 2025. It is now read-only.
resolver: Refactor visitor pattern#95
Merged
qinqon merged 2 commits intonmstate-archive:mainfrom Mar 8, 2022
Merged
Conversation
|
✔️ Deploy Preview for nmpolicy canceled. 🔨 Explore the source changes: 267574c 🔍 Inspect the deploy log: https://app.netlify.com/sites/nmpolicy/deploys/62135846722fb00008f0e9e6 |
518d40b to
267574c
Compare
AlonaKaplan
reviewed
Feb 24, 2022
03d494a to
514235e
Compare
AlonaKaplan
reviewed
Mar 3, 2022
514235e to
f621def
Compare
The code that resolves resolve and filter is mixed up at path.go so for example the replace does not need the shouldFilter feature but still the code that runs it has to understand it. This change contains the following: - Encapsulate the path advancing into the function nextStep and hasMoreSteps slice when there is no index in the path - Move the code from filter/replace to their correct place at filter.go and replace.go, implementing previous callbacks. - Replace the "Fn" visit functions with a stateVisitor interface Signed-off-by: Quique Llorente <ellorent@redhat.com>
759a246 to
b9e3f0d
Compare
AlonaKaplan
reviewed
Mar 8, 2022
nmpolicy/internal/resolver/walk.go
Outdated
| } | ||
|
|
||
| func (w walkOpVisitor) visitSlice(p path, sliceToVisit []interface{}) (interface{}, error) { | ||
| if p.currentStep.Number == nil { |
Collaborator
There was a problem hiding this comment.
I would move this check to accessSliceWithCurrentStep.
Walkind a path is implemented different from the other operators. This change reuse the same mechanism. Signed-off-by: Quique Llorente <ellorent@redhat.com>
b9e3f0d to
8b920b6
Compare
AlonaKaplan
approved these changes
Mar 8, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The code that resolves resolve and filter is mixed up at
path.goso for example thereplacedoes not need theshouldFilterfeature but still the code that runs it has to understand it.This PR do the following:
nextStepandhasMoreStepsstateVisitorinterfacepathVisitorCloses #83