diff --git a/acp/acp_local.go b/acp/acp_local.go index 99b2cb15f4..436a35f99d 100644 --- a/acp/acp_local.go +++ b/acp/acp_local.go @@ -12,13 +12,13 @@ package acp import ( "context" - "errors" protoTypes "github.com/cosmos/gogoproto/types" "github.com/sourcenetwork/acp_core/pkg/auth" "github.com/sourcenetwork/acp_core/pkg/engine" "github.com/sourcenetwork/acp_core/pkg/runtime" "github.com/sourcenetwork/acp_core/pkg/types" + "github.com/sourcenetwork/defradb/errors" "github.com/sourcenetwork/immutable" "github.com/sourcenetwork/defradb/acp/identity" diff --git a/cli/config.go b/cli/config.go index f17b3e5ead..a85dd77a27 100644 --- a/cli/config.go +++ b/cli/config.go @@ -11,13 +11,13 @@ package cli import ( - "errors" "os" "path/filepath" "strings" "github.com/joho/godotenv" "github.com/sourcenetwork/corelog" + "github.com/sourcenetwork/defradb/errors" "github.com/spf13/pflag" "github.com/spf13/viper" ) diff --git a/cli/schema_add.go b/cli/schema_add.go index 2874301358..5cdbc6be07 100644 --- a/cli/schema_add.go +++ b/cli/schema_add.go @@ -46,16 +46,16 @@ Learn more about the DefraDB GraphQL Schema Language on https://docs.source.netw RunE: func(cmd *cobra.Command, args []string) error { store := mustGetContextStore(cmd) - var schemas []string + var combinedSchema string switch { case len(schemaFiles) > 0: - // Read schemas from files + // Read schemas from files and concatenate them for _, schemaFile := range schemaFiles { data, err := os.ReadFile(schemaFile) if err != nil { return fmt.Errorf("failed to read file %s: %w", schemaFile, err) } - schemas = append(schemas, string(data)) + combinedSchema += string(data) + "\n" } case len(args) > 0 && args[0] == "-": @@ -64,24 +64,23 @@ Learn more about the DefraDB GraphQL Schema Language on https://docs.source.netw if err != nil { return fmt.Errorf("failed to read schema from stdin: %w", err) } - schemas = append(schemas, string(data)) + combinedSchema += string(data) + "\n" case len(args) > 0: // Read schema from argument string - schemas = append(schemas, args[0]) + combinedSchema += args[0] + "\n" default: return fmt.Errorf("schema cannot be empty") } - for _, schema := range schemas { - cols, err := store.AddSchema(cmd.Context(), schema) - if err != nil { - return fmt.Errorf("failed to add schema: %w", err) - } - if err := writeJSON(cmd, cols); err != nil { - return err - } + // Process the combined schema + cols, err := store.AddSchema(cmd.Context(), combinedSchema) + if err != nil { + return fmt.Errorf("failed to add schema: %w", err) + } + if err := writeJSON(cmd, cols); err != nil { + return err } return nil diff --git a/crypto/nonce.go b/crypto/nonce.go index 9c8f00b31f..bae5dcc58a 100644 --- a/crypto/nonce.go +++ b/crypto/nonce.go @@ -12,10 +12,11 @@ package crypto import ( "crypto/rand" - "errors" "io" "os" "strings" + + "github.com/sourcenetwork/defradb/errors" ) const AESNonceSize = 12 diff --git a/internal/db/collection_index.go b/internal/db/collection_index.go index 3559b02b38..edfe201e41 100644 --- a/internal/db/collection_index.go +++ b/internal/db/collection_index.go @@ -13,7 +13,6 @@ package db import ( "context" "encoding/json" - "errors" "fmt" "strconv" "strings" @@ -24,6 +23,7 @@ import ( "github.com/sourcenetwork/defradb/client" "github.com/sourcenetwork/defradb/client/request" "github.com/sourcenetwork/defradb/datastore" + "github.com/sourcenetwork/defradb/errors" "github.com/sourcenetwork/defradb/internal/db/base" "github.com/sourcenetwork/defradb/internal/db/description" "github.com/sourcenetwork/defradb/internal/db/fetcher"