-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add space parameter for Posit Cloud #983
Changes from 2 commits
9ee3121
9836775
34e4e64
b1ed3eb
3ccd0ad
407df87
e7f45b7
a33a91e
d234d40
ab46dd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,23 +161,27 @@ cloudClient <- function(service, authInfo) { | |
GET(service, authInfo, path, query) | ||
}, | ||
|
||
createApplication = function(name, title, template, accountId, appMode) { | ||
createApplication = function(name, title, template, accountId, appMode, spaceId = NULL) { | ||
json <- list() | ||
json$name <- name | ||
json$application_type <- if (appMode %in% c("rmd-static", "quarto-static", "static")) "static" else "connect" | ||
if (appMode %in% c("rmd-static", "quarto-static")) { | ||
json$render_by <- "server" | ||
} | ||
|
||
currentProjectId <- getCurrentProjectId(service, authInfo) | ||
# in case the source cloud project is a temporary copy, there is no | ||
# content id. The output will be published without a space id. | ||
if (!is.null(currentProjectId)) { | ||
json$project <- currentProjectId | ||
if (is.null(spaceId)) { | ||
currentProjectId <- getCurrentProjectId(service, authInfo) | ||
# in case the source cloud project is a temporary copy, there is no | ||
# content id. The output will be published without a space id. | ||
if (!is.null(currentProjectId)) { | ||
json$project <- currentProjectId | ||
|
||
path <- paste0("/content/", currentProjectId) | ||
currentProject <- GET(service, authInfo, path) | ||
json$space <- currentProject$space_id | ||
path <- paste0("/content/", currentProjectId) | ||
currentProject <- GET(service, authInfo, path) | ||
json$space <- currentProject$space_id | ||
mslynch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} else { | ||
json$space <- spaceId | ||
} | ||
|
||
output <- POST_JSON(service, authInfo, "/outputs", json) | ||
|
@@ -230,12 +234,21 @@ cloudClient <- function(service, authInfo) { | |
revision$application_id | ||
}, | ||
|
||
deployApplication = function(application, bundleId = NULL) { | ||
deployApplication = function(application, bundleId = NULL, spaceId = NULL) { | ||
mslynch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
outputPatchData <- list() | ||
|
||
currentProjectId <- getCurrentProjectId(service, authInfo) | ||
if (!is.null(currentProjectId)) { | ||
outputPatchData$project <- currentProjectId | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is different logic than is used when creating; intentional? In this case, we could end up using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the logic as-written makes sense (at least to me). When you deploy, it should definitely set the space based on the space of the environment project. But on redeploys, it would probably be more confusing for projects to move between spaces without providing the argument. @m-- Any other thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also cc @kippandrew ^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that makes sense to me. |
||
} | ||
|
||
if (!is.null(spaceId)) { | ||
outputPatchData$space <- spaceId | ||
} | ||
|
||
if (length(outputPatchData) > 0) { | ||
path <- paste0("/outputs/", application$id) | ||
json <- list(project = currentProjectId) | ||
PATCH_JSON(service, authInfo, path, json) | ||
PATCH_JSON(service, authInfo, path, outputPatchData) | ||
} | ||
|
||
path <- paste0("/applications/", application$application_id, "/deploy") | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change does not add the
json$project
when provided an incomingspaceId
. Is it needed in this case?Compare this change to the change in
deployApplication()
-- there, the space associated with the current project is never used, while the current project id is used unconditionally (even when there isspaceId
argument).What is the expectation for the
project
andspace
fields provided to the different API calls? I'm not familiar with the APIs that are being called -- more details would be really helpful.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it is needed here – pushed a commit to change this logic. If we're executing inside a Posit Cloud project, we always want to link the output to that output through
project
. For the space, we want to update it if there's a specific space passed in throughdeployApp
. If there's no space when we create the application, it should be set to the space of the project.