Skip to content

Commit

Permalink
Enable regex matches for provider IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed May 12, 2022
1 parent 0b46cb4 commit 8b3f759
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/grpc/services/storageprovider/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ func unwrapProviderIDAndPath(ref *provider.Reference, mountPath string) string {
}

// Trim the mount path of the storage provider if the request was for an absolute reference
if !utils.IsRelativeReference(ref) {
if ref != nil && !utils.IsRelativeReference(ref) {
ref.Path = strings.TrimPrefix(ref.Path, mountPath)
}

Expand All @@ -1306,7 +1306,7 @@ func rewrapProviderIDAndPath(ref *provider.Reference, spid, mountPath string) {
}

// Prepend the mount path of the storage provider if the request was for an absolute reference
if !utils.IsRelativeReference(ref) {
if ref != nil && !utils.IsRelativeReference(ref) {
ref.Path = path.Join(mountPath, ref.Path)
}
}
8 changes: 6 additions & 2 deletions pkg/storage/registry/spaces/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,14 @@ func (r *registry) findProvidersForResource(ctx context.Context, id string, find

for address, provider := range r.c.Providers {
// try to find provider based on storageproviderid prefix
if provider.ProviderID != "" && sdid != "" && provider.ProviderID != sdid {
if provider.ProviderID != "" && sdid != "" {
// skip mismatching storageproviders
continue
match, err := regexp.MatchString("^"+provider.ProviderID+"$", sdid)
if err != nil || !match {
continue
}
}

p := &registrypb.ProviderInfo{
Address: address,
ProviderId: id,
Expand Down

0 comments on commit 8b3f759

Please sign in to comment.