Skip to content

Commit

Permalink
changes to fix issue microsoft#89
Browse files Browse the repository at this point in the history
Made resourceGroup optional (useful when providing a storage key)
  • Loading branch information
algattik committed Jul 25, 2017
1 parent aa9f849 commit 27d2cb7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions R/AzureBlob.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ azureBlobLS <- function(azureActiveContext, directory, recursive = FALSE,
if (missing(storageAccount)) storageAccount <- azureActiveContext$storageAccount
if (missing(storageKey)) storageKey <- azureActiveContext$storageKey
if (missing(container)) container <- azureActiveContext$container
if (missing(resourceGroup)) resourceGroup <- azureActiveContext$resourceGroup
if (missing(directory)) directory <- azureActiveContext$directory
} else {
if(missing(directory)) directory <- "/"
Expand All @@ -125,7 +124,6 @@ azureBlobLS <- function(azureActiveContext, directory, recursive = FALSE,

if(is.null(directory) || directory == "") directory <- "/"

assert_that(is_resource_group(resourceGroup))
assert_that(is_storage_account(storageAccount))
assert_that(is_container(container))
assert_that(is_directory(directory))
Expand All @@ -137,6 +135,7 @@ azureBlobLS <- function(azureActiveContext, directory, recursive = FALSE,
directory <- gsub("//", "/", directory)

if (!missing(azureActiveContext) && !is.null(azureActiveContext) && missing(storageKey)) {
assert_that(is_resource_group(resourceGroup))
storageKey <- refreshStorageKey(azureActiveContext, storageAccount, resourceGroup)
}

Expand Down Expand Up @@ -215,7 +214,6 @@ azureGetBlob <- function(azureActiveContext, blob, directory, type = "text",
if (missing(container)) container <- ""
}

assert_that(is_resource_group(resourceGroup))
assert_that(is_storage_account(storageAccount))
assert_that(is_container(container))
assert_that(is_storage_key(storageKey))
Expand Down Expand Up @@ -298,7 +296,6 @@ azurePutBlob <- function(azureActiveContext, blob, contents = "", file = "",
if (is.null(directory)) directory <- "/"
if (is.null(container)) container <- ""

assert_that(is_resource_group(resourceGroup))
assert_that(is_storage_account(storageAccount))
assert_that(is_container(container))
assert_that(is_storage_key(storageKey))
Expand All @@ -318,6 +315,7 @@ azurePutBlob <- function(azureActiveContext, blob, contents = "", file = "",
if (!missing(contents) && !missing(file))stop("Provided either Content OR file Argument")

if (missing(storageKey) && !missing(azureActiveContext) && !is.null(azureActiveContext)) {
assert_that(is_resource_group(resourceGroup))
storageKey <- refreshStorageKey(azureActiveContext, storageAccount, resourceGroup)
}

Expand Down Expand Up @@ -366,12 +364,12 @@ azureBlobFind <- function(azureActiveContext, file, storageAccount, storageKey,
if (missing(storageKey)) storageKey <- azureActiveContext$storageKey
if (missing(container)) container <- azureActiveContext$container
if (missing(resourceGroup)) resourceGroup <- azureActiveContext$resourceGroup
assert_that(is_resource_group(resourceGroup))
storageKey <- refreshStorageKey(azureActiveContext, storageAccount, resourceGroup)
} else {
if (missing(container)) container <- ""
}

assert_that(is_resource_group(resourceGroup))
assert_that(is_storage_account(storageAccount))
assert_that(is_container(container))
assert_that(is_storage_key(storageKey))
Expand Down Expand Up @@ -414,6 +412,7 @@ azureBlobCD <- function(azureActiveContext, directory, container, file,
if (missing(storageKey)) storageKey <- azureActiveContext$storageKey
if (missing(container)) container <- azureActiveContext$container
if (missing(resourceGroup)) resourceGroup <- azureActiveContext$resourceGroup
assert_that(is_resource_group(resourceGroup))
storageKey <- refreshStorageKey(azureActiveContext, storageAccount, resourceGroup)
} else {
if (missing(directory)) directory <- "/"
Expand All @@ -422,7 +421,6 @@ azureBlobCD <- function(azureActiveContext, directory, container, file,

verbosity <- set_verbosity(verbose)

assert_that(is_resource_group(resourceGroup))
assert_that(is_storage_account(storageAccount))
assert_that(is_container(container))
assert_that(is_storage_key(storageKey))
Expand Down Expand Up @@ -494,12 +492,12 @@ azureDeleteBlob <- function(azureActiveContext, blob, directory,
if (missing(blob)) blob <- azureActiveContext$blob
if (missing(directory)) directory <- azureActiveContext$directory
if (missing(container)) container <- azureActiveContext$container
assert_that(is_resource_group(resourceGroup))
storageKey <- refreshStorageKey(azureActiveContext, storageAccount, resourceGroup)
} else {
if (missing(directory)) directory <- "/"
if (missing(container)) container <- ""
}
assert_that(is_resource_group(resourceGroup))
assert_that(is_storage_account(storageAccount))
assert_that(is_container(container))
assert_that(is_storage_key(storageKey))
Expand Down

0 comments on commit 27d2cb7

Please sign in to comment.