From ac7299668a686ef94245d33e9ea66183b5bddbe5 Mon Sep 17 00:00:00 2001 From: Islam Aleiv Date: Mon, 8 Jul 2024 13:28:42 +0200 Subject: [PATCH] Move function --- cli/collection_create.go | 15 +++++++++++++++ cli/utils.go | 15 --------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cli/collection_create.go b/cli/collection_create.go index 7d82eab6b7..ca28bcf79b 100644 --- a/cli/collection_create.go +++ b/cli/collection_create.go @@ -17,7 +17,9 @@ import ( "github.com/spf13/cobra" "github.com/sourcenetwork/defradb/client" + "github.com/sourcenetwork/defradb/datastore" "github.com/sourcenetwork/defradb/internal/db" + "github.com/sourcenetwork/defradb/internal/encryption" ) func MakeCollectionCreateCommand() *cobra.Command { @@ -112,3 +114,16 @@ Example: create from stdin: cmd.Flags().StringVarP(&file, "file", "f", "", "File containing document(s)") return cmd } + +// setContextDocEncryption sets doc encryption for the current command context. +func setContextDocEncryption(cmd *cobra.Command, shouldEncrypt bool, encryptFields []string, txn datastore.Txn) { + if !shouldEncrypt && len(encryptFields) == 0 { + return + } + ctx := cmd.Context() + if txn != nil { + ctx = encryption.ContextWithStore(ctx, txn) + } + ctx = encryption.SetContextConfigFromParams(ctx, shouldEncrypt, encryptFields) + cmd.SetContext(ctx) +} diff --git a/cli/utils.go b/cli/utils.go index 6369040e13..d1ee09962b 100644 --- a/cli/utils.go +++ b/cli/utils.go @@ -25,10 +25,8 @@ import ( acpIdentity "github.com/sourcenetwork/defradb/acp/identity" "github.com/sourcenetwork/defradb/client" - "github.com/sourcenetwork/defradb/datastore" "github.com/sourcenetwork/defradb/http" "github.com/sourcenetwork/defradb/internal/db" - "github.com/sourcenetwork/defradb/internal/encryption" "github.com/sourcenetwork/defradb/keyring" ) @@ -162,19 +160,6 @@ func setContextIdentity(cmd *cobra.Command, privateKeyHex string) error { return nil } -// setContextDocEncryption sets doc encryption for the current command context. -func setContextDocEncryption(cmd *cobra.Command, shouldEncrypt bool, encryptFields []string, txn datastore.Txn) { - if !shouldEncrypt && len(encryptFields) == 0 { - return - } - ctx := cmd.Context() - if txn != nil { - ctx = encryption.ContextWithStore(ctx, txn) - } - ctx = encryption.SetContextConfigFromParams(ctx, shouldEncrypt, encryptFields) - cmd.SetContext(ctx) -} - // setContextRootDir sets the rootdir for the current command context. func setContextRootDir(cmd *cobra.Command) error { rootdir, err := cmd.Root().PersistentFlags().GetString("rootdir")