这是indexloc提供的服务,不要输入任何密码
Skip to content

Mention MONGODB_DATABASE_URI environment variable in error message if it is missing #50

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

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This changelog documents the changes between release versions.
## [Unreleased]
- Fix incorrect order of results for query requests with more than 10 variable sets (#37)
- In the CLI update command, don't overwrite schema files that haven't changed ([#49](https://github.com/hasura/ndc-mongodb/pull/49/files))
- In the CLI update command, if the database URI is not provided the error message now mentions the correct environment variable to use (`MONGODB_DATABASE_URI`) ([#50](https://github.com/hasura/ndc-mongodb/pull/50))

## [0.0.4] - 2024-04-12
- Queries that attempt to compare a column to a column in the query root table, or a related table, will now fail instead of giving the incorrect result ([#22](https://github.com/hasura/ndc-mongodb/pull/22))
Expand Down
17 changes: 11 additions & 6 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use anyhow::anyhow;
use std::env;
use std::path::PathBuf;

use clap::Parser;
use clap::{Parser, ValueHint};
use mongodb_agent_common::state::{try_init_state_from_uri, DATABASE_URI_ENV_VAR};
use mongodb_cli_plugin::{run, Command, Context};

Expand All @@ -18,17 +18,18 @@ pub struct Args {
#[arg(
long = "context-path",
env = "HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH",
value_name = "DIRECTORY"
value_name = "DIRECTORY",
value_hint = ValueHint::DirPath
)]
pub context_path: Option<PathBuf>,

#[arg(
long = "connection-uri",
env = DATABASE_URI_ENV_VAR,
required = true,
value_name = "URI"
value_name = "URI",
value_hint = ValueHint::Url
)]
pub connection_uri: String,
pub connection_uri: Option<String>,

/// The command to invoke.
#[command(subcommand)]
Expand All @@ -45,7 +46,11 @@ pub async fn main() -> anyhow::Result<()> {
Some(path) => path,
None => env::current_dir()?,
};
let connector_state = try_init_state_from_uri(&args.connection_uri)
let connection_uri = args.connection_uri.ok_or(anyhow!(
"Missing environment variable {}",
DATABASE_URI_ENV_VAR
))?;
let connector_state = try_init_state_from_uri(&connection_uri)
.await
.map_err(|e| anyhow!("Error initializing MongoDB state {}", e))?;
let context = Context {
Expand Down