-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Support for User Links add through annotations for Pods and Services #2249
Changes from 1 commit
8a3b5db
473eebf
8d60655
90a0205
b9634ec
55a68d8
ddf5df7
0c9a17f
6113ce1
e95ad73
90281db
680abb0
28898bf
a9fa513
e2bca8e
14918be
5a2aae4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,10 +60,7 @@ func GetUserLinks(client k8sClient.Interface, namespace, name, resource, host st | |
func getServiceLinks(client k8sClient.Interface, namespace, name, host string) ([]UserLink, error) { | ||
userLinks := []UserLink{} | ||
service, err := client.CoreV1().Services(namespace).Get(name, metaV1.GetOptions{}) | ||
if err != nil { | ||
return userLinks, err | ||
} | ||
if len(service.Annotations[annotationObj]) == 0 { | ||
if err != nil || len(service.Annotations[annotationObj]) == 0 { | ||
return userLinks, err | ||
} | ||
m := map[string]string{} | ||
|
@@ -90,7 +87,7 @@ func getServiceLinks(client k8sClient.Interface, namespace, name, host string) ( | |
userLink.Valid = true | ||
} else if strings.Contains(val, apiserverProxyURL) { //dealing with relative path | ||
//strip the url of apiserver-proxy-url | ||
userLink.Link = host + "/api/" + "v1" + "/namespaces/" + service.ObjectMeta.Namespace + | ||
userLink.Link = host + "/api/v1/namespaces/" + service.ObjectMeta.Namespace + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in my understanding the host is replaced later on in the frontend. So could we use a static placeholder, like localhost? |
||
"/services/" + service.ObjectMeta.Name + "/proxy" + strings.TrimLeft(val, apiserverProxyURL) | ||
userLink.Valid = true | ||
} else { | ||
|
@@ -106,10 +103,7 @@ func getServiceLinks(client k8sClient.Interface, namespace, name, host string) ( | |
func getPodLinks(client k8sClient.Interface, namespace, name, host string) ([]UserLink, error) { | ||
userLinks := []UserLink{} | ||
pod, err := client.CoreV1().Pods(namespace).Get(name, metaV1.GetOptions{}) | ||
if err != nil { | ||
return userLinks, err | ||
} | ||
if len(pod.Annotations[annotationObj]) == 0 { | ||
if err != nil || len(pod.Annotations[annotationObj]) == 0 { | ||
return userLinks, err | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Merge both ifs to |
||
|
||
|
@@ -125,7 +119,7 @@ func getPodLinks(client k8sClient.Interface, namespace, name, host string) ([]Us | |
//use api server proxy url | ||
if strings.Contains(val, apiserverProxyURL) { | ||
//strip the url of apiserver-proxy-url | ||
userLink.Link = host + "/api/" + "v1" + "/namespaces/" + pod.ObjectMeta.Namespace + | ||
userLink.Link = host + "/api/v1/namespaces/" + pod.ObjectMeta.Namespace + | ||
"/pods/" + pod.ObjectMeta.Name + "/proxy" + strings.TrimLeft(val, apiserverProxyURL) | ||
userLink.Valid = true | ||
} else if strings.Contains(val, "http://") { //dealing with absolute path | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,5 @@ | |
height: inherit; | ||
margin: 0; | ||
vertical-align: middle; | ||
padding: 5px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
} |
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.
Merge both ifs to
err != nil || len(pod.Annotations[annotationObj]) == 0
.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.
getServiceLinks
andgetPodLinks
have a lot in common. Perhaps you could avoid such code duplication?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.
I tried but they differ enough so that it makes it not worth refactoring further.