summaryrefslogtreecommitdiffstats
path: root/src/builder.rs
diff options
context:
space:
mode:
authorDylan McKay <me@dylanmckay.io>2018-12-22 23:32:19 +1300
committerdoug tangren <d.tangren@gmail.com>2018-12-22 19:32:19 +0900
commit4cb31a38bcaabf255cb779be10bb23e0840460e4 (patch)
treee13a7e9c33d841c50b9a397e4d47db5e67f2530f /src/builder.rs
parent1c2665988c7cb90d77488ea9e1cb3f9bf4fb7bf8 (diff)
Support for setting CPU shares/memory for image builder (#134)
* Support for setting CPU shares/memory for image builder * Support for setting the number of CPU shares allocated to a container
Diffstat (limited to 'src/builder.rs')
-rw-r--r--src/builder.rs29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/builder.rs b/src/builder.rs
index 9aaeb99..fbebeb7 100644
--- a/src/builder.rs
+++ b/src/builder.rs
@@ -220,9 +220,23 @@ impl BuildOptionsBuilder {
self
}
- // todo: memory
+ pub fn memory(
+ &mut self,
+ memory: u64,
+ ) -> &mut Self {
+ self.params.insert("memory", memory.to_string());
+ self
+ }
+
+ pub fn cpu_shares(
+ &mut self,
+ cpu_shares: u32,
+ ) -> &mut Self {
+ self.params.insert("cpushares", cpu_shares.to_string());
+ self
+ }
+
// todo: memswap
- // todo: cpushares
// todo: cpusetcpus
// todo: cpuperiod
// todo: cpuquota
@@ -481,6 +495,17 @@ impl ContainerOptionsBuilder {
self
}
+ /// Sets an integer value representing the container's
+ /// relative CPU weight versus other containers.
+ pub fn cpu_shares(
+ &mut self,
+ cpu_shares: u32,
+ ) -> &mut Self {
+ self.params
+ .insert("HostConfig.CpuShares", json!(cpu_shares));
+ self
+ }
+
pub fn labels(
&mut self,
labels: &HashMap<&str, &str>,