-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
feat: Add external link annotation support. #3487 #4380
feat: Add external link annotation support. #3487 #4380
Conversation
cfe624d
to
1d2b658
Compare
Codecov Report
@@ Coverage Diff @@
## master #4380 +/- ##
==========================================
- Coverage 41.29% 41.16% -0.13%
==========================================
Files 122 122
Lines 16584 16590 +6
==========================================
- Hits 6848 6830 -18
- Misses 8750 8777 +27
+ Partials 986 983 -3
Continue to review full report at Codecov.
|
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.
Thanks for this contribution, I think it's a very handy feature to have!
But I'm unsure whether it's a good idea to create a link from arbitrary input such as the value of an annotation. This might easily lead to XSS and other kinds of attacks. I think we should make sure that the supplied value is indeed a valid URL or at least escape all control characters before rendering it out.
I'm not sure what React makes out of the value passed to rendering the a
tag, but I feel we should put in a little more safety measures here. What do you think?
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.
We already have a field to store external URLs:
ExternalURLs []string `json:"externalURLs,omitempty" protobuf:"bytes,5,opt,name=externalURLs"` |
Here is example where it is populated:
argo-cd/controller/cache/info.go
Line 149 in 9f47a11
res.NetworkingInfo = &v1alpha1.ResourceNetworkingInfo{TargetRefs: targets, Ingress: ingress, ExternalURLs: urls} |
It is possible to keep using it?
@alexmt great catch! That's much better. That list has the added advantage of being able to present a drop-down for multiple urls. With that in mind, I would propose that we actually tweak the feature a bit:
Then tweak the dropdown code just a bit to make it render the links with titles when present. I have a rough version running locally. Here the annotations: And this is how the dropdown looks when you have more than one matching annotation. Or when you put the annotation on an ingress resource that already has data in the If we are good with that, then I'm happy to clean up the code and submit. I would also love advice on how to best sanitize urls like @jannfis suggested. |
I did perform some research, and came to the conclusion that JSX expressions within curly braces So, my request for change is void :) |
@carsonoid I agree with your proposal. Both prefix and optional title sound good to me. |
fda0ca9
to
488afaf
Compare
@@ -247,11 +247,6 @@ function renderResourceNode(props: ApplicationResourceTreeProps, id: string, nod | |||
{node.createdAt} | |||
</Moment> | |||
) : null} | |||
{(node.info || []).map((tag, i) => ( |
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.
It is intentional? I think we still need to render node tags.
a01c51f
to
a045dc9
Compare
Example implementation of argoproj#3487
a045dc9
to
d1acc77
Compare
@alexmt updated as requested. |
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.
LGTM. thank you @carsonoid !
@jannfis , looks like review comments have been addressed. Can you please approve so we can merge it ? |
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.
LGTM
Example implementation of #3487
Using the current
node.Info
list is a bit clunky but requires minimal code change for the feature. I'm open to other ideas, maybe a second info list that is not automatically attached to nodes. That would allow the ui to get bits of metadata that it can use more selectively.It's a simple interface for the end-user. Just add the annotation to any resource:
And then get a link in the interface. This was typically only done for ingress resources or other Argo links. But it can now be done on any resource. Providing a handy way to make Argo-CD the jumping-off point for any application. I think this could be extended even further with a CRD as defined in the issue. But this is a good start and would be enough for most users.
Checklist: