ExtractNamespace parses the namespace value from the incoming gRPC context. For the non-ACL mode, it is caller's responsibility to set the galaxy namespace.
(ctx context.Context)
| 260 | // ExtractNamespace parses the namespace value from the incoming gRPC context. For the non-ACL mode, |
| 261 | // it is caller's responsibility to set the galaxy namespace. |
| 262 | func ExtractNamespace(ctx context.Context) (uint64, error) { |
| 263 | md, ok := metadata.FromIncomingContext(ctx) |
| 264 | if !ok { |
| 265 | return 0, errors.New("No metadata in the context") |
| 266 | } |
| 267 | ns := md.Get("namespace") |
| 268 | if len(ns) == 0 { |
| 269 | return 0, errors.New("No namespace in the metadata of context") |
| 270 | } |
| 271 | namespace, err := strconv.ParseUint(ns[0], 0, 64) |
| 272 | if err != nil { |
| 273 | return 0, errors.Wrapf(err, "Error while parsing namespace from metadata") |
| 274 | } |
| 275 | return namespace, nil |
| 276 | } |
| 277 | |
| 278 | func IsRootNsOperation(ctx context.Context) bool { |
| 279 | md, ok := metadata.FromIncomingContext(ctx) |
no test coverage detected