From 5d7b0c5f889ce320491c13c3c69fb9f909d0d58f Mon Sep 17 00:00:00 2001 From: Ruben Bartelink Date: Wed, 21 Aug 2024 14:18:06 +0100 Subject: [PATCH] fix(Tool sync cosmos from json): Use db/conn env vars --- tools/Propulsion.Tool/Sync.fs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/Propulsion.Tool/Sync.fs b/tools/Propulsion.Tool/Sync.fs index 2c112d0b..e3a1c682 100644 --- a/tools/Propulsion.Tool/Sync.fs +++ b/tools/Propulsion.Tool/Sync.fs @@ -117,8 +117,12 @@ and [] CosmosParameters = | [] From of ParseResults interface IArgParserTemplate with member a.Usage = a |> function - | Connection _ -> "specify a connection string for the destination Cosmos account. Default (if Cosmos): Same as Source" - | Database _ -> "specify a database name for store. Default (if Cosmos): Same as Source" + | Connection _ -> $"""specify a connection string for the destination Cosmos account. + Default (From Cosmos): Same as Source. + Default (From Json): optional if environment variable {Args.Configuration.Cosmos.CONNECTION} specified""" + | Database _ -> $"""specify a database name for store. + Default (From Cosmos): Same as Source. + Default (From Json): optional if environment variable {Args.Configuration.Cosmos.DATABASE} specified""" | Container _ -> "specify a container name for store." | LeaseContainerId _ -> "store leases in Sync target DB (default: use `-aux` adjacent to the Source Container). Enables the Source to be read via a ReadOnly connection string." | Timeout _ -> "specify operation timeout in seconds. Default: 5." @@ -130,7 +134,7 @@ and CosmosArguments(c: Args.Configuration, p: ParseResults) = let source = SourceArguments(c, p.GetResult CosmosParameters.From) let connection = match source.Store with | Cosmos c -> p.GetResult(Connection, fun () -> c.Connection) - | Json _ -> p.GetResult Connection + | Json _ -> p.GetResult(Connection, fun () -> c.CosmosConnection) | x -> p.Raise $"unexpected subcommand %A{x}" let connector = let timeout = p.GetResult(Timeout, 5) |> TimeSpan.seconds @@ -139,7 +143,7 @@ and CosmosArguments(c: Args.Configuration, p: ParseResults) = Equinox.CosmosStore.CosmosStoreConnector(Equinox.CosmosStore.Discovery.ConnectionString connection, timeout, retries, maxRetryWaitTime) let database = match source.Store with | Cosmos c -> p.GetResult(Database, fun () -> c.Database) - | Json _ -> p.GetResult Database + | Json _ -> p.GetResult(Database, fun () -> c.CosmosDatabase) | x -> p.Raise $"unexpected subcommand %A{x}" let container = p.GetResult Container member val Source = source