def user(self, user): user_cmd = "su - {}".format(user) add_user_cmd = _Users.add(user) if add_user_cmd: cmd = add_user_cmd + "\n" + user_cmd else: cmd = user_cmd self._singobj._post.append(cmd)
def user(user): """Return Dockerfile instruction to create `user` if he/she does not exist and switch to that user. Parameters ---------- user : str Name of user to create and switch to. """ user_cmd = "USER {}".format(user) add_user_cmd = _Users.add(user) if add_user_cmd: return "RUN " + add_user_cmd + "\n" + user_cmd else: return user_cmd