fix: Move creds empty check to credentials module
This commit is contained in:
parent
32e2ba35cf
commit
aebaabfb2f
2 changed files with 11 additions and 22 deletions
|
|
@ -59,8 +59,8 @@ static ENV_CREDENTIALS: Lazy<Option<Credentials>> = Lazy::new(|| {
|
|||
env::var(CI_REGISTRY).ok(),
|
||||
env::var(GITHUB_ACTIONS).ok(),
|
||||
) {
|
||||
(Some(registry), _, _) => registry,
|
||||
(None, Some(ci_registry), None) => ci_registry,
|
||||
(Some(registry), _, _) if !registry.is_empty() => registry,
|
||||
(None, Some(ci_registry), None) if !ci_registry.is_empty() => ci_registry,
|
||||
(None, None, Some(_)) => "ghcr.io".to_string(),
|
||||
_ => return None,
|
||||
};
|
||||
|
|
@ -71,9 +71,9 @@ static ENV_CREDENTIALS: Lazy<Option<Credentials>> = Lazy::new(|| {
|
|||
env::var(CI_REGISTRY_USER).ok(),
|
||||
env::var(GITHUB_ACTOR).ok(),
|
||||
) {
|
||||
(Some(username), _, _) => username,
|
||||
(None, Some(ci_registry_user), None) => ci_registry_user,
|
||||
(None, None, Some(github_actor)) => github_actor,
|
||||
(Some(username), _, _) if !username.is_empty() => username,
|
||||
(None, Some(ci_registry_user), None) if !ci_registry_user.is_empty() => ci_registry_user,
|
||||
(None, None, Some(github_actor)) if !github_actor.is_empty() => github_actor,
|
||||
_ => return None,
|
||||
};
|
||||
trace!("Username: {username}");
|
||||
|
|
@ -83,9 +83,11 @@ static ENV_CREDENTIALS: Lazy<Option<Credentials>> = Lazy::new(|| {
|
|||
env::var(CI_REGISTRY_PASSWORD).ok(),
|
||||
env::var(GITHUB_TOKEN).ok(),
|
||||
) {
|
||||
(Some(password), _, _) => password,
|
||||
(None, Some(ci_registry_password), None) => ci_registry_password,
|
||||
(None, None, Some(registry_token)) => registry_token,
|
||||
(Some(password), _, _) if !password.is_empty() => password,
|
||||
(None, Some(ci_registry_password), None) if !ci_registry_password.is_empty() => {
|
||||
ci_registry_password
|
||||
}
|
||||
(None, None, Some(registry_token)) if !registry_token.is_empty() => registry_token,
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -256,20 +256,7 @@ impl Driver<'_> {
|
|||
pub fn init(self) -> Result<()> {
|
||||
trace!("Driver::init()");
|
||||
let init = INIT.lock().map_err(|e| anyhow!("{e}"))?;
|
||||
credentials::set_user_creds(
|
||||
match self.username {
|
||||
Some(username) if !username.is_empty() => Some(username),
|
||||
_ => None,
|
||||
},
|
||||
match self.password {
|
||||
Some(password) if !password.is_empty() => Some(password),
|
||||
_ => None,
|
||||
},
|
||||
match self.registry {
|
||||
Some(registry) if !registry.is_empty() => Some(registry),
|
||||
_ => None,
|
||||
},
|
||||
)?;
|
||||
credentials::set_user_creds(self.username, self.password, self.registry)?;
|
||||
|
||||
let mut build_driver = SELECTED_BUILD_DRIVER.lock().map_err(|e| anyhow!("{e}"))?;
|
||||
let mut inspect_driver = SELECTED_INSPECT_DRIVER.lock().map_err(|e| anyhow!("{e}"))?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue