diff --git a/.github/workflows/dev-build.yaml b/.github/workflows/dev-build.yaml new file mode 100644 index 0000000..e3a3daf --- /dev/null +++ b/.github/workflows/dev-build.yaml @@ -0,0 +1,36 @@ +name: Build and Push Slackwatch Image + +on: + push: + branches: + - dev + + paths: + - 'src/**' + - 'Dockerfile' + - 'assets/**' + +concurrency: + group: "slackwatch" + cancel-in-progress: true + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Check out the code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Log in to GitHub Container Registry + run: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: ./ + file: ./Dockerfile + push: true + tags: ghcr.io/slackspace-io/slackwatch:dev,ghcr.io/slackspace-io/slackwatch:${{ github.sha }} diff --git a/.github/workflows/slackwatch.yml b/.github/workflows/slackwatch.yml index 22a953b..6b1fa2c 100644 --- a/.github/workflows/slackwatch.yml +++ b/.github/workflows/slackwatch.yml @@ -7,7 +7,6 @@ on: paths: - 'src/**' - - '.github/workflows/slackwatch.yml' - 'Dockerfile' - 'assets/**' @@ -34,4 +33,4 @@ jobs: context: ./ file: ./Dockerfile push: true - tags: ghcr.io/slackspace-io/slackwatch:dev,ghcr.io/slackspace-io/slackwatch:${{ github.sha }} + tags: ghcr.io/slackspace-io/slackwatch:preview,ghcr.io/slackspace-io/slackwatch:${{ github.sha }} diff --git a/.gitignore b/.gitignore index bde1a51..d073835 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ docker-compose*.yml #mdbook book/ .site/ +/site/ diff --git a/Cargo.lock b/Cargo.lock index ce722ea..6392dba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -121,9 +121,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "anymap" diff --git a/Cargo.toml b/Cargo.toml index 4bd7926..bdfdeed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] serde = { version = "1.0.197", features = ["derive"] } dotenv = { version = "0.15.0"} -anyhow = { version = "1.0.81", features = ["std"] } +anyhow = { version = "1.0.82", features = ["std"] } env_logger = { version = "0.11.3" } tokio = { version = "1.37.0", features = ["full"], optional = true } warp = { version = "0.3.7", optional = true } diff --git a/assets/style.css b/assets/style.css index cf37406..5d2967b 100644 --- a/assets/style.css +++ b/assets/style.css @@ -67,6 +67,6 @@ order: 1!important; } -.workload-version, .workload-image, .workload-namespace, .workload-last-scanned { +.workload-version, .workload-image, .workload-namespace, .workload-last-scanned, .workload-latest-version { margin-top: 10px; } diff --git a/src/repocheck/repocheck.rs b/src/repocheck/repocheck.rs index 1b257cc..d8d7061 100644 --- a/src/repocheck/repocheck.rs +++ b/src/repocheck/repocheck.rs @@ -26,9 +26,10 @@ pub async fn get_tags_for_image(image: &str) -> Result, Box Result Result current_version { // tag_version is greater than current_version // Do something with this tag - println!("Tag {} is newer than current version", tag); - latest_version = tag.clone(); + if latest_version.is_empty() { + log::info!("latest_version is empty - setting to tag {}", tag); + latest_version = tag.clone(); + } else if tag_version > Version::parse(&strip_tag_lettings(&latest_version)).unwrap() { + log::info!("Tag {} is newer than {} current latest_version updating", tag, latest_version); + latest_version = tag.clone(); + } + } } else { // Handle the case where the tag is not a valid SemVer format diff --git a/src/site/app.rs b/src/site/app.rs index ef7d239..ccd2b06 100644 --- a/src/site/app.rs +++ b/src/site/app.rs @@ -29,8 +29,6 @@ async fn get_all_workloads() -> Result { use crate::database::client::return_all_workloads; let workloads = return_all_workloads(); Ok(workloads.unwrap().iter().map(|w| w.name.clone()).collect::>().join(", ")) - -// Ok(workloads.unwrap().iter().map(|w| w.name.clone()).collect::>().join(", ")) } @@ -67,6 +65,31 @@ fn Home() -> Element { } } +#[component] +fn DebugWorkloadCard(props: WorkloadCardProps) -> Element { + rsx! { + div { + class: if props.workload.update_available == models::models::UpdateStatus::Available { + "workload-card-update-available" + } else { + "workload-card" + }, + div { class: "workload-name", "{props.workload.name}" }, + div { class: "workload- + namespace", "Namespace: {props.workload.namespace}" }, + div { class: "workload-version", "Current Tag {props.workload.current_version}" }, + div { class: "workload-image", "Image: {props.workload.image}" }, + div { class: "workload-last-scanned", "Last Scanned: {props.workload.last_scanned}" }, + if props.workload.update_available == models::models::UpdateStatus::Available { + div { class: "workload-latest-version", "Latest Version Available: {props.workload.latest_version}" } + br {} + } + } + } +} + + + #[component] fn WorkloadCard(props: WorkloadCardProps) -> Element { let data = use_signal(|| {props.workload.clone()}); @@ -91,6 +114,8 @@ fn WorkloadCard(props: WorkloadCardProps) -> Element { div { class: "workload-image", "Image: {props.workload.image}" }, div { class: "workload-last-scanned", "Last Scanned: {props.workload.last_scanned}" }, if props.workload.update_available == models::models::UpdateStatus::Available { + div { class: "workload-latest-version", "Latest Version Available: {props.workload.latest_version}" } + br {} button { onclick: move |_| { async move { if let Ok(_) = upgrade_workload(data()).await { @@ -106,20 +131,6 @@ fn WorkloadCard(props: WorkloadCardProps) -> Element { pub fn App() -> Element { println!("App started"); rsx! { Router:: {} } - //rsx!{ - // div { - // "App" - // } - //} - //rsx! { All {} } -// rsx! { -// "server data is {workloads():?}" -// div {} -// "server data is {all():?}" -// div { {all().map(|w| rsx! { div {"{w:?}"}})}} -// -// -//} } @@ -170,6 +181,7 @@ fn All() -> Element { div { class: "workload-version", "Current Tag {w.current_version}" }, div { class: "workload-image", "Image: {w.image}" }, div { class: "workload-last-scanned", "Last Scanned: {w.last_scanned}" }, + div { class: "workload-name", "{w.latest_version}" }, if w.update_available == models::models::UpdateStatus::Available { div { class: "workload-update-available", "Update Available" } }