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

Log when pinging #81

Closed
wants to merge 6 commits into from
Closed
Changes from all 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
40 changes: 38 additions & 2 deletions src/registry/artifactory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,45 @@ impl Artifactory {
uri.into()
};

let response = self.client.get(repositories_url).send().await?;
let response = {
let builder = reqwest::Client::builder()
.redirect(reqwest::redirect::Policy::none())
.build()
.wrap_err("client error")?
.get(repositories_uri.as_str());

let builder = if let Some(token) = self.credentials.registry_tokens.get(&self.registry)
{
tracing::info!(
uri=?repositories_uri.as_str(),
token_length=?token.len(),
"Pinging with the {} header set",
Self::JFROG_AUTH_HEADER,
);
builder.header(Self::JFROG_AUTH_HEADER, token)
} else {
tracing::info!(
uri=?repositories_uri.as_str(),
"Pinging WITHOUT the {} header set",
Self::JFROG_AUTH_HEADER
);
builder
};

builder.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. Status {status}",
status = status.as_u16()
);

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

Expand Down
Loading