Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: picoCTF/docker-reaper
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.1.0
Choose a base ref
...
head repository: picoCTF/docker-reaper
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 12 commits
  • 9 files changed
  • 2 contributors

Commits on Feb 3, 2025

  1. Update dependencies

    dmartin committed Feb 3, 2025
    Copy the full SHA
    191de4e View commit details

Commits on Feb 28, 2025

  1. Upgrade to Rust 2024

    dmartin committed Feb 28, 2025
    Copy the full SHA
    485fa49 View commit details
  2. Update dependencies

    dmartin committed Feb 28, 2025
    Copy the full SHA
    457244a View commit details
  3. Apply 2024 style edition

    dmartin committed Feb 28, 2025
    Copy the full SHA
    f3b7e2e View commit details
  4. Copy the full SHA
    8fd1354 View commit details

Commits on Mar 5, 2025

  1. Copy the full SHA
    54630fd View commit details

Commits on Mar 11, 2025

  1. Upgrade dependencies

    dmartin committed Mar 11, 2025
    Copy the full SHA
    647feb5 View commit details

Commits on Apr 1, 2025

  1. Bump tokio from 1.44.0 to 1.44.1

    Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.44.0 to 1.44.1.
    - [Release notes](https://github.com/tokio-rs/tokio/releases)
    - [Commits](tokio-rs/tokio@tokio-1.44.0...tokio-1.44.1)
    
    ---
    updated-dependencies:
    - dependency-name: tokio
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and dmartin committed Apr 1, 2025
    Copy the full SHA
    fc98c91 View commit details
  2. Bump clap from 4.5.32 to 4.5.34

    Bumps [clap](https://github.com/clap-rs/clap) from 4.5.32 to 4.5.34.
    - [Release notes](https://github.com/clap-rs/clap/releases)
    - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
    - [Commits](clap-rs/clap@clap_complete-v4.5.32...clap_complete-v4.5.34)
    
    ---
    updated-dependencies:
    - dependency-name: clap
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and dmartin committed Apr 1, 2025
    Copy the full SHA
    a6371bd View commit details

Commits on May 1, 2025

  1. Update dependencies

    dmartin committed May 1, 2025
    Copy the full SHA
    4d87153 View commit details

Commits on May 16, 2025

  1. Add RELEASING.md

    dmartin committed May 16, 2025
    Copy the full SHA
    c715f2d View commit details
  2. Remove self from authors list

    dmartin committed May 16, 2025
    Copy the full SHA
    07a0e54 View commit details
Showing with 332 additions and 235 deletions.
  1. +289 −201 Cargo.lock
  2. +9 −12 Cargo.toml
  3. +12 −0 RELEASING.md
  4. +2 −4 src/lib.rs
  5. +7 −5 src/main.rs
  6. +3 −3 tests/common.rs
  7. +4 −4 tests/containers.rs
  8. +3 −3 tests/networks.rs
  9. +3 −3 tests/volumes.rs
490 changes: 289 additions & 201 deletions Cargo.lock

Large diffs are not rendered by default.

21 changes: 9 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
[package]
authors = [
"Dustin Martin <dustin@dmartin.io>",
"picoCTF Team <opensource@picoctf.org>",
]
authors = ["picoCTF Team <opensource@picoctf.org>"]
description = "Command line tool for removing expired Docker resources"
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
name = "docker-reaper"
repository = "https://github.com/picoCTF/docker-reaper"
version = "1.0.0"
version = "1.1.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.95"
anyhow = "1.0.98"
bollard = { version = "0.18.1", features = ["ssl"] }
chrono = { version = "0.4.39", default-features = false, features = [
chrono = { version = "0.4.41", default-features = false, features = [
"std",
"clock",
] }
clap = { version = "4.5.23", features = ["derive"] }
clap = { version = "4.5.37", features = ["derive"] }
futures = "0.3.31"
go-parse-duration = "0.1.1"
tabled = "0.17.0"
thiserror = "2.0.9"
tokio = { version = "1.42.0", features = ["full"] }
tabled = "0.19.0"
thiserror = "2.0.12"
tokio = { version = "1.44.2", features = ["full"] }
tracing = "0.1.41"
tracing-subscriber = "0.3.19"

12 changes: 12 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Releasing

1. Ensure that [`CHANGELOG.md`](./CHANGELOG.md) is up-to-date with all relevant changes. Additionally, make sure that the version specified in [Cargo.toml](./Cargo.toml) matches the to-be-released version.

1. Create and push a new Git tag for the version with a `v` prefix, e.g.:
```shell
git tag vX.Y.Z
git push --tags
```
This will automatically run the "Publish release" GitHub Actions workflow, which will create a GitHub release, build a release tarball, and attach the tarball to the release.

1. Edit the newly created GitHub release, setting the relevant section of `CHANGELOG.md` as the description.
6 changes: 2 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#[doc(no_inline)]
pub use bollard::Docker;
use bollard::container::{ListContainersOptions, RemoveContainerOptions};
use bollard::network::ListNetworksOptions;
use bollard::service::VolumeListResponse;
use bollard::volume::ListVolumesOptions;
#[doc(no_inline)]
pub use bollard::Docker;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::time::{SystemTime, UNIX_EPOCH};
@@ -111,7 +111,6 @@ impl Filter {
pub enum ResourceType {
Container,
Network,
#[allow(dead_code)]
Volume,
}

@@ -137,7 +136,6 @@ pub struct Resource {
#[tabled(rename = "Resource Type")]
pub resource_type: ResourceType,
#[tabled(skip)]
#[allow(dead_code)]
pub id: String,
pub name: String,
pub status: RemovalStatus,
12 changes: 7 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -4,10 +4,10 @@ use tracing::{debug, error, info, warn};
use anyhow::Context;
use clap::{Args, Parser, Subcommand};
use docker_reaper::{
reap_containers, reap_networks, reap_volumes, Docker, Filter, ReapContainersConfig,
ReapNetworksConfig, ReapVolumesConfig,
Docker, Filter, ReapContainersConfig, ReapNetworksConfig, ReapVolumesConfig, reap_containers,
reap_networks, reap_volumes,
};
use tokio::time::{sleep, Duration};
use tokio::time::{Duration, sleep};

#[derive(Debug, Parser)]
#[command(
@@ -131,7 +131,9 @@ async fn main() -> Result<(), anyhow::Error> {
debug!("Environment variable DOCKER_CERT_PATH set. Connecting via TLS");
Docker::connect_with_ssl_defaults()?
} else if env::var("DOCKER_HOST").is_ok() {
debug!("Environment variable DOCKER_HOST set, but not DOCKER_CERT_PATH. Connecting via HTTP");
debug!(
"Environment variable DOCKER_HOST set, but not DOCKER_CERT_PATH. Connecting via HTTP"
);
Docker::connect_with_http_defaults()?
} else {
debug!("Environment variable DOCKER_HOST not set, connecting to local machine");
@@ -185,8 +187,8 @@ async fn main() -> Result<(), anyhow::Error> {
info!("Found {} matching resources", removed_resources.len());
if !removed_resources.is_empty() {
use tabled::{
settings::{object::Columns, Style, Width},
Table,
settings::{Style, Width, object::Columns},
};
let mut table = Table::new(removed_resources);
info!(
6 changes: 3 additions & 3 deletions tests/common.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
//! Common utility functions for integration tests.
#![allow(dead_code)]

use bollard::Docker;
use bollard::container::{Config, NetworkingConfig};
use bollard::image::CreateImageOptions;
use bollard::network::CreateNetworkOptions;
use bollard::secret::{ContainerCreateResponse, EndpointSettings};
use bollard::volume::CreateVolumeOptions;
use bollard::Docker;
use chrono::Utc;
use docker_reaper::{
reap_containers, reap_networks, reap_volumes, Filter, ReapContainersConfig, ReapNetworksConfig,
ReapVolumesConfig,
Filter, ReapContainersConfig, ReapNetworksConfig, ReapVolumesConfig, reap_containers,
reap_networks, reap_volumes,
};
use std::collections::HashMap;
use std::sync::OnceLock;
8 changes: 4 additions & 4 deletions tests/containers.rs
Original file line number Diff line number Diff line change
@@ -7,14 +7,14 @@ mod common;
use std::collections::HashMap;

use common::{
cleanup, container_exists, docker_client, network_exists, run_container, RunContainerResult,
TEST_LABEL,
RunContainerResult, TEST_LABEL, cleanup, container_exists, docker_client, network_exists,
run_container,
};
use docker_reaper::{
reap_containers, Filter, ReapContainersConfig, RemovalStatus, Resource, ResourceType,
Filter, ReapContainersConfig, RemovalStatus, Resource, ResourceType, reap_containers,
};
use serial_test::serial;
use tokio::time::{sleep, Duration};
use tokio::time::{Duration, sleep};

/// Test that only containers older than the `min_age` threshold are reaped.
#[tokio::test]
6 changes: 3 additions & 3 deletions tests/networks.rs
Original file line number Diff line number Diff line change
@@ -6,12 +6,12 @@ mod common;

use std::collections::HashMap;

use common::{cleanup, create_network, docker_client, network_exists, TEST_LABEL};
use common::{TEST_LABEL, cleanup, create_network, docker_client, network_exists};
use docker_reaper::{
reap_networks, Filter, ReapNetworksConfig, RemovalStatus, Resource, ResourceType,
Filter, ReapNetworksConfig, RemovalStatus, Resource, ResourceType, reap_networks,
};
use serial_test::serial;
use tokio::time::{sleep, Duration};
use tokio::time::{Duration, sleep};

/// Test that only networks older than the `min_age` threshold are reaped.
#[tokio::test]
6 changes: 3 additions & 3 deletions tests/volumes.rs
Original file line number Diff line number Diff line change
@@ -6,12 +6,12 @@ mod common;

use std::collections::HashMap;

use common::{cleanup, create_volume, docker_client, volume_exists, TEST_LABEL};
use common::{TEST_LABEL, cleanup, create_volume, docker_client, volume_exists};
use docker_reaper::{
reap_volumes, Filter, ReapVolumesConfig, RemovalStatus, Resource, ResourceType,
Filter, ReapVolumesConfig, RemovalStatus, Resource, ResourceType, reap_volumes,
};
use serial_test::serial;
use tokio::time::{sleep, Duration};
use tokio::time::{Duration, sleep};

/// Test that only volumes older than the `min_age` threshold are reaped.
#[tokio::test]