Skip to content

Commit

Permalink
Merge pull request #5061 from kobergj/FixOCMWildcardsII
Browse files Browse the repository at this point in the history
Fix OCM Wildcards
  • Loading branch information
kobergj authored Feb 3, 2025
2 parents 1391493 + de27ef9 commit f4d78c9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
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

0 comments on commit f4d78c9

Please sign in to comment.