Skip to content

Commit 00f1581

Browse files
committed
Added fixes for atom routing issues
1 parent e7a320f commit 00f1581

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

internal/controller/middleware.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ func (r *AtomReconciler) mutateStripPrefixMiddleware(atom *pdoknlv3.Atom, middle
3434
Prefixes: []string{atom.Spec.Service.BaseURL.Path + "/"}},
3535
}
3636

37+
for _, ingressRouteUrl := range atom.Spec.IngressRouteURLs {
38+
middleware.Spec.StripPrefix.Prefixes = append(middleware.Spec.StripPrefix.Prefixes, ingressRouteUrl.URL.Path+"/")
39+
}
40+
3741
if err := smoothutil.EnsureSetGVK(r.Client, middleware, middleware); err != nil {
3842
return err
3943
}
@@ -101,7 +105,7 @@ func (r *AtomReconciler) mutateDownloadLinkMiddleware(atom *pdoknlv3.Atom, prefi
101105
middleware.Spec = traefikiov1alpha1.MiddlewareSpec{
102106
ReplacePathRegex: &dynamic.ReplacePathRegex{
103107
Regex: getDownloadLinkRegex(ingressRouteURLs, files),
104-
Replacement: "/" + prefix + "/$1",
108+
Replacement: "/" + prefix + "/$2",
105109
},
106110
}
107111

@@ -112,17 +116,12 @@ func (r *AtomReconciler) mutateDownloadLinkMiddleware(atom *pdoknlv3.Atom, prefi
112116
}
113117

114118
func getDownloadLinkRegex(ingressRouteURLs smoothoperatormodel.IngressRouteURLs, files []string) string {
115-
if len(ingressRouteURLs) == 1 {
116-
return "^" + ingressRouteURLs[0].URL.JoinPath("downloads", "("+strings.Join(files, "|")+")").Path
117-
}
118-
119119
paths := []string{}
120120
for _, ingressRouteURL := range ingressRouteURLs {
121121
paths = append(paths, ingressRouteURL.URL.Path)
122122
}
123123

124124
return "^(" + strings.Join(paths, "|") + ")/downloads/" + "(" + strings.Join(files, "|") + ")"
125-
126125
}
127126

128127
func getDownloadLinkGroups(links []pdoknlv3.DownloadLink) map[string]struct {

0 commit comments

Comments
 (0)