Config option to not specify a user when calling docker.
authorCarl Hetherington <cth@carlh.net>
Thu, 3 Oct 2019 22:01:36 +0000 (00:01 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 3 Oct 2019 22:01:36 +0000 (00:01 +0200)
cdist

diff --git a/cdist b/cdist
index bf478d2525e0d1ad341fba897104b6092c2722e3..751be982baa931a86d4ebe10c0bec351c9c992ff 100755 (executable)
--- a/cdist
+++ b/cdist
@@ -106,6 +106,7 @@ class Config:
                          Option('osx_sdk_prefix'),
                          Option('osx_sdk'),
                          BoolOption('docker_sudo'),
+                         BoolOption('docker_no_user'),
                          Option('docker_hub_repository'),
                          Option('flatpak_state_dir'),
                          Option('parallel', 4) ]
@@ -531,7 +532,11 @@ class DockerTarget(Target):
 
     def command(self, cmd):
         dir = os.path.join(self.directory, os.path.relpath(os.getcwd(), self.directory))
-        command('%s exec -u %s -t %s /bin/bash -c \'export %s; cd %s; %s\'' % (config.docker(), getpass.getuser(), self.container, self.variables_string(), dir, cmd))
+        if config.get('docker_no_user'):
+            user = ''
+        else:
+            user = '-t %s' % getpass.getuser()
+        command('%s exec -u %s %s /bin/bash -c \'export %s; cd %s; %s\'' % (config.docker(), user, self.container, self.variables_string(), dir, cmd))
 
     def cleanup(self):
         super(DockerTarget, self).cleanup()