Skip to content

Commit

Permalink
Merge pull request #82 from helsing-ai/kh/better-login-logging-2
Browse files Browse the repository at this point in the history
Log when pinging
  • Loading branch information
kihehs authored Sep 26, 2023
2 parents a2ae061 + ecd77cb commit 8ef39da
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/registry/artifactory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,25 @@ impl Artifactory {
reqwest::Client::builder().redirect(reqwest::redirect::Policy::none());

if let Some(token) = credentials.registry_tokens.get(&registry) {
if std::env::var("BUFFRS_TESTSUITE").is_err() {
tracing::info!(
uri=?registry.as_str(),
token_length=?token.len(),
"The {} header is set",
Self::JFROG_AUTH_HEADER,
);
}

let mut headers = HeaderMap::new();
headers.insert(Self::JFROG_AUTH_HEADER, token.parse()?);

client_builder = client_builder.default_headers(headers);
} else if std::env::var("BUFFRS_TESTSUITE").is_err() {
tracing::info!(
uri=?registry.as_str(),
"The {} header is NOT set",
Self::JFROG_AUTH_HEADER,
);
}

Ok(Self {
Expand All @@ -56,9 +71,15 @@ impl Artifactory {

let response = self.client.get(repositories_url).send().await?;

ensure!(response.status().is_success(), "Failed to ping artifactory");
let status = response.status();

if !status.is_success() {
tracing::info!("Artifactory response header: {:?}", response);
}

ensure!(status.is_success(), "Failed to ping artifactory");

tracing::debug!("pinging artifactory succeeded");
tracing::debug!("Pinging artifactory succeeded");

Ok(())
}
Expand Down

0 comments on commit 8ef39da

Please sign in to comment.