Reputation: 2397
I am trying to migrate a legacy system to use artifactory. However I have two blockers:
Would it be possible for me to write a plugin to implement this?
Looking at https://www.jfrog.com/confluence/display/RTF/User+Plugins I couldn't find a callback for when POST /api/pypi/<index-name>
is requested.
If I can make
Upvotes: 4
Views: 135
Reputation: 2778
As you say, there is no plugin hook for the Pypi API endpoints. It would be possible to use the altResponse
endpoint to customize artifact downloads, but then you would be restricted to GET
requests with no request body, which is also not a good option for you.
I think the most viable approach would be to define a custom executions
endpoint. With this, you can specify the acceptable method, read the body, and set your own response code and body. The main shortcoming with this is that you can't customize the path (it's always /api/plugins/execute/[execution_name]
), but this can be worked around.
Execution endpoints can take params in the following form:
/api/plugins/execute/[execution_name]?params=[param_name]=[param_val]
Say your plugin takes a param path
, which represents the API path your old scripts are going to call. Then you can set your base URL to /api/plugins/execute/[execution_name]?params=path=/
, so that the API path is appended to the param. Alternatively, you can use nginx or another reverse proxy to rewrite the original API path to this form.
(Since you'll be using XML-RPC, I don't suppose you'll need to worry about any of this path stuff, but I'm including it anyway for completeness.)
Some issues with this approach:
String
responses, so sending binary data in the response body might be finnicky. However, no such limitation exists with the request body.POST
, this probably won't be an issue for you.Content-Type
or other header, you'll need to use a reverse proxy to insert it into the response.Upvotes: 2