moby-derp 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 290a7b49ad9be080d13d38d95afb6f0ec3a242f18195538eb4c38ea236b7d52e
4
- data.tar.gz: 30663c89f116294188131c481854c2a97b2aa4827792ab11944e2ba9ae2bd552
3
+ metadata.gz: b4872cf7a3115e157c1cd297c180db60444a7b46064e6192564ba9d89f3477d9
4
+ data.tar.gz: 216b70b7af5e4a9e695dfcb3a668bc1fa3483ebed98ed010783977db4e20972b
5
5
  SHA512:
6
- metadata.gz: 276f7e10f3e8c08bad227a44980f966d26ac176d63d970df0adcd6f853323128d3144cd5e2cff381334a55754b4badcb1224ec5691b743b3619f6a08957e111d
7
- data.tar.gz: 7c30674a604b9470ed09b552501cb099b0941fee066770580924cc2f9a597cd25e1470907d2589d9515d8e2c925ca61c6a210722766279554478dd39065eb415
6
+ metadata.gz: dd9a21877adc23193d59050030abd4257d83a3de86ba5c8e722ea5fd772583f142ac4a9cc381c8c1acbc93152506dceb3fa3f63889c9fcd0a9b9d3c08dc38718
7
+ data.tar.gz: 45cc46def1400c188fbf12b2d5ab0ff3e584d16ee3d9c83875dfd231b5f10bfe30813ce015533aa19a68aae479421208e470a5b98713bc1a1832692c96426741
@@ -122,6 +122,13 @@ containers:
122
122
  #
123
123
  stop_timeout: 42
124
124
 
125
+ # The default user under which commands in the container should be run.
126
+ # Can be `<user>`, `<user>:<group>`, or even `:<group>`, and the user
127
+ # and group can either be a name (which must exist in the *container's*
128
+ # `/etc/passwd` / `/etc/group` file), or a numeric ID.
129
+ #
130
+ user: fred:flintstone
131
+
125
132
  # Adjust the container's restart policy.
126
133
  #
127
134
  restart: on-failure:42
@@ -92,6 +92,10 @@ module MobyDerp
92
92
  params["StopSignal"] = @config.stop_signal
93
93
  params["StopTimeout"] = @config.stop_timeout
94
94
 
95
+ if @config.user
96
+ params["User"] = @config.user
97
+ end
98
+
95
99
  if @config.readonly
96
100
  params["HostConfig"]["ReadonlyRootfs"] = true
97
101
  end
@@ -7,7 +7,7 @@ require "docker-api"
7
7
  module MobyDerp
8
8
  class ContainerConfig
9
9
  attr_reader :name, :image, :update_image, :command, :environment, :mounts,
10
- :labels, :readonly, :stop_signal, :stop_timeout, :restart, :limits
10
+ :labels, :readonly, :stop_signal, :stop_timeout, :user, :restart, :limits
11
11
 
12
12
  def initialize(system_config:,
13
13
  pod_config:,
@@ -21,13 +21,14 @@ module MobyDerp
21
21
  readonly: false,
22
22
  stop_signal: "SIGTERM",
23
23
  stop_timeout: 10,
24
+ user: nil,
24
25
  restart: "no",
25
26
  limits: {}
26
27
  )
27
28
  @system_config, @pod_config, @name, @image = system_config, pod_config, "#{pod_config.name}.#{container_name}", image
28
29
 
29
30
  @update_image, @command, @environment, @mounts, @labels = update_image, command, environment, mounts, labels
30
- @readonly, @stop_signal, @stop_timeout, @restart = readonly, stop_signal, stop_timeout, restart
31
+ @readonly, @stop_signal, @stop_timeout, @user, @restart = readonly, stop_signal, stop_timeout, user, restart
31
32
  @limits = limits
32
33
 
33
34
  validate_image
@@ -39,6 +40,7 @@ module MobyDerp
39
40
  validate_readonly
40
41
  validate_stop_signal
41
42
  validate_stop_timeout
43
+ validate_user
42
44
  validate_restart
43
45
  validate_limits
44
46
  end
@@ -149,6 +151,15 @@ module MobyDerp
149
151
  end
150
152
  end
151
153
 
154
+ def validate_user
155
+ return if @user.nil?
156
+
157
+ unless @user =~ /\A([a-zA-Z0-9_-]+)?(:[a-zA-Z0-9_-]+)?\z/
158
+ raise ConfigurationError,
159
+ "invalid user specification"
160
+ end
161
+ end
162
+
152
163
  def validate_restart
153
164
  unless @restart.is_a?(String)
154
165
  raise ConfigurationError,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moby-derp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Palmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-26 00:00:00.000000000 Z
11
+ date: 2019-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api