Skip to content

Commit

Permalink
way too big image but it works
Browse files Browse the repository at this point in the history
  • Loading branch information
slackspace-io committed Mar 21, 2024
1 parent db3dfb7 commit 7a95a40
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions rust/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ WORKDIR /usr/src/slackwatch
COPY . .
RUN cargo install --path .

FROM debian:bookworm-slim
RUN apt-get update && rm -rf /var/lib/apt/lists/*
FROM rust:1.76
#RUN apt-get update && rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/cargo/bin/slackwatch /usr/local/bin/slackwatch
CMD ["slackwatch"]
18 changes: 7 additions & 11 deletions rust/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use config::{Config, ConfigError, Environment, File};
use serde_derive::Deserialize;




#[derive(Debug, Deserialize)]
#[allow(unused)]
pub struct Settings {
Expand All @@ -23,20 +20,19 @@ pub struct Ntfy {
pub url: String,
pub topic: String,
pub reminder: String,
pub token : String
pub token: String,
}


impl Settings {
pub fn new() -> Result<Self, ConfigError> {
dotenv::dotenv().ok();
let s = Config::builder()
.add_source(File::with_name("config/default").required(false))
.add_source(File::with_name(".env.toml").required(false))
.add_source(Environment::with_prefix("slackwatch"))
.build()?;
let s = Config::builder()
.add_source(File::with_name("config/default").required(false))
.add_source(File::with_name(".env.toml").required(false))
.add_source(Environment::with_prefix("slackwatch"))
.build()?;
//print config
println!("{:?}", s);
s.try_deserialize()
}
}
}
8 changes: 5 additions & 3 deletions rust/src/services/workloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use crate::database;
use crate::database::client::get_latest_scan_id;
use crate::kubernetes::client::find_enabled_workloads;
use crate::models::models::{UpdateStatus, Workload};
use crate::notifications::ntfy::send_notification;
use crate::repocheck::repocheck::get_tags_for_image;
use regex::Regex;
use semver::Version;
use crate::notifications::ntfy::send_notification;

pub async fn fetch_and_update_all_watched() -> Result<(), String> {
let workloads = find_enabled_workloads().await.map_err(|e| e.to_string())?;
Expand All @@ -19,9 +19,11 @@ pub async fn fetch_and_update_all_watched() -> Result<(), String> {
.map_err(|e| e.to_string())?;
let workload = parse_tags(&workload).await.map_err(|e| e.to_string())?;
if workload.update_available.to_string() == "Available" {
send_notification(&workload).await.unwrap_or_else(|e| log::error!("Error sending notification: {}", e));
send_notification(&workload)
.await
.unwrap_or_else(|e| log::error!("Error sending notification: {}", e));
}

std::thread::spawn(move || database::client::insert_workload(&workload, scan_id))
.join()
.map_err(|_| "Thread error".to_string())?
Expand Down

0 comments on commit 7a95a40

Please sign in to comment.