Debian Codegraph @

internal/csfle/csfle.go

raw symbols SCIP
1 // Copyright (C) MongoDB, Inc. 2022-present.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may
4 // not use this file except in compliance with the License. You may obtain
5 // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
7 package csflescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/csfle`/
8
9 import (
10 "errorsscip-go gomod github.com/golang/go/src go1.18 errors/"
11 "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/"
12
13 "go.mongodb.org/mongo-driver/x/bsonx/bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/"
14 )
15
16 const (
17 EncryptedCacheCollectionscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/csfle`/EncryptedCacheCollection. = "ecc"
18 EncryptedStateCollectionscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/csfle`/EncryptedStateCollection. = "esc"
19 EncryptedCompactionCollectionscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/csfle`/EncryptedCompactionCollection. = "ecoc"
20 )
21
22 // GetEncryptedStateCollectionName returns the encrypted state collection name associated with dataCollectionName.
23 func GetEncryptedStateCollectionNamescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/internal/csfle`/GetEncryptedStateCollectionName().(efBSON bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.Documentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/Document#, dataCollectionName string, stateCollection string) (string, error) {
24 fieldName := stateCollection + "Collection"
25 val, err := efBSON.LookupErrscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/Document#LookupErr().(fieldName)
26 if err != nil {
27 if !errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Isscip-go gomod github.com/golang/go/src go1.18 errors/Is().(err, bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.ErrElementNotFoundscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/ErrElementNotFound.) {
28 return "", err
29 }
30 // Return default name.
31 defaultName := "enxcol_." + dataCollectionName + "." + stateCollection
32 return defaultName, nil
33 }
34
35 stateCollectionName, ok := val.StringValueOKscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/Value#StringValueOK().()
36 if !ok {
37 return "", fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().("expected string for '%v', got: %v", fieldName, val.Typescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/Value#Type.)
38 }
39 return stateCollectionName, nil
40 }