mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-04-05 19:30:57 +01:00
feat(registry): add more info in auth & storage logs
This commit is contained in:
parent
9bab997992
commit
e61aeb5da0
5 changed files with 32 additions and 31 deletions
|
@ -72,7 +72,7 @@ impl AuthImpl for GitHubAuth {
|
||||||
|
|
||||||
impl Display for GitHubAuth {
|
impl Display for GitHubAuth {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "GitHub")
|
write!(f, "GitHub (client id: {})", self.client_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ use async_compression::Level;
|
||||||
use convert_case::{Case, Casing};
|
use convert_case::{Case, Casing};
|
||||||
use fs_err::tokio as fs;
|
use fs_err::tokio as fs;
|
||||||
use pesde::{
|
use pesde::{
|
||||||
manifest::Manifest,
|
manifest::{DependencyType, Manifest},
|
||||||
source::{
|
source::{
|
||||||
git_index::GitBasedSource,
|
git_index::GitBasedSource,
|
||||||
ids::VersionId,
|
ids::VersionId,
|
||||||
|
@ -283,7 +283,12 @@ pub async fn publish_package(
|
||||||
RegistryError::InvalidArchive(format!("manifest has invalid dependencies: {e}"))
|
RegistryError::InvalidArchive(format!("manifest has invalid dependencies: {e}"))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
for (specifier, _) in dependencies.values() {
|
for (specifier, ty) in dependencies.values() {
|
||||||
|
// we need not verify dev dependencies, as they won't be installed
|
||||||
|
if *ty == DependencyType::Dev {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
match specifier {
|
match specifier {
|
||||||
DependencySpecifiers::Pesde(specifier) => {
|
DependencySpecifiers::Pesde(specifier) => {
|
||||||
if specifier
|
if specifier
|
||||||
|
|
|
@ -124,6 +124,6 @@ impl StorageImpl for FSStorage {
|
||||||
|
|
||||||
impl Display for FSStorage {
|
impl Display for FSStorage {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "FS")
|
write!(f, "FS ({})", self.root.display())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,31 +19,27 @@ pub trait StorageImpl: Display {
|
||||||
package_name: &PackageName,
|
package_name: &PackageName,
|
||||||
version: &VersionId,
|
version: &VersionId,
|
||||||
contents: Vec<u8>,
|
contents: Vec<u8>,
|
||||||
) -> Result<(), crate::error::RegistryError>;
|
) -> Result<(), RegistryError>;
|
||||||
async fn get_package(
|
async fn get_package(
|
||||||
&self,
|
&self,
|
||||||
package_name: &PackageName,
|
package_name: &PackageName,
|
||||||
version: &VersionId,
|
version: &VersionId,
|
||||||
) -> Result<HttpResponse, crate::error::RegistryError>;
|
) -> Result<HttpResponse, RegistryError>;
|
||||||
|
|
||||||
async fn store_readme(
|
async fn store_readme(
|
||||||
&self,
|
&self,
|
||||||
package_name: &PackageName,
|
package_name: &PackageName,
|
||||||
version: &VersionId,
|
version: &VersionId,
|
||||||
contents: Vec<u8>,
|
contents: Vec<u8>,
|
||||||
) -> Result<(), crate::error::RegistryError>;
|
) -> Result<(), RegistryError>;
|
||||||
async fn get_readme(
|
async fn get_readme(
|
||||||
&self,
|
&self,
|
||||||
package_name: &PackageName,
|
package_name: &PackageName,
|
||||||
version: &VersionId,
|
version: &VersionId,
|
||||||
) -> Result<HttpResponse, crate::error::RegistryError>;
|
) -> Result<HttpResponse, RegistryError>;
|
||||||
|
|
||||||
async fn store_doc(
|
async fn store_doc(&self, doc_hash: String, contents: Vec<u8>) -> Result<(), RegistryError>;
|
||||||
&self,
|
async fn get_doc(&self, doc_hash: &str) -> Result<HttpResponse, RegistryError>;
|
||||||
doc_hash: String,
|
|
||||||
contents: Vec<u8>,
|
|
||||||
) -> Result<(), crate::error::RegistryError>;
|
|
||||||
async fn get_doc(&self, doc_hash: &str) -> Result<HttpResponse, crate::error::RegistryError>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StorageImpl for Storage {
|
impl StorageImpl for Storage {
|
||||||
|
@ -120,14 +116,14 @@ impl Display for Storage {
|
||||||
pub fn get_storage_from_env() -> Storage {
|
pub fn get_storage_from_env() -> Storage {
|
||||||
if let Ok(endpoint) = benv!(parse "S3_ENDPOINT") {
|
if let Ok(endpoint) = benv!(parse "S3_ENDPOINT") {
|
||||||
Storage::S3(s3::S3Storage {
|
Storage::S3(s3::S3Storage {
|
||||||
s3_bucket: Bucket::new(
|
bucket: Bucket::new(
|
||||||
endpoint,
|
endpoint,
|
||||||
UrlStyle::Path,
|
UrlStyle::Path,
|
||||||
benv!(required "S3_BUCKET_NAME"),
|
benv!(required "S3_BUCKET_NAME"),
|
||||||
benv!(required "S3_REGION"),
|
benv!(required "S3_REGION"),
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
s3_credentials: Credentials::new(
|
credentials: Credentials::new(
|
||||||
benv!(required "S3_ACCESS_KEY"),
|
benv!(required "S3_ACCESS_KEY"),
|
||||||
benv!(required "S3_SECRET_KEY"),
|
benv!(required "S3_SECRET_KEY"),
|
||||||
),
|
),
|
||||||
|
|
|
@ -13,8 +13,8 @@ use std::{fmt::Display, time::Duration};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct S3Storage {
|
pub struct S3Storage {
|
||||||
pub s3_bucket: Bucket,
|
pub bucket: Bucket,
|
||||||
pub s3_credentials: Credentials,
|
pub credentials: Credentials,
|
||||||
pub reqwest_client: reqwest::Client,
|
pub reqwest_client: reqwest::Client,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ impl StorageImpl for S3Storage {
|
||||||
contents: Vec<u8>,
|
contents: Vec<u8>,
|
||||||
) -> Result<(), RegistryError> {
|
) -> Result<(), RegistryError> {
|
||||||
let object_url = PutObject::new(
|
let object_url = PutObject::new(
|
||||||
&self.s3_bucket,
|
&self.bucket,
|
||||||
Some(&self.s3_credentials),
|
Some(&self.credentials),
|
||||||
&format!(
|
&format!(
|
||||||
"{package_name}/{}/{}/pkg.tar.gz",
|
"{package_name}/{}/{}/pkg.tar.gz",
|
||||||
version.version(),
|
version.version(),
|
||||||
|
@ -57,8 +57,8 @@ impl StorageImpl for S3Storage {
|
||||||
version: &VersionId,
|
version: &VersionId,
|
||||||
) -> Result<HttpResponse, RegistryError> {
|
) -> Result<HttpResponse, RegistryError> {
|
||||||
let object_url = GetObject::new(
|
let object_url = GetObject::new(
|
||||||
&self.s3_bucket,
|
&self.bucket,
|
||||||
Some(&self.s3_credentials),
|
Some(&self.credentials),
|
||||||
&format!(
|
&format!(
|
||||||
"{package_name}/{}/{}/pkg.tar.gz",
|
"{package_name}/{}/{}/pkg.tar.gz",
|
||||||
version.version(),
|
version.version(),
|
||||||
|
@ -79,8 +79,8 @@ impl StorageImpl for S3Storage {
|
||||||
contents: Vec<u8>,
|
contents: Vec<u8>,
|
||||||
) -> Result<(), RegistryError> {
|
) -> Result<(), RegistryError> {
|
||||||
let object_url = PutObject::new(
|
let object_url = PutObject::new(
|
||||||
&self.s3_bucket,
|
&self.bucket,
|
||||||
Some(&self.s3_credentials),
|
Some(&self.credentials),
|
||||||
&format!(
|
&format!(
|
||||||
"{package_name}/{}/{}/readme.gz",
|
"{package_name}/{}/{}/readme.gz",
|
||||||
version.version(),
|
version.version(),
|
||||||
|
@ -108,8 +108,8 @@ impl StorageImpl for S3Storage {
|
||||||
version: &VersionId,
|
version: &VersionId,
|
||||||
) -> Result<HttpResponse, RegistryError> {
|
) -> Result<HttpResponse, RegistryError> {
|
||||||
let object_url = GetObject::new(
|
let object_url = GetObject::new(
|
||||||
&self.s3_bucket,
|
&self.bucket,
|
||||||
Some(&self.s3_credentials),
|
Some(&self.credentials),
|
||||||
&format!(
|
&format!(
|
||||||
"{package_name}/{}/{}/readme.gz",
|
"{package_name}/{}/{}/readme.gz",
|
||||||
version.version(),
|
version.version(),
|
||||||
|
@ -125,8 +125,8 @@ impl StorageImpl for S3Storage {
|
||||||
|
|
||||||
async fn store_doc(&self, doc_hash: String, contents: Vec<u8>) -> Result<(), RegistryError> {
|
async fn store_doc(&self, doc_hash: String, contents: Vec<u8>) -> Result<(), RegistryError> {
|
||||||
let object_url = PutObject::new(
|
let object_url = PutObject::new(
|
||||||
&self.s3_bucket,
|
&self.bucket,
|
||||||
Some(&self.s3_credentials),
|
Some(&self.credentials),
|
||||||
// capitalize Doc to prevent conflicts with scope names
|
// capitalize Doc to prevent conflicts with scope names
|
||||||
&format!("Doc/{}.gz", doc_hash),
|
&format!("Doc/{}.gz", doc_hash),
|
||||||
)
|
)
|
||||||
|
@ -147,8 +147,8 @@ impl StorageImpl for S3Storage {
|
||||||
|
|
||||||
async fn get_doc(&self, doc_hash: &str) -> Result<HttpResponse, RegistryError> {
|
async fn get_doc(&self, doc_hash: &str) -> Result<HttpResponse, RegistryError> {
|
||||||
let object_url = GetObject::new(
|
let object_url = GetObject::new(
|
||||||
&self.s3_bucket,
|
&self.bucket,
|
||||||
Some(&self.s3_credentials),
|
Some(&self.credentials),
|
||||||
&format!("Doc/{}.gz", doc_hash),
|
&format!("Doc/{}.gz", doc_hash),
|
||||||
)
|
)
|
||||||
.sign(S3_SIGN_DURATION);
|
.sign(S3_SIGN_DURATION);
|
||||||
|
@ -161,6 +161,6 @@ impl StorageImpl for S3Storage {
|
||||||
|
|
||||||
impl Display for S3Storage {
|
impl Display for S3Storage {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "S3")
|
write!(f, "S3 (bucket name: {})", self.bucket.name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue