-
Notifications
You must be signed in to change notification settings - Fork 925
GODRIVER-3502: Refactor and remove builder pattern for MongoCryptOptions #2278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
4039902
1499c99
3350f07
d87a039
87be7b3
d0b152b
792bb86
c6dffd7
bc0e891
049f1dd
0e017d0
17866ca
6645c1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,14 +53,15 @@ func NewClientEncryption(keyVaultClient *Client, opts ...options.Lister[options. | |
| return nil, fmt.Errorf("error creating KMS providers map: %w", err) | ||
| } | ||
|
|
||
| mc, err := mongocrypt.NewMongoCrypt(mcopts.MongoCrypt(). | ||
| SetKmsProviders(kmsProviders). | ||
| mc, err := mongocrypt.NewMongoCrypt(&mcopts.MongoCryptOptions{ | ||
| KmsProviders: kmsProviders, | ||
| // Explicitly disable loading the crypt_shared library for the Crypt used for | ||
| // ClientEncryption because it's only needed for AutoEncryption and we don't expect users to | ||
| // have the crypt_shared library installed if they're using ClientEncryption. | ||
| SetCryptSharedLibDisabled(true). | ||
| SetHTTPClient(cea.HTTPClient). | ||
| SetKeyExpiration(cea.KeyExpiration)) | ||
| CryptSharedLibDisabled: true, | ||
| HTTPClient: cea.HTTPClient, | ||
| KeyExpiration: cea.KeyExpiration, | ||
| }) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
@@ -173,7 +174,9 @@ func (ce *ClientEncryption) CreateDataKey( | |
| return bson.Binary{}, fmt.Errorf("failed to construct options from builder: %w", err) | ||
| } | ||
|
|
||
| co := mcopts.DataKey().SetKeyAltNames(args.KeyAltNames) | ||
| co := &mcopts.DataKeyOptions{ | ||
| KeyAltNames: args.KeyAltNames, | ||
| } | ||
| if args.MasterKey != nil { | ||
| keyDoc, err := marshal( | ||
| args.MasterKey, | ||
|
|
@@ -182,10 +185,10 @@ func (ce *ClientEncryption) CreateDataKey( | |
| if err != nil { | ||
| return bson.Binary{}, err | ||
| } | ||
| co.SetMasterKey(keyDoc) | ||
| co.MasterKey = keyDoc | ||
| } | ||
| if args.KeyMaterial != nil { | ||
| co.SetKeyMaterial(args.KeyMaterial) | ||
| co.KeyMaterial = args.KeyMaterial | ||
| } | ||
|
|
||
| // create data key document | ||
|
|
@@ -208,18 +211,18 @@ func (ce *ClientEncryption) CreateDataKey( | |
| func transformExplicitEncryptionOptions(opts ...options.Lister[options.EncryptOptions]) *mcopts.ExplicitEncryptionOptions { | ||
| args, _ := mongoutil.NewOptions[options.EncryptOptions](opts...) | ||
|
|
||
| transformed := mcopts.ExplicitEncryption() | ||
| transformed := &mcopts.ExplicitEncryptionOptions{} | ||
| if args.KeyID != nil { | ||
| transformed.SetKeyID(*args.KeyID) | ||
| transformed.KeyID = args.KeyID | ||
| } | ||
| if args.KeyAltName != nil { | ||
| transformed.SetKeyAltName(*args.KeyAltName) | ||
| transformed.KeyAltName = args.KeyAltName | ||
| } | ||
| transformed.SetAlgorithm(args.Algorithm) | ||
| transformed.SetQueryType(args.QueryType) | ||
| transformed.Algorithm = args.Algorithm | ||
| transformed.QueryType = args.QueryType | ||
|
|
||
| if args.ContentionFactor != nil { | ||
| transformed.SetContentionFactor(*args.ContentionFactor) | ||
| transformed.ContentionFactor = args.ContentionFactor | ||
| } | ||
|
||
|
|
||
| if args.RangeOptions != nil { | ||
|
|
@@ -241,7 +244,7 @@ func transformExplicitEncryptionOptions(opts ...options.Lister[options.EncryptOp | |
| if rangeArgs.TrimFactor != nil { | ||
| transformedRange.TrimFactor = rangeArgs.TrimFactor | ||
| } | ||
| transformed.SetRangeOptions(transformedRange) | ||
| transformed.RangeOptions = &transformedRange | ||
| } | ||
| return transformed | ||
| } | ||
|
|
@@ -468,7 +471,7 @@ func (ce *ClientEncryption) RewrapManyDataKey( | |
| } | ||
|
|
||
| // Transfer rmdko options to /x/ package options to publish the mongocrypt feed. | ||
| co := mcopts.RewrapManyDataKey() | ||
| co := &mcopts.RewrapManyDataKeyOptions{} | ||
| if args.MasterKey != nil { | ||
| keyDoc, err := marshal( | ||
| args.MasterKey, | ||
|
|
@@ -477,10 +480,10 @@ func (ce *ClientEncryption) RewrapManyDataKey( | |
| if err != nil { | ||
| return nil, err | ||
| } | ||
| co.SetMasterKey(keyDoc) | ||
| co.MasterKey = keyDoc | ||
| } | ||
| if args.Provider != nil { | ||
| co.SetProvider(*args.Provider) | ||
| co.Provider = args.Provider | ||
| } | ||
|
||
|
|
||
| // Prepare the filters and rewrap the data key using mongocrypt. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Nitpicking] This block can be merged into L177-L179, the initialization of
co.