Skip to content

Commit

Permalink
Rename edgedb to instance in gel.toml (#1443)
Browse files Browse the repository at this point in the history
  • Loading branch information
aljazerzen authored Jan 22, 2025
1 parent 63e4462 commit 4e41035
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
21 changes: 11 additions & 10 deletions src/portable/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ use crate::print::{self, msg, Highlight};
#[derive(serde::Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct SrcConfig {
pub edgedb: SrcEdgedb,
#[serde(alias = "edgedb")]
pub instance: SrcInstance,
pub project: Option<SrcProject>,
#[serde(flatten)]
pub extra: BTreeMap<String, toml::Value>,
}

#[derive(serde::Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct SrcEdgedb {
pub struct SrcInstance {
#[serde(default)]
pub server_version: Option<toml::Spanned<Query>>,
#[serde(flatten)]
Expand All @@ -43,12 +44,12 @@ pub struct SrcProject {

#[derive(Debug)]
pub struct Config {
pub edgedb: Edgedb,
pub instance: Instance,
pub project: Project,
}

#[derive(Debug)]
pub struct Edgedb {
pub struct Instance {
pub server_version: Query,
}

Expand All @@ -66,7 +67,7 @@ pub fn warn_extra(extra: &BTreeMap<String, toml::Value>, prefix: &str) {
pub fn format_config(version: &Query) -> String {
format!(
"\
[edgedb]\n\
[instance]\n\
server-version = {:?}\n\
",
version.as_config_value()
Expand All @@ -79,12 +80,12 @@ pub fn read(path: &Path) -> anyhow::Result<Config> {
let toml = toml::de::Deserializer::new(&text);
let val: SrcConfig = serde_path_to_error::deserialize(toml)?;
warn_extra(&val.extra, "");
warn_extra(&val.edgedb.extra, "edgedb.");
warn_extra(&val.instance.extra, "instance.");

return Ok(Config {
edgedb: Edgedb {
instance: Instance {
server_version: val
.edgedb
.instance
.server_version
.map(|x| x.into_inner())
.unwrap_or(Query {
Expand Down Expand Up @@ -180,7 +181,7 @@ pub fn modify_server_ver(config: &Path, ver: &Query) -> anyhow::Result<bool> {
);
read_modify_write(
config,
|v: &SrcConfig| &v.edgedb.server_version,
|v: &SrcConfig| &v.instance.server_version,
"server-version",
ver,
Query::as_config_value,
Expand Down Expand Up @@ -287,7 +288,7 @@ mod test {
super::modify_config(
&parsed,
data,
|v: &super::SrcConfig| &v.edgedb.server_version,
|v: &super::SrcConfig| &v.instance.server_version,
"server-version",
version,
super::Query::as_config_value,
Expand Down
4 changes: 2 additions & 2 deletions src/portable/project/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub fn init_existing(
let ver_query = if let Some(sver) = &options.server_version {
sver.clone()
} else {
config.edgedb.server_version
config.instance.server_version
};
let mut client = CloudClient::new(cloud_options)?;
let (name, exists) = ask_name(project_dir, options, &mut client)?;
Expand Down Expand Up @@ -492,7 +492,7 @@ fn link(
}

let config = config::read(&config_path)?;
let ver_query = config.edgedb.server_version;
let ver_query = config.instance.server_version;

let mut client = CloudClient::new(cloud_options)?;
let name = if let Some(name) = &options.server_instance {
Expand Down
2 changes: 1 addition & 1 deletion src/portable/project/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ pub fn upgrade_instance(options: &Command, opts: &crate::options::Options) -> an
anyhow::bail!("`{CONFIG_FILE_DISPLAY_NAME}` not found, unable to upgrade {BRANDING} instance without an initialized project.");
};
let config = config::read(&config_path)?;
let cfg_ver = &config.edgedb.server_version;
let cfg_ver = &config.instance.server_version;
let schema_dir = &config.project.schema_dir;

let stash_dir = get_stash_path(&root)?;
Expand Down

0 comments on commit 4e41035

Please sign in to comment.