chore: change CodexAuth::from_api_key() to take &str instead of String (#1970)
Good practice and simplifies some of the call sites. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/1970). * #1971 * __->__ #1970 * #1966 * #1965 * #1962
This commit is contained in:
@@ -96,7 +96,7 @@ impl ModelProviderInfo {
|
|||||||
auth: &Option<CodexAuth>,
|
auth: &Option<CodexAuth>,
|
||||||
) -> crate::error::Result<reqwest::RequestBuilder> {
|
) -> crate::error::Result<reqwest::RequestBuilder> {
|
||||||
let effective_auth = match self.api_key() {
|
let effective_auth = match self.api_key() {
|
||||||
Ok(Some(key)) => Some(CodexAuth::from_api_key(key)),
|
Ok(Some(key)) => Some(CodexAuth::from_api_key(&key)),
|
||||||
Ok(None) => auth.clone(),
|
Ok(None) => auth.clone(),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if auth.is_some() {
|
if auth.is_some() {
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ async fn includes_session_id_and_model_headers_in_request() {
|
|||||||
let ctrl_c = std::sync::Arc::new(tokio::sync::Notify::new());
|
let ctrl_c = std::sync::Arc::new(tokio::sync::Notify::new());
|
||||||
let CodexSpawnOk { codex, .. } = Codex::spawn(
|
let CodexSpawnOk { codex, .. } = Codex::spawn(
|
||||||
config,
|
config,
|
||||||
Some(CodexAuth::from_api_key("Test API Key".to_string())),
|
Some(CodexAuth::from_api_key("Test API Key")),
|
||||||
ctrl_c.clone(),
|
ctrl_c.clone(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
@@ -167,7 +167,7 @@ async fn includes_base_instructions_override_in_request() {
|
|||||||
let ctrl_c = std::sync::Arc::new(tokio::sync::Notify::new());
|
let ctrl_c = std::sync::Arc::new(tokio::sync::Notify::new());
|
||||||
let CodexSpawnOk { codex, .. } = Codex::spawn(
|
let CodexSpawnOk { codex, .. } = Codex::spawn(
|
||||||
config,
|
config,
|
||||||
Some(CodexAuth::from_api_key("Test API Key".to_string())),
|
Some(CodexAuth::from_api_key("Test API Key")),
|
||||||
ctrl_c.clone(),
|
ctrl_c.clone(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
@@ -226,7 +226,7 @@ async fn originator_config_override_is_used() {
|
|||||||
let ctrl_c = std::sync::Arc::new(tokio::sync::Notify::new());
|
let ctrl_c = std::sync::Arc::new(tokio::sync::Notify::new());
|
||||||
let CodexSpawnOk { codex, .. } = Codex::spawn(
|
let CodexSpawnOk { codex, .. } = Codex::spawn(
|
||||||
config,
|
config,
|
||||||
Some(CodexAuth::from_api_key("Test API Key".to_string())),
|
Some(CodexAuth::from_api_key("Test API Key")),
|
||||||
ctrl_c.clone(),
|
ctrl_c.clone(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
@@ -364,7 +364,7 @@ async fn includes_user_instructions_message_in_request() {
|
|||||||
let ctrl_c = std::sync::Arc::new(tokio::sync::Notify::new());
|
let ctrl_c = std::sync::Arc::new(tokio::sync::Notify::new());
|
||||||
let CodexSpawnOk { codex, .. } = Codex::spawn(
|
let CodexSpawnOk { codex, .. } = Codex::spawn(
|
||||||
config,
|
config,
|
||||||
Some(CodexAuth::from_api_key("Test API Key".to_string())),
|
Some(CodexAuth::from_api_key("Test API Key")),
|
||||||
ctrl_c.clone(),
|
ctrl_c.clone(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ async fn summarize_context_three_requests_and_instructions() {
|
|||||||
let ctrl_c = std::sync::Arc::new(tokio::sync::Notify::new());
|
let ctrl_c = std::sync::Arc::new(tokio::sync::Notify::new());
|
||||||
let CodexSpawnOk { codex, .. } = Codex::spawn(
|
let CodexSpawnOk { codex, .. } = Codex::spawn(
|
||||||
config,
|
config,
|
||||||
Some(CodexAuth::from_api_key("dummy".to_string())),
|
Some(CodexAuth::from_api_key("dummy")),
|
||||||
ctrl_c.clone(),
|
ctrl_c.clone(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ async fn retries_on_early_close() {
|
|||||||
config.model_provider = model_provider;
|
config.model_provider = model_provider;
|
||||||
let CodexSpawnOk { codex, .. } = Codex::spawn(
|
let CodexSpawnOk { codex, .. } = Codex::spawn(
|
||||||
config,
|
config,
|
||||||
Some(CodexAuth::from_api_key("Test API Key".to_string())),
|
Some(CodexAuth::from_api_key("Test API Key")),
|
||||||
ctrl_c,
|
ctrl_c,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ impl PartialEq for CodexAuth {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CodexAuth {
|
impl CodexAuth {
|
||||||
pub fn from_api_key(api_key: String) -> Self {
|
pub fn from_api_key(api_key: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
api_key: Some(api_key),
|
api_key: Some(api_key.to_owned()),
|
||||||
mode: AuthMode::ApiKey,
|
mode: AuthMode::ApiKey,
|
||||||
auth_file: PathBuf::new(),
|
auth_file: PathBuf::new(),
|
||||||
auth_dot_json: Arc::new(Mutex::new(None)),
|
auth_dot_json: Arc::new(Mutex::new(None)),
|
||||||
|
|||||||
Reference in New Issue
Block a user