Skip to content

Commit

Permalink
Merge pull request #35 from samansmink/remove-deprecated-chain
Browse files Browse the repository at this point in the history
Disable deprecated code from aws sdk
  • Loading branch information
samansmink authored Mar 12, 2024
2 parents a3bff08 + f6858dc commit f7b8729
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 171 deletions.
1 change: 1 addition & 0 deletions .github/workflows/MainDistributionPipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
extension_name: aws
duckdb_version: 'v0.10.0'
exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_rtools' # Doesn't work anyway: env local file or env access possible
vcpkg_commit: 'a1a1cbc975abf909a6c8985a6a2b8fe20bbd9bd6'

duckdb-stable-deploy:
name: Deploy extension binaries
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/MinioTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Setup vcpkg
uses: lukka/[email protected]
with:
vcpkgGitCommitId: a42af01b72c28a8e1d7b48107b33e4f286a55ef6
vcpkgGitCommitId: a1a1cbc975abf909a6c8985a6a2b8fe20bbd9bd6

- name: Build
shell: bash
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
path = duckdb
url = https://github.com/duckdb/duckdb
branch = main
[submodule "extension-ci-tools"]
path = extension-ci-tools
url = [email protected]:duckdb/extension-ci-tools.git
125 changes: 6 additions & 119 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,121 +1,8 @@
.PHONY: all clean format debug release duckdb_debug duckdb_release pull update
PROJ_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

all: release
# Configuration of extension
EXT_NAME=quack
EXT_CONFIG=${PROJ_DIR}extension_config.cmake

MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
PROJ_DIR := $(dir $(MKFILE_PATH))

ifeq ($(OS),Windows_NT)
TEST_PATH="/test/Release/unittest.exe"
else
TEST_PATH="/test/unittest"
endif

OSX_BUILD_UNIVERSAL_FLAG=
ifneq (${OSX_BUILD_ARCH}, "")
OSX_BUILD_UNIVERSAL_FLAG=-DOSX_BUILD_ARCH=${OSX_BUILD_ARCH}
endif
ifeq (${STATIC_LIBCPP}, 1)
STATIC_LIBCPP=-DSTATIC_LIBCPP=TRUE
endif
ifeq (${DONT_STATIC_LINK_DUCKDB}, 1)
STATIC_LINK_DUCKDB_FLAG=-DEXTENSION_STATIC_BUILD=0
else
STATIC_LINK_DUCKDB_FLAG=-DEXTENSION_STATIC_BUILD=1
endif

VCPKG_TOOLCHAIN_PATH?=
ifneq ("${VCPKG_TOOLCHAIN_PATH}", "")
TOOLCHAIN_FLAGS:=${TOOLCHAIN_FLAGS} -DVCPKG_MANIFEST_DIR='${PROJ_DIR}' -DVCPKG_BUILD=1 -DCMAKE_TOOLCHAIN_FILE='${VCPKG_TOOLCHAIN_PATH}'
endif
ifneq ("${VCPKG_TARGET_TRIPLET}", "")
TOOLCHAIN_FLAGS:=${TOOLCHAIN_FLAGS} -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}'
endif

ifeq ($(GEN),ninja)
GENERATOR=-G "Ninja"
FORCE_COLOR=-DFORCE_COLORED_OUTPUT=1
endif

BUILD_FLAGS=-DBUILD_EXTENSIONS="tpch;httpfs" ${STATIC_LINK_DUCKDB_FLAG} ${OSX_BUILD_UNIVERSAL_FLAG} ${STATIC_LIBCPP} ${DISABLE_UNITY_FLAG} ${TOOLCHAIN_FLAGS} -DDUCKDB_EXPLICIT_PLATFORM='${DUCKDB_PLATFORM}'

CLIENT_FLAGS :=

# These flags will make DuckDB build the extension
EXTENSION_FLAGS=\
-DDUCKDB_EXTENSION_NAMES="aws" \
-DDUCKDB_EXTENSION_AWS_PATH="$(PROJ_DIR)" \
-DDUCKDB_EXTENSION_AWS_SHOULD_LINK=1 \
-DDUCKDB_EXTENSION_AWS_LOAD_TESTS=1 \
-DDUCKDB_EXTENSION_AWS_TEST_PATH="$(PROJ_DIR)test" \
-DDUCKDB_EXTENSION_AWS_INCLUDE_PATH="$(PROJ_DIR)src/include" \
-DDUCKDB_EXTENSION_AWS_VERSION="$(PROJ_DIR)src/include" \


pull:
git submodule init
git submodule update --recursive --remote

clean:
rm -rf build
rm -rf testext
cd duckdb && make clean

# Main build
debug:
mkdir -p build/debug && \
cmake $(GENERATOR) $(FORCE_COLOR) $(EXTENSION_FLAGS) ${CLIENT_FLAGS} -DEXTENSION_STATIC_BUILD=1 -DCMAKE_BUILD_TYPE=Debug ${BUILD_FLAGS} -S ./duckdb/ -B build/debug && \
cmake --build build/debug --config Debug

release:
mkdir -p build/release && \
cmake $(GENERATOR) $(FORCE_COLOR) $(EXTENSION_FLAGS) ${CLIENT_FLAGS} -DEXTENSION_STATIC_BUILD=1 -DCMAKE_BUILD_TYPE=Release ${BUILD_FLAGS} -S ./duckdb/ -B build/release && \
cmake --build build/release --config Release

# Client build
debug_js: CLIENT_FLAGS=-DBUILD_NODE=1 -DBUILD_EXTENSIONS=json
debug_js: debug

debug_r: CLIENT_FLAGS=-DBUILD_R=1
debug_r: debug

debug_python: CLIENT_FLAGS=-DBUILD_PYTHON=1 -DBUILD_EXTENSIONS=json;fts;tpch;visualizer;tpcds
debug_python: debug

release_js: CLIENT_FLAGS=-DBUILD_NODE=1 -DBUILD_EXTENSIONS=json
release_js: release

release_r: CLIENT_FLAGS=-DBUILD_R=1
release_r: release

release_python: CLIENT_FLAGS=-DBUILD_PYTHON=1 -DBUILD_EXTENSIONS=json;fts;tpch;visualizer;tpcds
release_python: release

# Main tests
test: test_release
test_release: release
./build/release/$(TEST_PATH) "$(PROJ_DIR)test/*"
test_debug: debug
./build/debug/$(TEST_PATH) "$(PROJ_DIR)test/*"

# Client tests
test_js: test_debug_js
test_debug_js: debug_js
cd duckdb/tools/nodejs && npm run test-path -- "../../../test/nodejs/**/*.js"

test_release_js: release_js
cd duckdb/tools/nodejs && npm run test-path -- "../../../test/nodejs/**/*.js"

test_python: test_debug_python
test_debug_python: debug_python
cd test/python && python3 -m pytest

test_release_python: release_python
cd test/python && python3 -m pytest

format:
find src/ -iname *.hpp -o -iname *.cpp | xargs clang-format --sort-includes=0 -style=file -i
cmake-format -i CMakeLists.txt

update:
git submodule update --remote --merge
# Include the Makefile from extension-ci-tools
include extension-ci-tools/makefiles/duckdb_extension.Makefile
2 changes: 1 addition & 1 deletion duckdb
Submodule duckdb updated 1111 files
1 change: 1 addition & 0 deletions extension-ci-tools
Submodule extension-ci-tools added at f0c2c5
9 changes: 9 additions & 0 deletions extension_config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file is included by DuckDB's build system. It specifies which extension to load

# Extension from this repo
duckdb_extension_load(aws
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}
LOAD_TESTS
)

duckdb_extension_load(httpfs)
24 changes: 2 additions & 22 deletions src/aws_secret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ static unique_ptr<KeyValueSecret> ConstructBaseS3Secret(vector<string> &prefix_p
//! Generate a custom credential provider chain for authentication
class DuckDBCustomAWSCredentialsProviderChain : public Aws::Auth::AWSCredentialsProviderChain {
public:
explicit DuckDBCustomAWSCredentialsProviderChain(const string &credential_chain, const string &profile = "",
const string &task_role_resource_path = "",
const string &task_role_endpoint = "",
const string &task_role_token = "") {
explicit DuckDBCustomAWSCredentialsProviderChain(const string &credential_chain, const string &profile = "") {
auto chain_list = StringUtil::Split(credential_chain, ';');

for (const auto &item : chain_list) {
Expand All @@ -56,16 +53,6 @@ class DuckDBCustomAWSCredentialsProviderChain : public Aws::Auth::AWSCredentials
AddProvider(make_shared<Aws::Auth::InstanceProfileCredentialsProvider>());
} else if (item == "process") {
AddProvider(make_shared<Aws::Auth::ProcessCredentialsProvider>());
} else if (item == "task_role") {
if (!task_role_resource_path.empty()) {
AddProvider(make_shared<Aws::Auth::TaskRoleCredentialsProvider>(task_role_resource_path.c_str()));
} else if (!task_role_endpoint.empty()) {
AddProvider(make_shared<Aws::Auth::TaskRoleCredentialsProvider>(task_role_endpoint.c_str(),
task_role_token.c_str()));
} else {
throw InvalidInputException(
"task_role provider selected without a resource path or endpoint specified!");
}
} else if (item == "config") {
if (profile.empty()) {
AddProvider(make_shared<Aws::Auth::ProfileConfigFileAWSCredentialsProvider>());
Expand Down Expand Up @@ -99,12 +86,8 @@ static unique_ptr<BaseSecret> CreateAWSSecretFromCredentialChain(ClientContext &

if (input.options.find("chain") != input.options.end()) {
string chain = TryGetStringParam(input, "chain");
string task_role_resource_path = TryGetStringParam(input, "task_role_resource_path");
string task_role_endpoint = TryGetStringParam(input, "task_role_endpoint");
string task_role_token = TryGetStringParam(input, "task_role_token");

DuckDBCustomAWSCredentialsProviderChain provider(chain, profile, task_role_resource_path, task_role_endpoint,
task_role_token);
DuckDBCustomAWSCredentialsProviderChain provider(chain, profile);
credentials = provider.GetAWSCredentials();
} else {
if (input.options.find("profile") != input.options.end()) {
Expand Down Expand Up @@ -210,9 +193,6 @@ void CreateAwsSecretFunctions::Register(DatabaseInstance &instance) {

// Params for configuring the credential loading
cred_chain_function.named_parameters["profile"] = LogicalType::VARCHAR;
cred_chain_function.named_parameters["task_role_resource_path"] = LogicalType::VARCHAR;
cred_chain_function.named_parameters["task_role_endpoint"] = LogicalType::VARCHAR;
cred_chain_function.named_parameters["task_role_token"] = LogicalType::VARCHAR;

ExtensionUtil::RegisterFunction(instance, cred_chain_function);
}
Expand Down
27 changes: 0 additions & 27 deletions test/sql/aws_secret_chains.test
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,3 @@ CREATE SECRET env_secret (
PROVIDER credential_chain,
CHAIN 'env'
);

statement error
CREATE SECRET task_role_secret (
TYPE S3,
PROVIDER credential_chain,
CHAIN 'task_role'
);
----
task_role provider selected without a resource path or endpoint specified!

statement ok
CREATE SECRET task_role_secret_resource_path (
TYPE S3,
PROVIDER credential_chain,
CHAIN 'task_role',
TASK_ROLE_RESOURCE_PATH 'blablabla'
);

statement ok
CREATE SECRET task_role_secret_endpoint (
TYPE S3,
PROVIDER credential_chain,
CHAIN 'task_role',
TASK_ROLE_ENDPOINT 'blablabla',
TASK_ROLE_TOKEN 'lalala'
);

4 changes: 3 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
"zlib",
"aws-sdk-cpp",
"openssl"
]
],
"builtin-baseline": "a1a1cbc975abf909a6c8985a6a2b8fe20bbd9bd6",
"overrides": [{"name": "openssl", "version": "3.0.8"}]
}

0 comments on commit f7b8729

Please sign in to comment.