python artifactory library:在存储库上创建文件夹并在不传递密码的情况下进行身份验证

python artifactory library: create folders on repository and authenticate without pass the password

我正在使用 python 库与 artifactory 存储库进行交互;到目前为止,如果我通过凭据并上传文件,一切都很好。

path = ArtifactoryPath("http://myartifactory/myrepo/", auth=('tester', 'thepassword'))
path.deploy_file("/tmp/test.zip")

但是,如果我尝试上传文件夹,则会出现错误,而且我看不到任何上传文件夹的方法,除非您将其压缩并作为文件上传。

IsADirectoryError: [Errno 21] Is a directory

另外,命令 path.mkdir() 似乎并没有按照它说的去做;我也尝试过传递文件夹名称的字符串,但它不会在 atifactory 存储库上创建文件夹。

FileExistsError: [Errno 17] File exists:

而且我也在寻找一种不对身份验证凭据进行硬编码的方法,因为明文共享密码不太好。图书馆提到它接受证书作为 .pem 文件,但我不确定你如何创建这样的证书。

您不能直接上传文件夹,它们必须按照 the docs:

在存档中

Supported archive types are: zip; tar; tar.gz; and tgz.

要创建一个目录,你可以简单地传递一个path with the directory you want.

.pem 文件用于保存您的 RSA Public 密钥,并且可以通过以下方式生成:

ssh-keygen -f ~/.ssh/id_rsa.pub -m 'PEM' -e > public.pem chmod 600 public.pem