summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordoug tangren <d.tangren@gmail.com>2018-10-13 21:13:51 -0400
committerGitHub <noreply@github.com>2018-10-13 21:13:51 -0400
commit4dacec4f02098aa92529a8ab168a3b681d385ace (patch)
treebd468ec3b9d3cf31a7243dd5172ae350bd4c7025 /src
parent762468344db4d7ab9e1aa077a769092f384a19a2 (diff)
remove pub builder constructors (#125)
Diffstat (limited to 'src')
-rw-r--r--src/builder.rs165
1 files changed, 61 insertions, 104 deletions
diff --git a/src/builder.rs b/src/builder.rs
index 45eeb0f..ba300af 100644
--- a/src/builder.rs
+++ b/src/builder.rs
@@ -24,7 +24,7 @@ pub struct PullOptions {
impl PullOptions {
/// return a new instance of a builder for options
pub fn builder() -> PullOptionsBuilder {
- PullOptionsBuilder::new()
+ PullOptionsBuilder::default()
}
/// serialize options as a string. returns None if no options are defined
@@ -47,16 +47,10 @@ pub struct PullOptionsBuilder {
}
impl PullOptionsBuilder {
- pub fn new() -> PullOptionsBuilder {
- PullOptionsBuilder {
- ..Default::default()
- }
- }
-
pub fn image<I>(
&mut self,
img: I,
- ) -> &mut PullOptionsBuilder
+ ) -> &mut Self
where
I: Into<String>,
{
@@ -67,7 +61,7 @@ impl PullOptionsBuilder {
pub fn src<S>(
&mut self,
s: S,
- ) -> &mut PullOptionsBuilder
+ ) -> &mut Self
where
S: Into<String>,
{
@@ -78,7 +72,7 @@ impl PullOptionsBuilder {
pub fn repo<R>(
&mut self,
r: R,
- ) -> &mut PullOptionsBuilder
+ ) -> &mut Self
where
R: Into<String>,
{
@@ -89,7 +83,7 @@ impl PullOptionsBuilder {
pub fn tag<T>(
&mut self,
t: T,
- ) -> &mut PullOptionsBuilder
+ ) -> &mut Self
where
T: Into<String>,
{
@@ -144,7 +138,7 @@ pub struct BuildOptionsBuilder {
impl BuildOptionsBuilder {
/// path is expected to be a file path to a directory containing a Dockerfile
/// describing how to build a Docker image
- pub fn new<S>(path: S) -> BuildOptionsBuilder
+ pub(crate) fn new<S>(path: S) -> Self
where
S: Into<String>,
{
@@ -158,7 +152,7 @@ impl BuildOptionsBuilder {
pub fn dockerfile<P>(
&mut self,
path: P,
- ) -> &mut BuildOptionsBuilder
+ ) -> &mut Self
where
P: Into<String>,
{
@@ -170,7 +164,7 @@ impl BuildOptionsBuilder {
pub fn tag<T>(
&mut self,
t: T,
- ) -> &mut BuildOptionsBuilder
+ ) -> &mut Self
where
T: Into<String>,
{
@@ -181,7 +175,7 @@ impl BuildOptionsBuilder {
pub fn remote<R>(
&mut self,
r: R,
- ) -> &mut BuildOptionsBuilder
+ ) -> &mut Self
where
R: Into<String>,
{
@@ -193,7 +187,7 @@ impl BuildOptionsBuilder {
pub fn nocache<R>(
&mut self,
nc: bool,
- ) -> &mut BuildOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("nocache", nc.to_string());
self
}
@@ -201,7 +195,7 @@ impl BuildOptionsBuilder {
pub fn rm(
&mut self,
r: bool,
- ) -> &mut BuildOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("rm", r.to_string());
self
}
@@ -209,7 +203,7 @@ impl BuildOptionsBuilder {
pub fn forcerm(
&mut self,
fr: bool,
- ) -> &mut BuildOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("forcerm", fr.to_string());
self
}
@@ -218,7 +212,7 @@ impl BuildOptionsBuilder {
pub fn network_mode<T>(
&mut self,
t: T,
- ) -> &mut BuildOptionsBuilder
+ ) -> &mut Self
where
T: Into<String>,
{
@@ -251,7 +245,7 @@ pub struct ContainerListOptions {
impl ContainerListOptions {
/// return a new instance of a builder for options
pub fn builder() -> ContainerListOptionsBuilder {
- ContainerListOptionsBuilder::new()
+ ContainerListOptionsBuilder::default()
}
/// serialize options as a string. returns None if no options are defined
@@ -283,16 +277,10 @@ pub struct ContainerListOptionsBuilder {
}
impl ContainerListOptionsBuilder {
- pub fn new() -> ContainerListOptionsBuilder {
- ContainerListOptionsBuilder {
- ..Default::default()
- }
- }
-
pub fn filter(
&mut self,
filters: Vec<ContainerFilter>,
- ) -> &mut ContainerListOptionsBuilder {
+ ) -> &mut Self {
let mut param = HashMap::new();
for f in filters {
match f {
@@ -309,7 +297,7 @@ impl ContainerListOptionsBuilder {
self
}
- pub fn all(&mut self) -> &mut ContainerListOptionsBuilder {
+ pub fn all(&mut self) -> &mut Self {
self.params.insert("all", "true".to_owned());
self
}
@@ -317,7 +305,7 @@ impl ContainerListOptionsBuilder {
pub fn since(
&mut self,
since: &str,
- ) -> &mut ContainerListOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("since", since.to_owned());
self
}
@@ -325,12 +313,12 @@ impl ContainerListOptionsBuilder {
pub fn before(
&mut self,
before: &str,
- ) -> &mut ContainerListOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("before", before.to_owned());
self
}
- pub fn sized(&mut self) -> &mut ContainerListOptionsBuilder {
+ pub fn sized(&mut self) -> &mut Self {
self.params.insert("size", "true".to_owned());
self
}
@@ -427,7 +415,7 @@ pub struct ContainerOptionsBuilder {
}
impl ContainerOptionsBuilder {
- pub fn new(image: &str) -> ContainerOptionsBuilder {
+ pub(crate) fn new(image: &str) -> Self {
let mut params = HashMap::new();
let params_list = HashMap::new();
let params_hash = HashMap::new();
@@ -444,7 +432,7 @@ impl ContainerOptionsBuilder {
pub fn name(
&mut self,
name: &str,
- ) -> &mut ContainerOptionsBuilder {
+ ) -> &mut Self {
self.name = Some(name.to_owned());
self
}
@@ -452,7 +440,7 @@ impl ContainerOptionsBuilder {
pub fn volumes(
&mut self,
volumes: Vec<&str>,
- ) -> &mut ContainerOptionsBuilder {
+ ) -> &mut Self {
for v in volumes {
self.params_list
.entry("HostConfig.Binds")
@@ -465,7 +453,7 @@ impl ContainerOptionsBuilder {
pub fn links(
&mut self,
links: Vec<&str>,
- ) -> &mut ContainerOptionsBuilder {
+ ) -> &mut Self {
for link in links {
self.params_list
.entry("HostConfig.Links")
@@ -478,7 +466,7 @@ impl ContainerOptionsBuilder {
pub fn memory(
&mut self,
memory: u64,
- ) -> &mut ContainerOptionsBuilder {
+ ) -> &mut Self {
self.params
.insert("HostConfig.Memory", Value::Number(Number::from(memory)));
self
@@ -487,7 +475,7 @@ impl ContainerOptionsBuilder {
pub fn labels(
&mut self,
labels: &HashMap<&str, &str>,
- ) -> &mut ContainerOptionsBuilder {
+ ) -> &mut Self {
let mut json_labels = Map::new();
for (k, v) in labels {
json_labels.insert(k.to_string(), Value::String(v.to_string()));
@@ -501,7 +489,7 @@ impl ContainerOptionsBuilder {
pub fn extra_hosts(
&mut self,
hosts: Vec<&str>,
- ) -> &mut ContainerOptionsBuilder {
+ ) -> &mut Self {
for host in hosts {
self.params_list
.entry("HostConfig.ExtraHosts")
@@ -515,7 +503,7 @@ impl ContainerOptionsBuilder {
pub fn volumes_from(
&mut self,
volumes: Vec<&str>,
- ) -> &mut ContainerOptionsBuilder {
+ ) -> &mut Self {
for volume in volumes {
self.params_list
.entry("HostConfig.VolumesFrom")
@@ -528,7 +516,7 @@ impl ContainerOptionsBuilder {
pub fn network_mode(
&mut self,
network: &str,
- ) -> &mut ContainerOptionsBuilder {
+ ) -> &mut Self {
if !network.is_empty() {
self.params
.insert("HostConfig.NetworkMode", Value::String(network.to_owned()));
@@ -539,7 +527,7 @@ impl ContainerOptionsBuilder {
pub fn env(
&mut self,
envs: Vec<&str>,
- ) -> &mut ContainerOptionsBuilder {
+ ) -> &mut Self {
for env in envs {
self.params_list
.entry("Env")
@@ -552,7 +540,7 @@ impl ContainerOptionsBuilder {
pub fn cmd(
&mut self,
cmds: Vec<&str>,
- ) -> &mut ContainerOptionsBuilder {
+ ) -> &mut Self {
for cmd in cmds {
self.params_list
.entry("Cmd")
@@ -565,7 +553,7 @@ impl ContainerOptionsBuilder {
pub fn entrypoint(
&mut self,
entrypoint: &str,
- ) -> &mut ContainerOptionsBuilder {
+ ) -> &mut Self {
if !entrypoint.is_empty() {
self.params
.insert("Entrypoint", Value::String(entrypoint.to_owned()));
@@ -576,7 +564,7 @@ impl ContainerOptionsBuilder {
pub fn capabilities(
&mut self,
capabilities: Vec<&str>,
- ) -> &mut ContainerOptionsBuilder {
+ ) -> &mut Self {
for c in capabilities {
self.params_list
.entry("HostConfig.CapAdd")
@@ -589,7 +577,7 @@ impl ContainerOptionsBuilder {
pub fn devices(
&mut self,
devices: Vec<HashMap<String, String>>,
- ) -> &mut ContainerOptionsBuilder {
+ ) -> &mut Self {
for d in devices {
self.params_hash
.entry("HostConfig.Devices".to_string())
@@ -602,7 +590,7 @@ impl ContainerOptionsBuilder {
pub fn log_driver(
&mut self,
log_driver: &str,
- ) -> &mut ContainerOptionsBuilder {
+ ) -> &mut Self {
if !log_driver.is_empty() {
self.params.insert(
"HostConfig.LogConfig.Type",
@@ -616,7 +604,7 @@ impl ContainerOptionsBuilder {
&mut self,
name: &str,
maximum_retry_count: u64,
- ) -> &mut ContainerOptionsBuilder {
+ ) -> &mut Self {
if !name.is_empty() {
self.params.insert(
"HostConfig.RestartPolicy.Name",
@@ -651,7 +639,7 @@ pub struct ExecContainerOptions {
impl ExecContainerOptions {
/// return a new instance of a builder for options
pub fn builder() -> ExecContainerOptionsBuilder {
- ExecContainerOptionsBuilder::new()
+ ExecContainerOptionsBuilder::default()
}
/// serialize options as a string. returns None if no options are defined
@@ -667,18 +655,11 @@ pub struct ExecContainerOptionsBuilder {
}
impl ExecContainerOptionsBuilder {
- pub fn new() -> ExecContainerOptionsBuilder {
- ExecContainerOptionsBuilder {
- params: HashMap::new(),
- params_bool: HashMap::new(),
- }
- }
-
/// Command to run, as an array of strings
pub fn cmd(
&mut self,
cmds: Vec<&str>,
- ) -> &mut ExecContainerOptionsBuilder {
+ ) -> &mut Self {
for cmd in cmds {
self.params
.entry("Cmd")
@@ -692,7 +673,7 @@ impl ExecContainerOptionsBuilder {
pub fn env(
&mut self,
envs: Vec<&str>,
- ) -> &mut ExecContainerOptionsBuilder {
+ ) -> &mut Self {
for env in envs {
self.params
.entry("Env")
@@ -706,7 +687,7 @@ impl ExecContainerOptionsBuilder {
pub fn attach_stdout(
&mut self,
stdout: bool,
- ) -> &mut ExecContainerOptionsBuilder {
+ ) -> &mut Self {
self.params_bool.insert("AttachStdout", stdout);
self
}
@@ -715,7 +696,7 @@ impl ExecContainerOptionsBuilder {
pub fn attach_stderr(
&mut self,
stderr: bool,
- ) -> &mut ExecContainerOptionsBuilder {
+ ) -> &mut Self {
self.params_bool.insert("AttachStderr", stderr);
self
}
@@ -736,7 +717,7 @@ pub struct EventsOptions {
impl EventsOptions {
pub fn builder() -> EventsOptionsBuilder {
- EventsOptionsBuilder::new()
+ EventsOptionsBuilder::default()
}
/// serialize options as a string. returns None if no options are defined
@@ -799,17 +780,11 @@ pub struct EventsOptionsBuilder {
}
impl EventsOptionsBuilder {
- pub fn new() -> EventsOptionsBuilder {
- EventsOptionsBuilder {
- ..Default::default()
- }
- }
-
/// Filter events since a given timestamp
pub fn since(
&mut self,
ts: &u64,
- ) -> &mut EventsOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("since", ts.to_string());
self
}
@@ -818,7 +793,7 @@ impl EventsOptionsBuilder {
pub fn until(
&mut self,
ts: &u64,
- ) -> &mut EventsOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("until", ts.to_string());
self
}
@@ -826,7 +801,7 @@ impl EventsOptionsBuilder {
pub fn filter(
&mut self,
filters: Vec<EventFilter>,
- ) -> &mut EventsOptionsBuilder {
+ ) -> &mut Self {
let mut params = HashMap::new();
for f in filters {
match f {
@@ -886,7 +861,7 @@ pub struct LogsOptions {
impl LogsOptions {
/// return a new instance of a builder for options
pub fn builder() -> LogsOptionsBuilder {
- LogsOptionsBuilder::new()
+ LogsOptionsBuilder::default()
}
/// serialize options as a string. returns None if no options are defined
@@ -910,16 +885,10 @@ pub struct LogsOptionsBuilder {
}
impl LogsOptionsBuilder {
- pub fn new() -> LogsOptionsBuilder {
- LogsOptionsBuilder {
- ..Default::default()
- }
- }
-
pub fn follow(
&mut self,
f: bool,
- ) -> &mut LogsOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("follow", f.to_string());
self
}
@@ -927,7 +896,7 @@ impl LogsOptionsBuilder {
pub fn stdout(
&mut self,
s: bool,
- ) -> &mut LogsOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("stdout", s.to_string());
self
}
@@ -935,7 +904,7 @@ impl LogsOptionsBuilder {
pub fn stderr(
&mut self,
s: bool,
- ) -> &mut LogsOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("stderr", s.to_string());
self
}
@@ -943,7 +912,7 @@ impl LogsOptionsBuilder {
pub fn timestamps(
&mut self,
t: bool,
- ) -> &mut LogsOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("timestamps", t.to_string());
self
}
@@ -952,7 +921,7 @@ impl LogsOptionsBuilder {
pub fn tail(
&mut self,
how_many: &str,
- ) -> &mut LogsOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("tail", how_many.to_owned());
self
}
@@ -979,7 +948,7 @@ pub struct ImageListOptions {
impl ImageListOptions {
pub fn builder() -> ImageListOptionsBuilder {
- ImageListOptionsBuilder::new()
+ ImageListOptionsBuilder::default()
}
pub fn serialize(&self) -> Option<String> {
if self.params.is_empty() {
@@ -1001,16 +970,10 @@ pub struct ImageListOptionsBuilder {
}
impl ImageListOptionsBuilder {
- pub fn new() -> ImageListOptionsBuilder {
- ImageListOptionsBuilder {
- ..Default::default()
- }
- }
-
pub fn digests(
&mut self,
d: bool,
- ) -> &mut ImageListOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("digests", d.to_string());
self
}
@@ -1018,7 +981,7 @@ impl ImageListOptionsBuilder {
pub fn all(
&mut self,
a: bool,
- ) -> &mut ImageListOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("all", a.to_string());
self
}
@@ -1026,7 +989,7 @@ impl ImageListOptionsBuilder {
pub fn filter_name(
&mut self,
name: &str,
- ) -> &mut ImageListOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("filter", name.to_owned());
self
}
@@ -1034,7 +997,7 @@ impl ImageListOptionsBuilder {
pub fn filter(
&mut self,
filters: Vec<ImageFilter>,
- ) -> &mut ImageListOptionsBuilder {
+ ) -> &mut Self {
let mut param = HashMap::new();
for f in filters {
match f {
@@ -1066,7 +1029,7 @@ pub struct RmContainerOptions {
impl RmContainerOptions {
/// return a new instance of a builder for options
pub fn builder() -> RmContainerOptionsBuilder {
- RmContainerOptionsBuilder::new()
+ RmContainerOptionsBuilder::default()
}
/// serialize options as a string. returns None if no options are defined
@@ -1090,16 +1053,10 @@ pub struct RmContainerOptionsBuilder {
}
impl RmContainerOptionsBuilder {
- pub fn new() -> RmContainerOptionsBuilder {
- RmContainerOptionsBuilder {
- ..Default::default()
- }
- }
-
pub fn force(
&mut self,
f: bool,
- ) -> &mut RmContainerOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("force", f.to_string());
self
}
@@ -1107,7 +1064,7 @@ impl RmContainerOptionsBuilder {
pub fn volumes(
&mut self,
s: bool,
- ) -> &mut RmContainerOptionsBuilder {
+ ) -> &mut Self {
self.params.insert("v", s.to_string());
self
}
@@ -1185,7 +1142,7 @@ pub struct NetworkCreateOptionsBuilder {
}
impl NetworkCreateOptionsBuilder {
- pub fn new(name: &str) -> NetworkCreateOptionsBuilder {
+ pub(crate) fn new(name: &str) -> Self {
let mut params = HashMap::new();
let params_hash = HashMap::new();
@@ -1200,7 +1157,7 @@ impl NetworkCreateOptionsBuilder {
pub fn driver(
&mut self,
name: &str,
- ) -> &mut NetworkCreateOptionsBuilder {
+ ) -> &mut Self {
if !name.is_empty() {
self.params.insert("Driver", name.to_owned());
}
@@ -1210,7 +1167,7 @@ impl NetworkCreateOptionsBuilder {
pub fn label(
&mut self,
labels: Vec<HashMap<String, String>>,
- ) -> &mut NetworkCreateOptionsBuilder {
+ ) -> &mut Self {
for l in labels {
self.params_hash
.entry("Labels".to_string())