Skip to content
Merged
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
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ jobs:
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest'
run: cargo fmt -- --check

- name: Check for executor.execute_command antipattern
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest'
run: |
# Commands should use self.execute_command(args) not self.executor.execute_command("docker", args)
# The latter causes "docker docker <cmd>" double-command bug
if grep -r 'executor\.execute_command("docker"' src/command/; then
echo "ERROR: Found executor.execute_command(\"docker\", ...) antipattern!"
echo "Use self.execute_command(args) instead to avoid 'docker docker' bug."
exit 1
fi

- name: Run Clippy
if: matrix.rust == 'stable'
run: cargo clippy --all-targets --all-features -- -D warnings
Expand Down
4 changes: 2 additions & 2 deletions src/command/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ impl BuildCommand {
&self.executor
}

/// Get a mutable reference to the command executor
/// Get a mutable reference to the command executor
#[must_use]
pub fn get_executor_mut(&mut self) -> &mut CommandExecutor {
&mut self.executor
Expand Down Expand Up @@ -1322,7 +1322,7 @@ impl DockerCommand for BuildCommand {

async fn execute(&self) -> Result<Self::Output> {
let args = self.build_command_args();
let output = self.executor.execute_command("docker", args).await?;
let output = self.execute_command(args).await?;

// Extract image ID from output
let image_id = if self.quiet {
Expand Down
2 changes: 1 addition & 1 deletion src/command/builder/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl DockerCommand for BuilderBuildCommand {
async fn execute(&self) -> Result<Self::Output> {
// The builder build command has the same output as regular build
let args = self.build_command_args();
let output = self.inner.executor.execute_command("docker", args).await?;
let output = self.execute_command(args).await?;

// Extract image ID from output
let image_id = extract_image_id(&output.stdout);
Expand Down
2 changes: 1 addition & 1 deletion src/command/builder/prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl DockerCommand for BuilderPruneCommand {

async fn execute(&self) -> Result<Self::Output> {
let args = self.build_command_args();
let output = self.executor.execute_command("docker", args).await?;
let output = self.execute_command(args).await?;

let (deleted_cache_ids, space_reclaimed, space_reclaimed_str) =
Self::parse_output(&output.stdout);
Expand Down
2 changes: 1 addition & 1 deletion src/command/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ impl DockerCommand for ImagesCommand {

async fn execute(&self) -> Result<Self::Output> {
let args = self.build_command_args();
let output = self.executor.execute_command("docker", args).await?;
let output = self.execute_command(args).await?;

let images = self.parse_output(&output);

Expand Down
2 changes: 1 addition & 1 deletion src/command/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl DockerCommand for LoginCommand {

async fn execute(&self) -> Result<Self::Output> {
let args = self.build_command_args();
let output = self.executor.execute_command("docker", args).await?;
let output = self.execute_command(args).await?;

Ok(LoginOutput { output })
}
Expand Down
2 changes: 1 addition & 1 deletion src/command/logout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl DockerCommand for LogoutCommand {

async fn execute(&self) -> Result<Self::Output> {
let args = self.build_command_args();
let output = self.executor.execute_command("docker", args).await?;
let output = self.execute_command(args).await?;

Ok(LogoutOutput { output })
}
Expand Down
2 changes: 1 addition & 1 deletion src/command/pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ impl DockerCommand for PullCommand {

async fn execute(&self) -> Result<Self::Output> {
let args = self.build_command_args();
self.executor.execute_command("docker", args).await
self.execute_command(args).await
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/command/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ impl DockerCommand for PushCommand {

async fn execute(&self) -> Result<Self::Output> {
let args = self.build_command_args();
self.executor.execute_command("docker", args).await
self.execute_command(args).await
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/command/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ impl DockerCommand for SearchCommand {

async fn execute(&self) -> Result<Self::Output> {
let args = self.build_command_args();
let output = self.executor.execute_command("docker", args).await?;
let output = self.execute_command(args).await?;

let repositories = self.parse_output(&output)?;

Expand Down
2 changes: 1 addition & 1 deletion src/command/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl DockerCommand for TagCommand {

async fn execute(&self) -> Result<Self::Output> {
let args = self.build_command_args();
self.executor.execute_command("docker", args).await
self.execute_command(args).await
}
}

Expand Down
30 changes: 14 additions & 16 deletions tests/lifecycle_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ async fn test_container_pause_unpause() {
let _ = StartCommand::new(&container_name).execute().await;

// Pause the container
let pause_result = PauseCommand::new(&container_name).execute().await;
if pause_result.is_ok() {
assert!(!pause_result.unwrap().stdout.is_empty());
if let Ok(pause_output) = PauseCommand::new(&container_name).execute().await {
assert!(!pause_output.stdout.is_empty());

// Unpause the container
let unpause_result = UnpauseCommand::new(&container_name)
Expand Down Expand Up @@ -100,8 +99,8 @@ async fn test_container_restart() {
.execute()
.await;

if restart_result.is_ok() {
assert!(!restart_result.unwrap().stdout.is_empty());
if let Ok(restart_output) = restart_result {
assert!(!restart_output.stdout.is_empty());
}

// Clean up
Expand All @@ -125,8 +124,8 @@ async fn test_container_rename() {
// Rename the container
let rename_result = RenameCommand::new(&old_name, &new_name).execute().await;

if rename_result.is_ok() {
assert!(!rename_result.unwrap().stderr.contains("Error"));
if let Ok(rename_output) = rename_result {
assert!(!rename_output.stderr.contains("Error"));
// Clean up with new name
let _ = RmCommand::new(&new_name).force().execute().await;
} else {
Expand Down Expand Up @@ -156,8 +155,8 @@ async fn test_container_kill() {
.execute()
.await;

if kill_result.is_ok() {
assert!(!kill_result.unwrap().stdout.is_empty());
if let Ok(kill_output) = kill_result {
assert!(!kill_output.stdout.is_empty());
}

// Clean up
Expand All @@ -184,8 +183,8 @@ async fn test_container_update() {
.execute()
.await;

if update_result.is_ok() {
assert!(!update_result.unwrap().stdout.is_empty());
if let Ok(update_output) = update_result {
assert!(!update_output.stdout.is_empty());
}

// Clean up
Expand All @@ -210,10 +209,9 @@ async fn test_container_wait() {
// Wait for container to exit
let wait_result = WaitCommand::new(&container_name).execute().await;

if wait_result.is_ok() {
let output = wait_result.unwrap();
if let Ok(wait_output) = wait_result {
// The output should contain the exit code (0)
assert!(output.stdout.contains("0"));
assert!(wait_output.stdout.contains("0"));
}

// Clean up
Expand Down Expand Up @@ -243,8 +241,8 @@ async fn test_container_commit() {
.execute()
.await;

if commit_result.is_ok() {
assert!(!commit_result.unwrap().stdout.is_empty());
if let Ok(commit_output) = commit_result {
assert!(!commit_output.stdout.is_empty());

// Clean up the image
let _ = docker_wrapper::RmiCommand::new(format!("{}:latest", image_name))
Expand Down