Skip to content

Commit

Permalink
serialize multi-value metadata entries as comma-separated values
Browse files Browse the repository at this point in the history
fixes #1017
  • Loading branch information
aronatkins committed Oct 13, 2023
1 parent 525289d commit c75cf56
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 3 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
* `rpubsUpload()` correctly records the initial RPubs destination, allowing
republishing.

* `deployApp()` and friends record multi-value `metadata` entries as
comma-separated values. (#1017)

# rsconnect 1.1.1

* Added `space` parameter to deploy directly to a space in Posit Cloud.
Expand Down
3 changes: 3 additions & 0 deletions R/deployApp.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@
#' @param metadata Additional metadata fields to save with the deployment
#' record. These fields will be returned on subsequent calls to
#' [deployments()].
#'
#' Multi-value fields are recorded as comma-separated values and returned in
#' that form. Custom value serialization is the responsibility of the caller.
#' @param forceUpdate What should happen if there's no deployment record for
#' the app, but there's an app with the same name on the server? If `TRUE`,
#' will always update the previously-deployed app. If `FALSE`, will ask
Expand Down
3 changes: 3 additions & 0 deletions R/deployments.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ deploymentRecord <- function(name,
url = url %||% "",
version = version
)
# convert any multi-value metadata entries into comma-separated values
# this prevents write.dcf from writing multiple records into one file.
metadata <- lapply(metadata, function(v) paste0(v, collapse = ", "))
c(standard, metadata)
}

Expand Down
5 changes: 4 additions & 1 deletion man/deployApp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/deploySite.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/showProperties.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions tests/testthat/test-deployments.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ test_that("can read/write metadata", {
expect_equal(out$meta2, "two")
})

test_that("can read/write metadata having multiple values", {
dir <- local_temp_app()

addTestDeployment(dir, metadata = list(engines = c("knitr","markdown")))

Check warning on line 75 in tests/testthat/test-deployments.R

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-deployments.R,line=75,col=62,[commas_linter] Commas should always have a space after.
out <- deployments(dir, excludeOrphaned = FALSE)
expect_equal(nrow(out), 1)
expect_equal(out$engines, "knitr, markdown")
})

test_that("can read/write version", {
dir <- local_temp_app()

Expand Down

0 comments on commit c75cf56

Please sign in to comment.