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

✨ Add XMLPublicID condition to builtin provider #306

Merged
merged 8 commits into from
Dec 12, 2023

Conversation

aufi
Copy link
Member

@aufi aufi commented Aug 25, 2023

Adding XML-like public-id condition supporting regular expression evaluation on the public-id attribute.

Related to konveyor/windup-shim#87

Fixes: #221

Analyzer PR: 306
Windup-shim PR: 87

Adding XML-like public-id condition supporting regular expression
evaluation on the public-id attribute.

Related to konveyor/windup-shim#87
Related to konveyor#221

Signed-off-by: Marek Aufart <maufart@redhat.com>
@aufi aufi changed the title Add XMLPublicid condition to builtin provider ✨ Add XMLPublicid condition to builtin provider Aug 25, 2023
@shawn-hurley
Copy link
Contributor

@aufi is this ready for review?

@aufi aufi marked this pull request as ready for review September 1, 2023 11:30
Copy link
Contributor

@shawn-hurley shawn-hurley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should share the code for XML set up in a function, While you are there you can fix a bug and close the file for the original xml implementation.

provider/internal/builtin/provider.go Outdated Show resolved Hide resolved
provider/internal/builtin/provider.go Outdated Show resolved Hide resolved
provider/internal/builtin/service_client.go Outdated Show resolved Hide resolved
Signed-off-by: Marek Aufart <maufart@redhat.com>
Signed-off-by: Marek Aufart <maufart@redhat.com>
@aufi aufi changed the title ✨ Add XMLPublicid condition to builtin provider ✨ Add XMLPublicID condition to builtin provider Nov 22, 2023
Signed-off-by: Marek Aufart <aufi.cz@gmail.com>
@aufi
Copy link
Member Author

aufi commented Nov 22, 2023

Thanks for review&feedback @shawn-hurley, updated.

@aufi
Copy link
Member Author

aufi commented Nov 22, 2023

The CI failure comes from missing update/merge of konveyor/go-konveyor-tests#65. This PR will be merged when gets green, but I'd be grateful for review.

@shawn-hurley
Copy link
Contributor

@aufi the code looks good

Could you add a test in the demo to show it working so we don't break it in the future?

Signed-off-by: Marek Aufart <maufart@redhat.com>
Signed-off-by: Marek Aufart <maufart@redhat.com>
@aufi
Copy link
Member Author

aufi commented Nov 30, 2023

@shawn-hurley @jmle Added demo rule for the xmlPublicID condition. Ready for review.

Copy link
Contributor

@shawn-hurley shawn-hurley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am good after the rebase but +1 from me!

@@ -350,6 +369,47 @@ func findFilesMatchingPattern(root, pattern string) ([]string, error) {
return matches, err
}

func findXMLFiles(baseLocation string, filePaths []string) (xmlFiles []string, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @aufi, in the future, unless this is used by other functions, I don't know if this extra layer for functions is necessary. It doesn't hurt, but does add a layer to reading what the main function does.

I don't think we need to change or anything, but I'm just giving my perspective and wondering what your thoughts are. I think, for now, it is perfectly fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, your comment makes a good sense to me. The reason for this function was to share the function for XML&XML PublicID conditions (requested in one of previous reviews).

return
}

func queryXMLFile(filePath string, query *xpath.Expr) (nodes []*xmlquery.Node, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another one of the small things is that we don't have to change for this PR, but we usually don't use naked returns for a function that has some complexity.

In this case, because of the err != nil w/ checking the err on line 390, I think all the shadowing will add complexity and make it slightly harder to reason about. I don't think we have to change this, but I want to point it out.

I love to hear thoughts if you disagree just to hear a different perspective; for now, just leave it as is, and we can always address in a follow up :)

Copy link
Member Author

@aufi aufi Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated returns to use values directly (I didn't realize it is not used in analyzer in that way).

I'd plan to address mentioned issues when removing TODOs from golang XML parsing from the code.

aufi and others added 2 commits December 5, 2023 11:40
Signed-off-by: Marek Aufart <aufi.cz@gmail.com>
Signed-off-by: Marek Aufart <maufart@redhat.com>
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

Successfully merging this pull request may close these issues.

Handle public-id field in xmlfile conditions
2 participants