Skip to content
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

Fix OCM Wildcards #5061

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-ocm-wildcards.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: OCM Wildcards

Fix using ocm wildcards. Do not overwrite cached provider with actual value

https://github.com/cs3org/reva/pull/5061
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (s *service) GetInfoByDomain(ctx context.Context, req *ocmprovider.GetInfoB
domainInfo, err := s.pa.GetInfoByDomain(ctx, req.Domain)
if err != nil {
return &ocmprovider.GetInfoByDomainResponse{
Status: status.NewInternal(ctx, "error getting provider info"),
Status: status.NewInternal(ctx, "error getting provider info: "+err.Error()),
}, nil
}

Expand Down
31 changes: 25 additions & 6 deletions pkg/ocm/provider/authorizer/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,32 @@ func (a *authorizer) GetInfoByDomain(_ context.Context, domain string) (*ocmprov
// check if the domain matches a regex
if ok, err := regexp.MatchString(p.Domain, normalizedDomain); ok && err == nil {
// overwrite wildcards with the actual domain
for i, s := range p.Services {
s.Endpoint.Path = strings.ReplaceAll(s.Endpoint.Path, p.Domain, normalizedDomain)
s.Host = strings.ReplaceAll(s.Host, p.Domain, normalizedDomain)
p.Services[i] = s
var services []*ocmprovider.Service
for _, s := range p.Services {
services = append(services, &ocmprovider.Service{
Host: strings.ReplaceAll(s.Host, p.Domain, normalizedDomain),
Endpoint: &ocmprovider.ServiceEndpoint{
Type: s.Endpoint.Type,
Name: s.Endpoint.Name,
Path: strings.ReplaceAll(s.Endpoint.Path, p.Domain, normalizedDomain),
IsMonitored: s.Endpoint.IsMonitored,
Properties: s.Endpoint.Properties,
},
ApiVersion: s.ApiVersion,
AdditionalEndpoints: s.AdditionalEndpoints,
})
}
p.Domain = normalizedDomain
return p, nil
return &ocmprovider.ProviderInfo{
Name: p.Name,
FullName: p.FullName,
Description: p.Description,
Organization: p.Organization,
Domain: normalizedDomain,
Homepage: p.Homepage,
Email: p.Email,
Services: services,
Properties: p.Properties,
}, nil
}
}
return nil, errtypes.NotFound(domain)
Expand Down
Loading