-
-
Notifications
You must be signed in to change notification settings - Fork 180
fix: resource references with property resolving #2153
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
base: main
Are you sure you want to change the base?
Conversation
|
might make a PropertyResourceResolver(ResourceResolver) to separate concerns. |
|
Things to check before approving: that we don't cache based on originalresourceref keys. |
|
That's too easy, yes. There's no guarantee, nor reason, to assume that the So given the fact that you do nothing more than replace properties on the input I don't see why this can't be done before that input gets passed to the resolver. It just seems to me we're mixing responsibilities here. Edit: Personally I'd just look to all the places where we call the resolver and see if we can't put the property replacement there. If that's somehow too much work I'd suggest a "fake" resolver which does nothing more than replace the properties before passing on the work to a wrapper resolver. ANd then make sure that we always return that one as the "top" resolver. |
de8e99a to
c1f0a3b
Compare
that made me go look and i located resolveChecked which is the "root" of all the CombinedResource resolvers I could find. I updated it to do the property replacement - and since its in the project builder it can get and use the buildContext which has user specifcied propertiers. So far thats nice; but I see two issues:
...writing this out I think i'm going to update this to take a parameter where the property replacement will be enabled and only do that for the "root" build/alias call. |
c1f0a3b to
fca251c
Compare
|
note: just realizing prperty replacement as is implemented now also support env. for environment variable lookup so definitly dont want it available everywhere |
fca251c to
786c511
Compare
|
well heck - we already support property replacement in all Tags (incl. files) I just realize. look for "replaceProperties" we avoid/reduce the impact on //FILES by files not allowing absolute paths only relative ones. |
|
so yeah "//FILES myfile=../../../.bash_profile" works ...but so does Path.of("../../../.bash_profile") in a main method of any java code ...so yeah; not any worse or better risk than what running anything from online apps does. Hence adding verification/checksum checks is the more important part. |
c486a73 to
aa419ff
Compare
|
@quintesse assuming tests passes I think this is good to go. |
ec991d1 to
ead45d2
Compare
ead45d2 to
8991a1b
Compare
03000c8 to
5ae89f5
Compare
| * @param resource | ||
| * @return | ||
| */ | ||
| private ResourceRef resolveChecked(ResourceResolver resolver, String orginal_resource, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already merged, but original_resource? Wtf? Did you use AI to generate this? 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what was already there afaik. Unless you identify as AI it was human :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't gaslight me, this code is new, the diff shows you just added it :-)
I would never ever write a (Java) variable name with an underscore, the very idea gives me shivers 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only answer must be that I'm an AI then :)
| * i.e. jbang run someref${os.detected.os}.jar is ok but //FILES with | ||
| * ${user.home} is definitely not. | ||
| * | ||
| * @param resolver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either put proper docs or remove the @params :-)
| : orginal_resource; | ||
|
|
||
| if (!resource.equals(orginal_resource)) { | ||
| Util.verboseMsg("Resolving resource ref: " + orginal_resource + " -> " + resource); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging this is good, but I think the wording could be improved. In this case if there are no properties to be replaced you won't get a "resolving ..." message, which is wrong because we definitely are resolving. So I'd say that we'd either have to always log something or change the wording to something like "Applying properties" instead of "Resolving".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but something gets logged everytime - its just only when applying properties we put the "-> "
I did that to avoid it to say 99% of the time "Resolving resource ref: abc -> abc"
but if you can think of a better one do open pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that's why I said to simply change the text. Because it's not resolving, it's "applying properties to resource ref" or something like that. Just to avoid any confusion that that line suggests that resolving has been done/performed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But resolve xyz is what we wrote before applying any properties. So are you saying the old one was wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm just misunderstanding things. Doesn't matter. Not important,
minimal draft fix for #2152
this feels almost too easy...but would this work ?