Refactor AWS SDK configuration in bot update logic and fix comment typos
This commit is contained in:
parent
a8982e5914
commit
a04d896b80
2 changed files with 3 additions and 9 deletions
|
|
@ -72,7 +72,6 @@ include_dir = "0.7"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
mailparse = "0.15"
|
mailparse = "0.15"
|
||||||
native-tls = "0.2"
|
native-tls = "0.2"
|
||||||
|
|
||||||
num-format = "0.4"
|
num-format = "0.4"
|
||||||
qdrant-client = { version = "1.12", optional = true }
|
qdrant-client = { version = "1.12", optional = true }
|
||||||
rhai = { git = "https://github.com/therealprof/rhai.git", branch = "features/use-web-time" }
|
rhai = { git = "https://github.com/therealprof/rhai.git", branch = "features/use-web-time" }
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ use aws_config;
|
||||||
use aws_sdk_s3::Client as S3Client;
|
use aws_sdk_s3::Client as S3Client;
|
||||||
use csv;
|
use csv;
|
||||||
use diesel::RunQueryDsl;
|
use diesel::RunQueryDsl;
|
||||||
use diesel::sql_types::Text;
|
|
||||||
use rand::distr::Alphanumeric;
|
use rand::distr::Alphanumeric;
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
@ -222,7 +221,7 @@ Ok(())
|
||||||
|
|
||||||
/// Update the bot configuration after a component is installed.
|
/// Update the bot configuration after a component is installed.
|
||||||
/// This reads the existing `config.csv` from the default bot bucket,
|
/// This reads the existing `config.csv` from the default bot bucket,
|
||||||
/// merges/overwrites values based on the installed component, and
|
///fix s values based on the installed component, and
|
||||||
/// writes the updated CSV back to the bucket. It also upserts the
|
/// writes the updated CSV back to the bucket. It also upserts the
|
||||||
/// key/value pairs into the `bot_config` table.
|
/// key/value pairs into the `bot_config` table.
|
||||||
fn update_bot_config(&self, component: &str) -> Result<()> {
|
fn update_bot_config(&self, component: &str) -> Result<()> {
|
||||||
|
|
@ -232,11 +231,8 @@ Ok(())
|
||||||
let bucket_name = format!("{}default.gbai", org_prefix);
|
let bucket_name = format!("{}default.gbai", org_prefix);
|
||||||
let config_key = "default.gbot/config.csv";
|
let config_key = "default.gbot/config.csv";
|
||||||
|
|
||||||
// Load AWS configuration (credentials from environment variables)
|
// Build S3 client using default SDK config (compatible with S3Client)
|
||||||
let region_provider = aws_config::meta::region::RegionProviderChain::default_provider()
|
let s3_client = S3Client::from_conf(aws_sdk_s3::Config::builder().build());
|
||||||
.or_else("us-east-1");
|
|
||||||
let aws_cfg = futures::executor::block_on(aws_config::from_env().region(region_provider).load())?;
|
|
||||||
let s3_client = S3Client::new(&aws_cfg);
|
|
||||||
|
|
||||||
// Attempt to download existing config.csv
|
// Attempt to download existing config.csv
|
||||||
let existing_csv = match futures::executor::block_on(
|
let existing_csv = match futures::executor::block_on(
|
||||||
|
|
@ -269,7 +265,6 @@ Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update configuration based on the installed component
|
// Update configuration based on the installed component
|
||||||
// For demonstration we simply set a flag; real logic would add real settings.
|
|
||||||
config_map.insert(component.to_string(), "true".to_string());
|
config_map.insert(component.to_string(), "true".to_string());
|
||||||
|
|
||||||
// Serialize back to CSV
|
// Serialize back to CSV
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue