MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / init

Function init

src/mz/src/command/profile.rs:155–189  ·  view source on GitHub ↗

Initiates the profile creation process. There are only two ways to create a profile: 1. By prompting your user and email. 2. By opening the browser and creating the credentials in the console.

(
    scx: &Context,
    no_browser: bool,
    force: bool,
    admin_endpoint: Option<Url>,
    cloud_endpoint: Option<Url>,
)

Source from the content-addressed store, hash-verified

153/// 1. By prompting your user and email.
154/// 2. By opening the browser and creating the credentials in the console.
155pub async fn init(
156 scx: &Context,
157 no_browser: bool,
158 force: bool,
159 admin_endpoint: Option<Url>,
160 cloud_endpoint: Option<Url>,
161) -> Result<(), Error> {
162 let config_file = scx.config_file();
163 let profile = scx
164 .get_global_profile()
165 .unwrap_or_else(|| config_file.profile().to_string());
166
167 if let Some(profiles) = scx.config_file().profiles() {
168 if profiles.contains_key(&profile) && !force {
169 return Err(ProfileNameAlreadyExistsError(profile));
170 }
171 }
172
173 let app_password = match no_browser {
174 true => init_without_browser(admin_endpoint.clone()).await?,
175 false => init_with_browser(cloud_endpoint.clone()).await?,
176 };
177
178 let new_profile = TomlProfile {
179 app_password: Some(app_password.to_string()),
180 vault: None,
181 region: None,
182 admin_endpoint: admin_endpoint.map(|url| url.to_string()),
183 cloud_endpoint: cloud_endpoint.map(|url| url.to_string()),
184 };
185
186 config_file.add_profile(profile, new_profile).await?;
187
188 Ok(())
189}
190
191/// List all the possible config values for the profile.
192pub fn list(cx: &Context) -> Result<(), Error> {

Callers 5

runFunction · 0.50
configureFunction · 0.50
handleMethod · 0.50
openssl_sys_hackFunction · 0.50
openMethod · 0.50

Calls 11

init_without_browserFunction · 0.85
init_with_browserFunction · 0.85
config_fileMethod · 0.80
get_global_profileMethod · 0.80
profilesMethod · 0.80
contains_keyMethod · 0.80
add_profileMethod · 0.80
to_stringMethod · 0.45
profileMethod · 0.45
cloneMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected