Skip to content
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

Fix "admin" role issue with different servers #1423

Merged
merged 6 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 5 additions & 3 deletions src/portable/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::print::{self, err_marker, msg, Highlight};
use crate::process;
use crate::question;

use crate::portable::project::get_default_branch_name;
use crate::portable::project::{get_default_branch_name, get_default_user_name};
use edgedb_tokio::credentials::Credentials;

fn ask_name(cloud_client: &mut cloud::client::CloudClient) -> anyhow::Result<InstanceName> {
Expand Down Expand Up @@ -171,7 +171,9 @@ pub fn create(cmd: &Create, opts: &crate::options::Options) -> anyhow::Result<()
bootstrap(
&paths,
&info,
&cmd.default_user,
cmd.default_user
.as_deref()
.unwrap_or_else(|| get_default_user_name(specific_version)),
&cmd.default_branch
.clone()
.unwrap_or_else(|| get_default_branch_name(specific_version)),
Expand Down Expand Up @@ -445,7 +447,7 @@ pub fn bootstrap(
let script = bootstrap_script(
user,
&password,
if info.get_version()? >= &Build::from_str("6.0-dev.9024+4b89273").unwrap() {
if info.get_version()? >= &Build::from_str("6.0-alpha.2+8fb3f01").unwrap() {
fantix marked this conversation as resolved.
Show resolved Hide resolved
"admin"
} else {
"edgedb"
Expand Down
7 changes: 4 additions & 3 deletions src/portable/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,10 @@ pub struct Create {
pub start_conf: Option<StartConf>,

/// Default user name (created during initialization and saved in
/// credentials file).
#[arg(long, default_value = "admin")]
pub default_user: String,
/// credentials file). This defaults to 'admin' on EdgeDB >=6.x; otherwise
/// 'edgedb' is used.
#[arg(long)]
pub default_user: Option<String>,

/// The default branch name. This defaults to 'main' on EdgeDB >=5.x; otherwise
/// 'edgedb' is used.
Expand Down
13 changes: 11 additions & 2 deletions src/portable/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,14 @@ pub fn get_default_branch_name(version: &Specific) -> String {
String::from("edgedb")
}

pub fn get_default_user_name(version: &Specific) -> &'static str {
if version.major >= 6 {
"admin"
} else {
"edgedb"
}
}

fantix marked this conversation as resolved.
Show resolved Hide resolved
pub fn get_default_branch_or_database(version: &Specific, project_dir: &Path) -> String {
if version.major >= 5 {
return String::from("main");
Expand Down Expand Up @@ -818,7 +826,7 @@ fn do_init(
},
port: Some(port),
start_conf: None,
default_user: "edgedb".into(),
default_user: None,
non_interactive: true,
cloud_opts: options.cloud_opts.clone(),
default_branch: Some(database.to_string()),
Expand All @@ -835,12 +843,13 @@ fn do_init(
InstanceKind::Wsl(WslInfo {})
} else {
let inst = install::package(pkg).context(concatcp!("error installing ", BRANDING))?;
let version = inst.version.specific();
let info = InstanceInfo {
name: name.into(),
installation: Some(inst),
port,
};
create::bootstrap(&paths, &info, "admin", database)?;
create::bootstrap(&paths, &info, get_default_user_name(&version), database)?;
match create::create_service(&info) {
Ok(()) => {}
Err(e) => {
Expand Down
Loading