зеркало из https://github.com/Azure/AzureRMR.git
make path construction consistent
This commit is contained in:
Родитель
fbc7f1384a
Коммит
3c12755bc0
|
@ -129,7 +129,7 @@ private=list(
|
|||
get_azure_token=function(aad_host, tenant, app, auth_type=c("client_credentials", "device_code"), secret, arm_host)
|
||||
{
|
||||
auth_type <- match.arg(auth_type)
|
||||
base_url <- file.path(aad_host, tenant, fsep="/")
|
||||
base_url <- construct_path(aad_host, tenant)
|
||||
if(auth_type == "client_credentials")
|
||||
auth_with_creds(base_url, app, secret, arm_host)
|
||||
else auth_with_device(base_url, app, arm_host)
|
||||
|
|
|
@ -209,7 +209,7 @@ private=list(
|
|||
|
||||
rg_op=function(op="", ...)
|
||||
{
|
||||
op <- file.path("resourcegroups", self$name, op)
|
||||
op <- construct_path("resourcegroups", self$name, op)
|
||||
call_azure_rm(self$token, self$subscription, op, ...)
|
||||
}
|
||||
))
|
||||
|
|
|
@ -116,7 +116,7 @@ public=list(
|
|||
provider <- substr(self$type, 1, slash - 1)
|
||||
path <- substr(self$type, slash + 1, nchar(self$type))
|
||||
|
||||
op <- file.path("providers", provider)
|
||||
op <- construct_path("providers", provider)
|
||||
apis <- named_list(call_azure_rm(self$token, self$subscription, op)$resourceTypes, "resourceType")
|
||||
|
||||
names(apis) <- tolower(names(apis))
|
||||
|
@ -144,7 +144,7 @@ public=list(
|
|||
}
|
||||
|
||||
private$res_op(http_verb="DELETE")
|
||||
message("Deleting resource '", file.path(self$type, self$name), "'")
|
||||
message("Deleting resource '", construct_path(self$type, self$name), "'")
|
||||
|
||||
if(wait)
|
||||
{
|
||||
|
@ -207,8 +207,8 @@ private=list(
|
|||
else
|
||||
{
|
||||
if(missing(type))
|
||||
type <- file.path(provider, path)
|
||||
id <- file.path("/subscriptions", self$subscription, "resourceGroups", resource_group, "providers", type, name)
|
||||
type <- construct_path(provider, path)
|
||||
id <- construct_path("/subscriptions", self$subscription, "resourceGroups", resource_group, "providers", type, name)
|
||||
}
|
||||
self$resource_group <- resource_group
|
||||
self$type <- type
|
||||
|
@ -271,7 +271,7 @@ private=list(
|
|||
if(is.null(private$api_version))
|
||||
self$set_api_version()
|
||||
|
||||
op <- file.path("resourcegroups", self$resource_group, "providers", self$type, self$name, op)
|
||||
op <- construct_path("resourcegroups", self$resource_group, "providers", self$type, self$name, op)
|
||||
call_azure_rm(self$token, self$subscription, op, ..., api_version=private$api_version)
|
||||
}
|
||||
))
|
||||
|
|
|
@ -77,7 +77,7 @@ public=list(
|
|||
}
|
||||
else
|
||||
{
|
||||
op <- file.path("providers", provider)
|
||||
op <- construct_path("providers", provider)
|
||||
apis <- named_list(call_azure_rm(self$token, self$id, op)$resourceTypes, "resourceType")
|
||||
if(!is_empty(type))
|
||||
{
|
||||
|
|
|
@ -221,7 +221,7 @@ private=list(
|
|||
|
||||
tpl_op=function(op="", ...)
|
||||
{
|
||||
op <- file.path("resourcegroups", self$resource_group, "providers/Microsoft.Resources/deployments", self$name, op)
|
||||
op <- construct_path("resourcegroups", self$resource_group, "providers/Microsoft.Resources/deployments", self$name, op)
|
||||
call_azure_rm(self$token, self$subscription, op, ...)
|
||||
}
|
||||
))
|
||||
|
|
|
@ -28,7 +28,7 @@ call_azure_rm <- function(token, subscription, operation, ...,
|
|||
api_version=getOption("azure_api_version"))
|
||||
{
|
||||
url <- httr::parse_url(token$credentials$resource)
|
||||
url$path <- file.path("subscriptions", subscription, operation, fsep="/")
|
||||
url$path <- construct_path("subscriptions", subscription, operation)
|
||||
url$query <- modifyList(list(`api-version`=api_version), options)
|
||||
|
||||
call_azure_url(token, httr::build_url(url), ...)
|
||||
|
|
|
@ -57,3 +57,10 @@ validate_object_names <- function(x, required, optional=character(0))
|
|||
if(!valid)
|
||||
stop("Invalid object names")
|
||||
}
|
||||
|
||||
|
||||
# handle different behaviour of file_path on Windows/Linux wrt trailing /
|
||||
construct_path <- function(...)
|
||||
{
|
||||
sub("/$", "", file.path(..., fsep="/"))
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче