Skip to content

Commit 93f0006

Browse files
committed
Add support for multiple APIPaths in caddygateway
1 parent 6226cda commit 93f0006

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

controllers/cloud.redhat.com/providers/web/resources_caddygateway.go

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,30 @@ func makeWebGatewayConfigMap(p *providers.Provider) (string, error) {
280280
continue
281281
}
282282

283-
apiPath := innerDeployment.WebServices.Public.APIPath
284-
285-
if apiPath == "" {
286-
apiPath = innerDeployment.Name
287-
}
288-
289283
name := innerApp.GetDeploymentNamespacedName(&innerDeployment).Name
290284
hostname := fmt.Sprintf("%s.%s.svc", name, innerApp.Namespace)
291285

292-
upstreamList = append(upstreamList, ProxyRoute{
293-
Upstream: fmt.Sprintf("%s:%d", hostname, 8000),
294-
Path: fmt.Sprintf("/api/%s/*", apiPath),
295-
})
286+
if innerDeployment.WebServices.Public.APIPaths != nil {
287+
// apiPaths was defined, use it and ignore 'apiPath'
288+
for _, apiPath := range innerDeployment.WebServices.Public.APIPaths {
289+
upstreamList = append(upstreamList, ProxyRoute{
290+
Upstream: fmt.Sprintf("%s:%d", hostname, 8000),
291+
Path: string(apiPath),
292+
})
293+
}
294+
} else {
295+
apiPath := innerDeployment.WebServices.Public.APIPath
296+
297+
if apiPath == "" {
298+
apiPath = innerDeployment.Name
299+
}
300+
301+
upstreamList = append(upstreamList, ProxyRoute{
302+
Upstream: fmt.Sprintf("%s:%d", hostname, 8000),
303+
Path: fmt.Sprintf("/api/%s/*", apiPath),
304+
})
305+
306+
}
296307
}
297308
}
298309

0 commit comments

Comments
 (0)