Skip to content

Commit de27ef9

Browse files
committed
fix(ocm): fix ocm wildcards again
Signed-off-by: jkoberg <[email protected]>
1 parent 1391493 commit de27ef9

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Bugfix: OCM Wildcards
2+
3+
Fix using ocm wildcards. Do not overwrite cached provider with actual value
4+
5+
https://github.com/cs3org/reva/pull/5061

internal/grpc/services/ocmproviderauthorizer/ocmproviderauthorizer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (s *service) GetInfoByDomain(ctx context.Context, req *ocmprovider.GetInfoB
109109
domainInfo, err := s.pa.GetInfoByDomain(ctx, req.Domain)
110110
if err != nil {
111111
return &ocmprovider.GetInfoByDomainResponse{
112-
Status: status.NewInternal(ctx, "error getting provider info"),
112+
Status: status.NewInternal(ctx, "error getting provider info: "+err.Error()),
113113
}, nil
114114
}
115115

pkg/ocm/provider/authorizer/json/json.go

+25-6
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,32 @@ func (a *authorizer) GetInfoByDomain(_ context.Context, domain string) (*ocmprov
122122
// check if the domain matches a regex
123123
if ok, err := regexp.MatchString(p.Domain, normalizedDomain); ok && err == nil {
124124
// overwrite wildcards with the actual domain
125-
for i, s := range p.Services {
126-
s.Endpoint.Path = strings.ReplaceAll(s.Endpoint.Path, p.Domain, normalizedDomain)
127-
s.Host = strings.ReplaceAll(s.Host, p.Domain, normalizedDomain)
128-
p.Services[i] = s
125+
var services []*ocmprovider.Service
126+
for _, s := range p.Services {
127+
services = append(services, &ocmprovider.Service{
128+
Host: strings.ReplaceAll(s.Host, p.Domain, normalizedDomain),
129+
Endpoint: &ocmprovider.ServiceEndpoint{
130+
Type: s.Endpoint.Type,
131+
Name: s.Endpoint.Name,
132+
Path: strings.ReplaceAll(s.Endpoint.Path, p.Domain, normalizedDomain),
133+
IsMonitored: s.Endpoint.IsMonitored,
134+
Properties: s.Endpoint.Properties,
135+
},
136+
ApiVersion: s.ApiVersion,
137+
AdditionalEndpoints: s.AdditionalEndpoints,
138+
})
129139
}
130-
p.Domain = normalizedDomain
131-
return p, nil
140+
return &ocmprovider.ProviderInfo{
141+
Name: p.Name,
142+
FullName: p.FullName,
143+
Description: p.Description,
144+
Organization: p.Organization,
145+
Domain: normalizedDomain,
146+
Homepage: p.Homepage,
147+
Email: p.Email,
148+
Services: services,
149+
Properties: p.Properties,
150+
}, nil
132151
}
133152
}
134153
return nil, errtypes.NotFound(domain)

0 commit comments

Comments
 (0)