Skip to content

Commit aad5f40

Browse files
committed
feat: awkward builders
1 parent 7f9b189 commit aad5f40

35 files changed

Lines changed: 195 additions & 188 deletions

src/command/attach.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use async_trait::async_trait;
1010
///
1111
/// Attach local standard input, output, and error streams to a running container.
1212
///
13-
/// # Example
13+
/// # Examples
1414
///
1515
/// ```no_run
1616
/// use docker_wrapper::AttachCommand;
@@ -46,7 +46,7 @@ pub struct AttachCommand {
4646
impl AttachCommand {
4747
/// Create a new attach command
4848
///
49-
/// # Example
49+
/// # Examples
5050
///
5151
/// ```
5252
/// use docker_wrapper::AttachCommand;
@@ -66,7 +66,7 @@ impl AttachCommand {
6666

6767
/// Override the key sequence for detaching a container
6868
///
69-
/// # Example
69+
/// # Examples
7070
///
7171
/// ```
7272
/// use docker_wrapper::AttachCommand;
@@ -82,7 +82,7 @@ impl AttachCommand {
8282

8383
/// Do not attach STDIN
8484
///
85-
/// # Example
85+
/// # Examples
8686
///
8787
/// ```
8888
/// use docker_wrapper::AttachCommand;
@@ -98,7 +98,7 @@ impl AttachCommand {
9898

9999
/// Do not proxy signals
100100
///
101-
/// # Example
101+
/// # Examples
102102
///
103103
/// ```
104104
/// use docker_wrapper::AttachCommand;
@@ -120,7 +120,7 @@ impl AttachCommand {
120120
/// - The container doesn't exist
121121
/// - The container is not running
122122
///
123-
/// # Example
123+
/// # Examples
124124
///
125125
/// ```no_run
126126
/// use docker_wrapper::AttachCommand;

src/command/builder/build.rs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use async_trait::async_trait;
1212
/// This is essentially the same as `docker build` but accessed through
1313
/// the builder subcommand interface.
1414
///
15-
/// # Example
15+
/// # Examples
1616
///
1717
/// ```no_run
1818
/// use docker_wrapper::command::builder::BuilderBuildCommand;
@@ -33,64 +33,65 @@ use async_trait::async_trait;
3333
/// ```
3434
#[derive(Debug, Clone)]
3535
pub struct BuilderBuildCommand {
36-
/// Underlying build command
36+
/// Underlying build command.
3737
inner: BuildCommand,
3838
}
3939

4040
impl BuilderBuildCommand {
41-
/// Create a new builder build command
41+
/// Creates a new builder build command.
4242
///
4343
/// # Arguments
44-
/// * `context` - Build context path (e.g., ".", "/path/to/dir")
44+
///
45+
/// * `context` - Build context path (e.g., `.`, `/path/to/dir`).
4546
pub fn new(context: impl Into<String>) -> Self {
4647
Self {
4748
inner: BuildCommand::new(context),
4849
}
4950
}
5051

51-
/// Set the Dockerfile to use
52+
/// Sets the Dockerfile to use.
5253
#[must_use]
5354
pub fn dockerfile(mut self, path: impl Into<String>) -> Self {
5455
self.inner = self.inner.file(path.into());
5556
self
5657
}
5758

58-
/// Tag the image
59+
/// Tags the image.
5960
#[must_use]
6061
pub fn tag(mut self, tag: impl Into<String>) -> Self {
6162
self.inner = self.inner.tag(tag);
6263
self
6364
}
6465

65-
/// Do not use cache when building
66+
/// Do not use cache when building.
6667
#[must_use]
6768
pub fn no_cache(mut self) -> Self {
6869
self.inner = self.inner.no_cache();
6970
self
7071
}
7172

72-
/// Set build-time variables
73+
/// Sets build-time variables.
7374
#[must_use]
7475
pub fn build_arg(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
7576
self.inner = self.inner.build_arg(key, value);
7677
self
7778
}
7879

79-
/// Set target build stage
80+
/// Sets target build stage.
8081
#[must_use]
8182
pub fn target(mut self, target: impl Into<String>) -> Self {
8283
self.inner = self.inner.target(target);
8384
self
8485
}
8586

86-
/// Set platform for multi-platform builds
87+
/// Sets platform for multi-platform builds.
8788
#[must_use]
8889
pub fn platform(mut self, platform: impl Into<String>) -> Self {
8990
self.inner = self.inner.platform(platform);
9091
self
9192
}
9293

93-
/// Enable `BuildKit` backend
94+
/// Enables `BuildKit` backend.
9495
#[must_use]
9596
pub fn buildkit(mut self) -> Self {
9697
// This would normally set DOCKER_BUILDKIT=1 environment variable
@@ -102,35 +103,35 @@ impl BuilderBuildCommand {
102103
self
103104
}
104105

105-
/// Enable quiet mode
106+
/// Enables quiet mode.
106107
#[must_use]
107108
pub fn quiet(mut self) -> Self {
108109
self.inner = self.inner.quiet();
109110
self
110111
}
111112

112-
/// Always remove intermediate containers
113+
/// Always removes intermediate containers.
113114
#[must_use]
114115
pub fn force_rm(mut self) -> Self {
115116
self.inner = self.inner.force_rm();
116117
self
117118
}
118119

119-
/// Remove intermediate containers after successful build (default)
120+
/// Removes intermediate containers after successful build (default).
120121
#[must_use]
121122
pub fn rm(self) -> Self {
122123
// rm is the default behavior, this is a no-op
123124
self
124125
}
125126

126-
/// Do not remove intermediate containers after build
127+
/// Does not remove intermediate containers after build.
127128
#[must_use]
128129
pub fn no_rm(mut self) -> Self {
129130
self.inner = self.inner.no_rm();
130131
self
131132
}
132133

133-
/// Always attempt to pull newer version of base image
134+
/// Always attempts to pull newer version of base image.
134135
#[must_use]
135136
pub fn pull(mut self) -> Self {
136137
self.inner = self.inner.pull();
@@ -142,7 +143,7 @@ impl BuilderBuildCommand {
142143
impl DockerCommand for BuilderBuildCommand {
143144
type Output = BuildOutput;
144145

145-
fn command_name() -> &str {
146+
fn command_name() -> &'static str {
146147
"builder build"
147148
}
148149

@@ -155,15 +156,15 @@ impl DockerCommand for BuilderBuildCommand {
155156
}
156157

157158
fn build_command_args(&self) -> Vec<String> {
158-
self.inner.build_command_args();
159+
self.inner.build_command_args()
159160
}
160161

161162
async fn execute(&self) -> Result<Self::Output> {
162-
// The builder build command has the same output as regular build
163+
// the builder build command has the same output as regular build
163164
let args = self.build_command_args();
164165
let output = self.inner.executor.execute_command("docker", args).await?;
165166

166-
// Extract image ID from output
167+
// extract image ID from output
167168
let image_id = extract_image_id(&output.stdout);
168169

169170
Ok(BuildOutput {
@@ -175,9 +176,9 @@ impl DockerCommand for BuilderBuildCommand {
175176
}
176177
}
177178

178-
/// Extract image ID from build output
179+
/// Extracts image ID from build output.
179180
fn extract_image_id(stdout: &str) -> Option<String> {
180-
// Look for "Successfully built <id>" or "writing image sha256:<id>"
181+
// look for "Successfully built <id>" or "writing image sha256:<id>"
181182
for line in stdout.lines().rev() {
182183
if line.contains("Successfully built") {
183184
return line.split_whitespace().last().map(String::from);

src/command/builder/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Docker builder commands for build cache management
1+
//! Docker builder commands for build cache management.
22
//!
33
//! This module provides support for Docker builder commands that manage
44
//! the build subsystem and build cache.

0 commit comments

Comments
 (0)