Skip to content

Commit

Permalink
fix invalid external url (argoproj#5396)
Browse files Browse the repository at this point in the history
Signed-off-by: kshamajain99 <kshamajain99@gmail.com>
  • Loading branch information
kshamajain99 authored Feb 9, 2021
1 parent 366b7ff commit 1d1fbf0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions controller/cache/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ func populateIngressInfo(un *unstructured.Unstructured, res *ResourceInfo) {
}] = true
}

if host == nil || host == "" {
continue
}
stringPort := "http"
if tls, ok, err := unstructured.NestedSlice(un.Object, "spec", "tls"); ok && err == nil {
for i := range tls {
Expand Down
34 changes: 33 additions & 1 deletion controller/cache/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func TestGetIngressInfoWithoutTls(t *testing.T) {
}, info.NetworkingInfo)
}

func TestGetIngressInfoNoHost(t *testing.T) {
func TestGetIngressInfoWithHost(t *testing.T) {
ingress := strToUnstructured(`
apiVersion: extensions/v1beta1
kind: Ingress
Expand Down Expand Up @@ -362,6 +362,38 @@ func TestGetIngressInfoNoHost(t *testing.T) {
ExternalURLs: []string{"https://107.178.210.11/"},
}, info.NetworkingInfo)
}
func TestGetIngressInfoNoHost(t *testing.T) {
ingress := strToUnstructured(`
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: helm-guestbook
namespace: default
spec:
rules:
- http:
paths:
- backend:
serviceName: helm-guestbook
servicePort: 443
path: /
tls:
- secretName: my-tls
`)

info := &ResourceInfo{}
populateNodeInfo(ingress, info)

assert.Equal(t, &v1alpha1.ResourceNetworkingInfo{
TargetRefs: []v1alpha1.ResourceRef{{
Namespace: "default",
Group: "",
Kind: kube.ServiceKind,
Name: "helm-guestbook",
}},
}, info.NetworkingInfo)
assert.Equal(t, len(info.NetworkingInfo.ExternalURLs), 0)
}
func TestExternalUrlWithSubPath(t *testing.T) {
ingress := strToUnstructured(`
apiVersion: extensions/v1beta1
Expand Down

0 comments on commit 1d1fbf0

Please sign in to comment.