keboola/storage-driver-bigquery
最新稳定版本:v8.26.0
Composer 安装命令:
composer create-project keboola/storage-driver-bigquery
包简介
Keboola BigQuery driver
README 文档
README
Keboola high level storage backend driver for Big Query
Install dependencies.
docker compose run --rm dev composer install
Setup Big Query
Install Google Cloud client (via Brew), initialize it and log in to generate default credentials.
To prepare the backend use Terraform template. Create a sub folder in the KBC Team Dev (id: 431160969986) folder and fill the folder into the terraform command.
- get missing pieces (organization_id and billing_id) from Connection repository.
- (optional) move
bq-storage-backend-init.tfout of project directory so new files would be out of git - Run
terraform init - Run
terraform apply -var folder_id=[folder_id] -var billing_account_id=[billing_id] -var backend_prefix=<your prefix, eg. kbc-js> -var file_storage_backend_region=<desired region>(e.g. us-central1 region)- Optionally set
terraform.tfvarsfile with variables there is predefinedterraform.tfvars.distfile
- Optionally set
- New key files was created
principal_key.jsonandbig_query_key.json - Set envs from the
principal_key.jsonandbig_query_key.jsonby runningphp SetBQVars.phpand stop. OR continue with following steps with manual extraction. - open
principal_key.jsonset content ofprivate_keyas variableBQ_SECRETand remove (the whole entry) it from json file- note: simply cut&paste it whole even with the quotes and new lines -> your .env will be like
BQ_SECRET="-----BEGIN PRIVATE KEY-----XXXXZQ==\n-----END PRIVATE KEY-----\n"
- note: simply cut&paste it whole even with the quotes and new lines -> your .env will be like
- remove line breaks from the rest of key file (without
private_keyentry) and set this string as variableBQ_PRINCIPALto.env- You can convert the key to string with
awk -v RS= '{$1=$1}1' principal_key.json
- You can convert the key to string with
- remove line breaks from the
big_query_key.jsonkey file and set this string as variableBQ_KEY_FILEto.env- You can convert the key to string with
awk -v RS= '{$1=$1}1' big_query_key.json
- You can convert the key to string with
At the end, your .env file should look like...
# the id is printed by terraform at the end and it is just the numbers after `folders/` BQ_PRINCIPAL=<the content of the principal_key.json key file as single line without private_key entry> BQ_SECRET=<private_key from principal_key.json key file (taken from BQ_PRINCIPAL)> BQ_FOLDER_ID=<TF output file_storage_bucket_id : the id of the created folder, just the number, without /folders prefix> BQ_BUCKET_NAME=<TF output file_storage_bucket_id : bucket id created in main project> # choose different BQ_STACK_PREFIX than you Terraform prefix otherwise project created by Terraform will be deleted . e.g. local :) BQ_STACK_PREFIX=local BQ_KEY_FILE=<big_query_key.json file owned by main service acc>
All done. Now you can try composer loadGcs script and run tests.
docker compose run --rm dev composer loadGcs
Build docker images
docker compose build
Xdebug
To run with xdebug use dev-xdebug container instead of dev
Tests
Run tests with following command.
# This will run all tests docker compose run --rm dev composer tests # This will run all tests in parallel docker compose run --rm dev composer paratest # This will run import tests in parallel docker compose run --rm dev composer paratest-import # This will run export tests in parallel docker compose run --rm dev composer paratest-export # This will run all tests in parallel excluding import and export docker compose run --rm dev composer paratest-other
To disable retry copy phpunit-retry.xml.dist
cp phpunit-retry.xml.dist phpunit-retry.xml
Local development with libraries changes
When doing local development and you want to use local changes in php-storage-driver-common or php-table-backend-utils packages, you can symlink them into the container.
# remove vendor folder rm -r ./vendor/keboola/storage-driver-common rm -r ./vendor/keboola/table-backend-utils # symlink local proto folder ln -s /home/<project_path>/keboola/storage-backend/packages/php-storage-driver-common ./vendor/keboola/storage-driver-common ln -s /home/<project_path>/keboola/storage-backend/packages/php-table-backend-utils ./vendor/keboola/table-backend-utils # create docker-compose.override.yml file with following content # it is needed to mount local packages into the container cat > docker-compose.override.yml <<EOF services: dev: volumes: - /home/<project_path>/keboola/storage-backend/packages/php-storage-driver-common:/home/<project_path>/keboola/storage-backend/packages/php-storage-driver-common - /home/<project_path>/keboola/storage-backend/packages/php-table-backend-utils:/home/<project_path>/keboola/storage-backend/packages/php-table-backend-utils EOF
Code quality check
#run all bellow but not tests docker compose run --rm dev composer check #phplint docker compose run --rm dev composer phplint #phpcs docker compose run --rm dev composer phpcs #phpcbf docker compose run --rm dev composer phpcbf #phpstan docker compose run --rm dev composer phpstan
Full CI workflow
This command will run all checks and run tests
docker compose run --rm dev composer ci
Using
Project ID: A globally unique identifier for your project. This lib creating project id as combinations of stackPrefix and projectId from CreateProjectCommand
A project ID is a unique string used to differentiate your project from all others in Google Cloud. You can use the Google Cloud console to generate a project ID, or you can choose your own. You can only modify the project ID when you're creating the project.
Project ID requirements:
- Must be 6 to 30 characters in length.
- Can only contain lowercase letters, numbers, and hyphens.
- Must start with a letter.
- Cannot end with a hyphen.
- Cannot be in use or previously used; this includes deleted projects.
- Cannot contain restricted strings, such as
googleandssl.
License
MIT licensed, see LICENSE file.
统计信息
- 总下载量: 8.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-30