Skip to content
This repository has been archived by the owner on Oct 31, 2019. It is now read-only.

Commit

Permalink
Add validateStorageArguments() function #46
Browse files Browse the repository at this point in the history
  • Loading branch information
andrie committed Feb 13, 2017
1 parent 51f0e5b commit f515168
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion R/internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ callAzureStorageApi <- function(url, verb = "GET", storageKey, storageAccount,
`x-ms-date` = dateStamp)
),
verbosity),
"PUT" = PUT(url, add_headers(.headers = c(Authorization = at,
"PUT" = PUT(url, add_headers(.headers = c(Authorization = at,
`Content-Length` = nchar(content),
`x-ms-version` = "2015-04-05",
`x-ms-date` = dateStamp,
Expand Down Expand Up @@ -151,3 +151,25 @@ updateAzureActiveContext <- function(x, storageAccount, storageKey, resourceGrou
if (!missing(directory)) x$directory <- directory
TRUE
}

validateStorageArguments <- function(resourceGroup, storageAccount, container, storageKey) {
msg <- character(0)
pasten <- function(x, ...) paste(x, ..., collapse = "", sep = "\n")
if (!missing(resourceGroup) && (is.null(resourceGroup) || length(resourceGroup) == 0)) {
msg <- pasten(msg, "- No resourceGroup provided. Use resourceGroup argument or set in AzureContext")
}
if (!missing(storageAccount) && (is.null(storageAccount) || length(storageAccount) == 0)) {
msg <- pasten(msg, "- No storageAccount provided. Use storageAccount argument or set in AzureContext")
}
if (!missing(container) && (is.null(container) || length(container) == 0)) {
msg <- pasten(msg, "- No container provided. Use container argument or set in AzureContext")
}
if (!missing(storageKey) && (is.null(storageKey) || length(storageKey) == 0)) {
msg <- pasten(msg, "- No storageKey provided. Use storageKey argument or set in AzureContext")
}

if (length(msg) > 0) {
stop(msg, call. = FALSE)
}
msg
}

0 comments on commit f515168

Please sign in to comment.