Skip to content
Open
Show file tree
Hide file tree
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/bin/docs_rs_admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ docs_rs_logging = { path = "../../lib/docs_rs_logging" }
docs_rs_repository_stats = { path = "../../lib/docs_rs_repository_stats" }
docs_rs_storage = { path = "../../lib/docs_rs_storage" }
docs_rs_types = { path = "../../lib/docs_rs_types" }
docs_rs_uri = { path = "../../lib/docs_rs_uri" }
docs_rs_utils = { path = "../../lib/docs_rs_utils" }
futures-util = { workspace = true }
sqlx = { workspace = true }
Expand Down
77 changes: 73 additions & 4 deletions crates/bin/docs_rs_admin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod repackage;
pub(crate) mod testing;

use anyhow::{Context as _, Result, bail};
use chrono::NaiveDate;
use chrono::{NaiveDate, Utc};
use clap::{Parser, Subcommand};
use docs_rs_build_limits::{Overrides, blacklist};
use docs_rs_build_queue::priority::{
Expand All @@ -14,12 +14,13 @@ use docs_rs_build_queue::priority::{
use docs_rs_context::Context;
use docs_rs_database::{
crate_details,
service_config::{ConfigName, set_config},
service_config::{Abnormality, AlertSeverity, AnchorId, ConfigName, remove_config, set_config},
};
use docs_rs_fastly::CdnBehaviour as _;
use docs_rs_headers::SurrogateKey;
use docs_rs_repository_stats::workspaces;
use docs_rs_types::{CrateId, KrateName, ReleaseId, Version};
use docs_rs_uri::EscapedURI;
use futures_util::StreamExt;
use rebuilds::queue_rebuilds_faulty_rustdoc;
use std::iter;
Expand All @@ -37,7 +38,7 @@ async fn main() -> Result<()> {
Ok(())
}

#[derive(Debug, Clone, PartialEq, Eq, Parser)]
#[derive(Debug, Clone, PartialEq, Parser)]
#[command(
about = env!("CARGO_PKG_DESCRIPTION"),
version = docs_rs_utils::BUILD_VERSION,
Expand Down Expand Up @@ -350,7 +351,7 @@ impl BuildSubcommand {
}
}

#[derive(Debug, Clone, PartialEq, Eq, Subcommand)]
#[derive(Debug, Clone, PartialEq, Subcommand)]
enum DatabaseSubcommand {
/// Run database migration
Migrate {
Expand All @@ -359,6 +360,12 @@ enum DatabaseSubcommand {
version: Option<i64>,
},

/// Manage the abnormality shown in the site header
Abnormality {
#[command(subcommand)]
command: AbnormalitySubcommand,
},

/// temporary command to repackage missing crates into archive storage.
/// starts at the earliest release and works forwards.
Repackage {
Expand Down Expand Up @@ -404,6 +411,8 @@ impl DatabaseSubcommand {
}
.context("Failed to run database migrations")?,

Self::Abnormality { command } => command.handle_args(ctx).await?,

Self::Repackage { limit } => {
let pool = ctx.pool()?;
let storage = ctx.storage()?;
Expand Down Expand Up @@ -504,6 +513,66 @@ impl DatabaseSubcommand {
}
}

#[derive(Debug, Clone, PartialEq, Subcommand)]
enum AbnormalitySubcommand {
/// Set the abnormality shown in the site header
Set {
#[arg(long)]
url: EscapedURI,
#[arg(long)]
text: String,
/// explanation to be shown on the status page, can be HTML
#[arg(long)]
explanation: Option<String>,
#[arg(long, default_value_t)]
severity: AlertSeverity,
},

/// Remove the abnormality shown in the site header
Remove,
}

impl AbnormalitySubcommand {
async fn handle_args(self, ctx: Context) -> Result<()> {
let mut conn = ctx
.pool()?
.get_async()
.await
.context("failed to get a database connection")?;

match self {
Self::Set {
url,
text,
explanation,
severity,
} => {
set_config(
&mut conn,
ConfigName::Abnormality,
Abnormality {
anchor_id: AnchorId::Manual,
url,
text,
explanation,
start_time: Some(Utc::now()),
severity,
},
)
.await
.context("failed to set abnormality in database")?;
}
Self::Remove => {
remove_config(&mut conn, ConfigName::Abnormality)
.await
.context("failed to remove abnormality from database")?;
}
}

Ok(())
}
}

#[derive(Debug, Clone, PartialEq, Eq, Subcommand)]
enum LimitsSubcommand {
/// Get sandbox limit overrides for a crate
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/bin/docs_rs_web/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
cache::CachePolicy,
handlers::releases::Search,
impl_axum_webpage,
page::templates::{RenderBrands, RenderSolid},
page::templates::{AlertSeverityRender, RenderBrands, RenderSolid},
};
use anyhow::{Result, anyhow};
use askama::Template;
Expand Down
Loading
Loading