code: def create_file_and_add_volume(self,
                                     runtime,          # type: List[Text]
                                     volume,           # type: MapperEnt
                                     host_outdir_tgt,  # type: Optional[Text]
                                     secret_store,     # type: Optional[SecretStore]
                                     tmpdir_prefix     # type: Text
                                     ):  # type: (...) -> Text
          
          if not host_outdir_tgt:
              tmp_dir, tmp_prefix = os.path.split(tmpdir_prefix)
              new_file = os.path.join(
                  tempfile.mkdtemp(prefix=tmp_prefix, dir=tmp_dir),
                  os.path.basename(volume.resolved))
          writable = True if volume.type == "CreateWritableFile" else False
          if secret_store:
              contents = secret_store.retrieve(volume.resolved)
          else:
              contents = volume.resolved
          dirname = os.path.dirname(host_outdir_tgt or new_file)
          if not os.path.exists(dirname):
              os.makedirs(dirname)
          with open(host_outdir_tgt or new_file, "wb") as file_literal:
              file_literal.write(contents.encode("utf-8"))
          if not host_outdir_tgt:
              self.append_volume(runtime, new_file, volume.target,
                                 writable=writable)
          if writable:
              ensure_writable(host_outdir_tgt or new_file)
          else:
              ensure_non_writable(host_outdir_tgt or new_file)
          return host_outdir_tgt or new_file
docs: Create the file and add a mapping.