Use defer in reply
All checks were successful
Build and push container image / build (push) Successful in 15m59s

This commit is contained in:
toast 2024-07-30 19:25:51 +10:00
parent 1f74db5346
commit 081ff781de
4 changed files with 12 additions and 6 deletions

2
Cargo.lock generated
View File

@ -1014,7 +1014,7 @@ dependencies = [
[[package]] [[package]]
name = "kon" name = "kon"
version = "0.3.5" version = "0.3.6"
dependencies = [ dependencies = [
"bb8", "bb8",
"bb8-postgres", "bb8-postgres",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "kon" name = "kon"
version = "0.3.5" version = "0.3.6"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,5 @@
FROM rust:1.80-alpine3.20 AS chef FROM rust:1.80-alpine3.20 AS chef
ENV RUSTFLAGS="-C target-feature=-crt-static" ENV RUSTFLAGS="-C target-feature=-crt-static"
ARG CARGO_TOKEN
RUN apk add --no-cache openssl-dev musl-dev RUN apk add --no-cache openssl-dev musl-dev
RUN cargo install cargo-chef RUN cargo install cargo-chef
WORKDIR /usr/src/kon WORKDIR /usr/src/kon
@ -8,12 +7,16 @@ WORKDIR /usr/src/kon
FROM chef AS planner FROM chef AS planner
COPY . . COPY . .
RUN mkdir -p .cargo && \ RUN mkdir -p .cargo && \
printf '[registries.gitea]\nindex = "sparse+https://git.toast-server.net/api/packages/toast/cargo/"\ntoken = "Bearer %s"\n' "$CARGO_TOKEN" >> .cargo/config.toml printf '[registries.gitea]\nindex = "sparse+https://git.toast-server.net/api/packages/toast/cargo/"' >> .cargo/config.toml
RUN cargo chef prepare RUN cargo chef prepare
FROM chef AS builder FROM chef AS dependencies
COPY --from=planner /usr/src/kon/recipe.json recipe.json COPY --from=planner /usr/src/kon/recipe.json recipe.json
RUN cargo chef cook --release RUN cargo chef cook --release
FROM chef AS builder
COPY --from=planner /usr/src/kon/.cargo /usr/src/kon/.cargo
COPY --from=dependencies /usr/src/kon/target /usr/src/kon/target
COPY . . COPY . .
RUN cargo build -rF production RUN cargo build -rF production

View File

@ -66,6 +66,8 @@ struct Status {
state: String state: String
} }
const ILO_HOSTNAME: &str = "POMNI";
async fn ilo_data() -> Result<Chassis, ReqError> { async fn ilo_data() -> Result<Chassis, ReqError> {
let client = ClientBuilder::new() let client = ClientBuilder::new()
.danger_accept_invalid_certs(true) .danger_accept_invalid_certs(true)
@ -94,6 +96,7 @@ pub async fn ilo(_: poise::Context<'_, (), Error>) -> Result<(), Error> {
/// Retrieve data from the HP iLO4 interface /// Retrieve data from the HP iLO4 interface
#[poise::command(slash_command)] #[poise::command(slash_command)]
pub async fn temperature(ctx: poise::Context<'_, (), Error>) -> Result<(), Error> { pub async fn temperature(ctx: poise::Context<'_, (), Error>) -> Result<(), Error> {
ctx.defer().await?;
let data = ilo_data().await.unwrap(); let data = ilo_data().await.unwrap();
let mut tempdata = String::new(); let mut tempdata = String::new();
@ -133,7 +136,7 @@ pub async fn temperature(ctx: poise::Context<'_, (), Error>) -> Result<(), Error
CreateEmbed::new() CreateEmbed::new()
.color(BINARY_PROPERTIES.embed_color) .color(BINARY_PROPERTIES.embed_color)
.timestamp(Timestamp::now()) .timestamp(Timestamp::now())
.title("POMNI - HP iLO4 Temperatures") .title(format!("{} - HP iLO4 Temperatures", ILO_HOSTNAME))
.fields(vec![ .fields(vec![
("Temperatures", tempdata, false), ("Temperatures", tempdata, false),
("Fans", fandata, false) ("Fans", fandata, false)