posit-dev / publisher

MIT License
3 stars 0 forks source link

Add subdirectory support to deployments API #1873

Closed mmarchetti closed 22 hours ago

mmarchetti commented 5 days ago

Intent

This PR adds support for an optional dir query parameter to the deployment API endpoints:

The directory is relative to the workspace root directory, and cannot escape it (the API should return a 400 if you provide a path that would be outside of the workspace root).

It also populates the returned configuration DTO with a new projectDir field that contains the subdirectory (again, relative to the workspace root).

This is part of https://github.com/posit-dev/publisher/issues/1844 and part of https://github.com/posit-dev/publisher/issues/1851.

Type of Change

Automated Tests

Existing tests have been updated to assert that the projectDir is correct when no dir is specified. New tests have been added specifically to test the subdirectory case for each API.

Directions for Reviewers

Run the agent in a parent directory (one or more levels up from your deployable projects). Access deployment info from subdirectories using the various APIs:

$publisher ui -vv --listen=localhost:9001 &
curl localhost:9001/api/deployments?dir=test/sample-content/quarto-proj-py | jq
curl localhost:9001/api/deployments?dir=test/sample-content/quarto-proj-none | jq

The POST /api/deployments/$NAME endpoint should load the configuration named in the deployment from the same directory path; verify that.

Also run the extension and regression test basic publishing (you can't use subdirectories in the extension yet, but everything should default to the current behavior).