1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
findDeployment <- function(appPath = getwd(),
appName = NULL,
server = NULL,
account = NULL,
error_call = caller_env()) {
deps <- deployments(
appPath,
nameFilter = appName,
serverFilter = server,
accountFilter = account
)
if (nrow(deps) == 0) {
# When the name and account information does not discover a single deployment, return a skeleton
# deployment object, which can subsequently be used to query the service.
# Infers account when not provided...
accountDetails <- accountInfo(account, server)
if (is.null(appName)) {
appName <- generateAppName(NULL, appPath, account = accountDetails$name, unique = FALSE)
}
list(
name = appName,
account = accountDetails$name,
server = accountDetails$server
)
} else if (nrow(deps) == 1) {
as.list(deps)
} else {
disambiguateDeployments(deps, error_call = error_call)
}
}
disambiguateDeployments <- function(appDeployments, error_call = caller_env()) {
if (nrow(appDeployments) == 1) {
return(appDeployments[1, ])
}
apps <- paste0(
appDeployments$name, " ",
"(", accountLabel(appDeployments$account, appDeployments$server), "): ",
"{.url ", appDeployments$url, "}"
)
not_interactive <- c(
"Please use {.arg appName}, {.arg server} or {.arg account} to disambiguate.",
"Known applications:",
set_names(apps, "*")
)
idx <- cli_menu(
"This directory has been previously deployed in multiple places.",
"Which deployment do you want to use?",
choices = apps,
not_interactive = not_interactive,
error_call = error_call
)
as.list(appDeployments[idx, ])
}
|