builder: include environment when running an exec
Some container execs have an environment, let's make sure they are included when running exec. Closes-Bug: #1855932 Change-Id: Ic2e2c2d50f5883f7db28768ba215e74bcbf9fd8b
This commit is contained in:
parent
14fa098fcb
commit
b5be45067a
|
@ -262,6 +262,7 @@ class BaseBuilder(object):
|
||||||
cmd.append('--privileged=%s' % str(cconfig['privileged']).lower())
|
cmd.append('--privileged=%s' % str(cconfig['privileged']).lower())
|
||||||
if 'user' in cconfig:
|
if 'user' in cconfig:
|
||||||
cmd.append('--user=%s' % cconfig['user'])
|
cmd.append('--user=%s' % cconfig['user'])
|
||||||
|
self.list_or_dict_arg(cconfig, cmd, 'environment', '--env')
|
||||||
command = self.command_argument(cconfig.get('command'))
|
command = self.command_argument(cconfig.get('command'))
|
||||||
# for exec, the first argument is the container name,
|
# for exec, the first argument is the container name,
|
||||||
# make sure the correct one is used
|
# make sure the correct one is used
|
||||||
|
|
|
@ -585,6 +585,7 @@ three-12345678 three''', '', 0),
|
||||||
'one': {
|
'one': {
|
||||||
'command': 'ls -l /foo',
|
'command': 'ls -l /foo',
|
||||||
'privileged': True,
|
'privileged': True,
|
||||||
|
'environment': {'FOO': 'BAR'},
|
||||||
'user': 'bar'
|
'user': 'bar'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -596,6 +597,7 @@ three-12345678 three''', '', 0),
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
['docker', 'exec',
|
['docker', 'exec',
|
||||||
'--privileged=true', '--user=bar',
|
'--privileged=true', '--user=bar',
|
||||||
|
'--env=FOO=BAR',
|
||||||
'one-12345678', '-l', '/foo'],
|
'one-12345678', '-l', '/foo'],
|
||||||
cmd
|
cmd
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue