This commit is contained in:
hong-revo 2019-01-12 05:45:08 +11:00
Родитель 818f1a7af6
Коммит 81b3f2a7ba
3 изменённых файлов: 20 добавлений и 2 удалений

Просмотреть файл

@ -16,6 +16,7 @@
* Add `location` argument to `az_resource_group$create_resource` method, rather than hardcoding it to the resgroup location.
* Add `wait` argument when creating a new resource, similar to deploying a template, since some resources will return before provisioning is complete. Defaults to `FALSE` for backward compatibility.
* Export `is_azure_token`.
* Allow `az_resource_group$deploy_template()` to work without `parameters` arg (parameters folded into template itself).
# AzureRMR 1.0.0

Просмотреть файл

@ -72,7 +72,7 @@ public=list(
self$subscription <- subscription
self$resource_group <- resource_group
parms <- if(!is_empty(name) && !missing(template) && !missing(parameters))
parms <- if(!is_empty(name) && !missing(template))
private$init_and_deploy(name, template, parameters, ..., wait=wait)
else if(!is_empty(name))
private$init_from_host(name)
@ -197,6 +197,11 @@ private=list(
properties <- modifyList(default_properties, list(...))
private$validate_deploy_parms(properties)
# handle case of missing or empty parameters arg
# must be a _named_ list for jsonlite to turn into an object, not an array
if(missing(parameters) || is_empty(parameters))
parameters <- structure(list(), names=character(0))
# fold template data into list of properties
properties <- if(is.list(template))
modifyList(properties, list(template=template))
@ -205,7 +210,9 @@ private=list(
else modifyList(properties, list(template=jsonlite::fromJSON(template, simplifyVector=FALSE)))
# fold parameter data into list of properties
properties <- if(is.list(parameters))
properties <- if(is_empty(parameters))
modifyList(properties, list(parameters=parameters))
else if(is.list(parameters))
modifyList(properties, list(parameters=private$make_param_list(parameters)))
else if(is_url(parameters))
modifyList(properties, list(parametersLink=list(uri=parameters)))

Просмотреть файл

@ -50,6 +50,16 @@ test_that("Template methods work",
tpl2$delete(confirm=FALSE, free_resources=TRUE)
expect_true(is_empty(rg$list_resources()))
# leave out parameters arg, modify template to incorporate parameters
tplname3 <- paste(sample(letters, 10, replace=TRUE), collapse="")
tpl_parsed$parameters$location$defaultValue <- "australiaeast"
tpl_parsed$parameters$name$defaultValue <- tplname3
tpl3 <- rg$deploy_template(tplname3, template=tpl_parsed, wait=TRUE)
tpl3$check()
expect_is(tpl3, "az_template")
expect_false(is_empty(rg$list_resources()))
})
rg$delete(confirm=FALSE)