Skip to content

Commit

Permalink
snake case + update comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Newton committed Aug 15, 2023
1 parent e705192 commit 672f770
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
13 changes: 7 additions & 6 deletions cpp/src/arrow/filesystem/azurefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "arrow/result.h"
#include "arrow/util/checked_cast.h"
#include <azure/storage/blobs.hpp>
#include <azure/identity/default_azure_credential.hpp>
#include <azure/identity/managed_identity_credential.hpp>

namespace arrow {
namespace fs {
Expand Down Expand Up @@ -49,11 +49,12 @@ class AzureFileSystem::Impl {
: io_context_(io_context), options_(std::move(options)) {}

Status Init() {
// TODO: Delete this once we have a proper implementation. This is just here to
// ensure the build is working correctly with the Azure SDK.
auto defaultCredential = std::make_shared<Azure::Identity::DefaultAzureCredential>();
auto serviceClient = Azure::Storage::Blobs::BlobServiceClient(
"http://fake-blob-storage-endpoit", defaultCredential);
// TODO: GH-18014 Delete this once we have a proper implementation. This just
// initializes a pointless Azure blob service client with a fake endpoint to ensure
// the build will fail if the Azure SDK build is broken.
auto default_credential = std::make_shared<Azure::Identity::ManagedIdentityCredential>();
auto service_client = Azure::Storage::Blobs::BlobServiceClient(
"http://fake-blob-storage-endpoint", default_credential);
if (options_.backend == AzureBackend::Azurite) {
// gen1Client_->GetAccountInfo().Value.IsHierarchicalNamespaceEnabled
// throws error in azurite
Expand Down
30 changes: 15 additions & 15 deletions cpp/src/arrow/filesystem/azurefs_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,36 +114,36 @@ AzuriteEnv* GetAzuriteEnv() {
// Placeholder tests
// TODO: GH-18014 Remove once a proper test is added
TEST(AzureFileSystem, UploadThenDownload) {
const std::string containerName = "sample-container";
const std::string blobName = "sample-blob.txt";
const std::string blobContent = "Hello Azure!";
const std::string container_name = "sample-container";
const std::string blob_name = "sample-blob.txt";
const std::string blob_content = "Hello Azure!";

const std::string& account_name = GetAzuriteEnv()->account_name();
const std::string& account_key = GetAzuriteEnv()->account_key();

auto credential = std::make_shared<Azure::Storage::StorageSharedKeyCredential>(
account_name, account_key);

auto serviceClient = Azure::Storage::Blobs::BlobServiceClient(
auto service_client = Azure::Storage::Blobs::BlobServiceClient(
"http://127.0.0.1:10000/devstoreaccount1", credential);
auto containerClient = serviceClient.GetBlobContainerClient(containerName);
containerClient.CreateIfNotExists();
auto blobClient = containerClient.GetBlockBlobClient(blobName);
auto container_client = service_client.GetBlobContainerClient(container_name);
container_client.CreateIfNotExists();
auto blob_client = container_client.GetBlockBlobClient(blob_name);

std::vector<uint8_t> buffer(blobContent.begin(), blobContent.end());
blobClient.UploadFrom(buffer.data(), buffer.size());
std::vector<uint8_t> buffer(blob_content.begin(), blob_content.end());
blob_client.UploadFrom(buffer.data(), buffer.size());

std::vector<uint8_t> buffer2(blobContent.size());
blobClient.DownloadTo(buffer2.data(), buffer2.size());
std::vector<uint8_t> buffer2(blob_content.size());
blob_client.DownloadTo(buffer2.data(), buffer2.size());

EXPECT_EQ(std::string(buffer2.begin(), buffer2.end()), blobContent);
EXPECT_EQ(std::string(buffer2.begin(), buffer2.end()), blob_content);
}

TEST(AzureFileSystem, InitializeCredentials) {
auto defaultCredential = std::make_shared<Azure::Identity::DefaultAzureCredential>();
auto managedIdentityCredential =
auto default_credential = std::make_shared<Azure::Identity::DefaultAzureCredential>();
auto managed_identity_credential =
std::make_shared<Azure::Identity::ManagedIdentityCredential>();
auto servicePrincipalCredential =
auto service_principal_credential =
std::make_shared<Azure::Identity::ClientSecretCredential>("tenant_id", "client_id",
"client_secret");
}
Expand Down

0 comments on commit 672f770

Please sign in to comment.