Skip to content

Commit

Permalink
Update cloud migrate group backup access denied message (#1258)
Browse files Browse the repository at this point in the history
Signed-off-by: Grant Griffiths <[email protected]>
  • Loading branch information
ggriffiths authored Oct 2, 2019
1 parent 8afd2f0 commit 65a3c88
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions api/server/sdk/cloud_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package sdk

import (
"context"
"fmt"

"github.com/libopenstorage/openstorage/api"
"github.com/libopenstorage/openstorage/volume"
Expand Down Expand Up @@ -150,6 +151,20 @@ func (s *CloudBackupServer) GroupCreate(
Id: req.GetGroupId(),
},
}, api.Ownership_Read); err != nil {
statusError, ok := status.FromError(err)
if ok && statusError.Code() == codes.PermissionDenied {
var locatorContents string
switch {
case len(req.GetLabels()) > 0 && len(req.GetGroupId()) > 0:
locatorContents = fmt.Sprintf("labels %s and group ID %s", req.GetLabels(), req.GetGroupId())
case len(req.GetLabels()) > 0:
locatorContents = fmt.Sprintf("labels %s", req.GetLabels())
case len(req.GetGroupId()) > 0:
locatorContents = fmt.Sprintf("group ID %s", req.GetGroupId())
}
return nil, status.Errorf(codes.PermissionDenied, "Access denied to at least one volume with %s", locatorContents)
}

return nil, err
}
}
Expand Down

0 comments on commit 65a3c88

Please sign in to comment.