From 0baf2741d811a29e3cd048cfbb7617e95c1d7c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Biarda?= <1135380+michalbiarda@users.noreply.github.com> Date: Thu, 21 Jul 2022 12:19:45 +0200 Subject: [PATCH] #25 - Documentation enhancements, changed default pipeline name to `build` and removed duplicated pipeline configuration --- .driver/config.yaml | 4 +- .driver/connections.yaml.dist | 43 +++ .driver/connections.yaml.example | 24 ++ .driver/environments.yaml.dist | 14 + .driver/environments.yaml.example | 76 ++++++ .driver/pipelines.yaml | 51 +--- LICENSE | 201 -------------- LICENSE.MD | 177 +++++++++++++ README.md | 418 ++++++++++-------------------- composer.json | 6 +- docs/aws-setup.md | 44 ++++ docs/development.md | 124 +++++++++ src/Pipeline/Master.php | 51 ++-- 13 files changed, 662 insertions(+), 571 deletions(-) create mode 100644 .driver/connections.yaml.dist create mode 100644 .driver/connections.yaml.example create mode 100644 .driver/environments.yaml.dist create mode 100644 .driver/environments.yaml.example delete mode 100644 LICENSE create mode 100644 LICENSE.MD create mode 100644 docs/aws-setup.md create mode 100644 docs/development.md diff --git a/.driver/config.yaml b/.driver/config.yaml index 44ba3ab..a7fd7f9 100644 --- a/.driver/config.yaml +++ b/.driver/config.yaml @@ -1,2 +1,4 @@ +configuration: + compress-output: true test: - value: unknown \ No newline at end of file + value: unknown diff --git a/.driver/connections.yaml.dist b/.driver/connections.yaml.dist new file mode 100644 index 0000000..f4c30db --- /dev/null +++ b/.driver/connections.yaml.dist @@ -0,0 +1,43 @@ +connections: + database: mysql # Currently, this is the only supported engine. + webhooks: # OPTIONAL + post-url: # When the process is complete, Driver will ping this URL. + transform-url: # During the transformation process, Driver will ping this URL with connection information. + # You could write your own scripts to be executed at this URL. + auth: + user: # For HTTP basic authentication + password: # For HTTP basic authentication + mysql: # Source database connection information + database: # REQUIRED: database name + charset: # defaults to utf8 + engine: mysql + port: # defaults to 3306 + host: # defaults to 127.0.0.1 + user: # REQUIRED: database username + password: # REQUIRED: database password + dump-path: # Where to put the dumps while they are transitioning between the server and RDS, defaults to /tmp + s3: + engine: s3 + key: # REQUIRED: your S3 login key (can be the same as RDS if both access policies are allowed) + secret: # REQUIRED: your S3 login secret + bucket: # REQUIRED: which bucket would like this dumped into? + region: # defaults to us-east-1 + compressed-file-key: # name in the bucket for a compressed file, e.g. dump{{environment}}.sql.gz + uncompressed-file-key: # name for an uncompressed file, e.g. dump{{environment}}.sql + # It is recommended to include {{environment}} in the filename to avoid multiple environments overwriting the file. + rds: + key: # REQUIRED: your RDS login key + secret: # REQUIRED: your RDS login secret + region: #defaults to us-east-1 + ## BEGIN NEW RDS INSTANCE: + instance-type: # defaults to db.t3.medium, other options can be found at https://aws.amazon.com/rds/instance-types/ + engine: # defaults to MySQL + storage-type: # defaults to gp2 + ## END NEW RDS INSTANCE + ## BEGIN EXISTING RDS INSTANCE: + instance-identifier: + instance-username: + instance-password: + instance-db-name: + security-group-name: + ## END EXISTING RDS INSTANCE diff --git a/.driver/connections.yaml.example b/.driver/connections.yaml.example new file mode 100644 index 0000000..6b80437 --- /dev/null +++ b/.driver/connections.yaml.example @@ -0,0 +1,24 @@ +connections: + database: mysql + mysql: + engine: mysql + host: localhost + database: some_db + user: some_user + password: "sdf93mSDF,os,of3Spwer/df" + s3: + engine: s3 + key: SDF83K0N3IDSL29ZMEIH + secret: "kF9kwnf,mo3fFoaow+3mda/439a,Dlwommw9021m" + bucket: some-bucket + compressed-file-key: dump{{environment}}.sql.gz + uncompressed-file-key: dump{{environment}}.sql + region: us-east-2 + rds: + key: SDF83K0N3IDSL29ZMEIH + secret: "kF9kwnf,mo3fFoaow+3mda/439a,Dlwommw9021m" + region: us-east-2 + ec2: + key: SDF83K0N3IDSL29ZMEIH + secret: "kF9kwnf,mo3fFoaow+3mda/439a,Dlwommw9021m" + region: us-east-2 diff --git a/.driver/environments.yaml.dist b/.driver/environments.yaml.dist new file mode 100644 index 0000000..a24ee19 --- /dev/null +++ b/.driver/environments.yaml.dist @@ -0,0 +1,14 @@ +environments: + ENVIRONMENT_NAME: # Change ENVIRONMENT_NAME to some concrete name like "local", you can define multiple environments. + sort: # REQUIRED: numeric value, lower runs sooner, higher runs later. + transformations: # OPTIONAL + TABLE_NAME: # Change TABLE_NAME to real name of database table you would like to transform with SQL query. + # You can define multiple tables. + - "UPDATE {{table_name}} SET value = 'example' WHERE path = 'id';" # You can list here multiple UPDATE queries. + # The {{table_name}} is substituted for the `TABLE_NAME` reference above. + # Driver will look for a table that ends with `TABLE_NAME`. + # For example, if your `TABLE_NAME` is `core_config_data`, Driver will search for a table in the database that + # ends with `core_config_data`. Thus, `core_config_data` and `sample_core_config_data` would all match. + ignored_tables: # OPTIONAL, tables listed here will be ignored in the final dump with: + # mysqldump ... --ignored-tables=DATABASE.table_1 + - TABLE_NAME diff --git a/.driver/environments.yaml.example b/.driver/environments.yaml.example new file mode 100644 index 0000000..833d7dd --- /dev/null +++ b/.driver/environments.yaml.example @@ -0,0 +1,76 @@ +environments: + staging: + sort: 100 + transformations: + mview_state: + - "UPDATE {{table_name}} SET mode = 'disabled';" + core_config_data: + - "UPDATE {{table_name}} SET value = 'https://staging.store.com/' WHERE path LIKE 'web/%secure/base_url' AND scope_id = 0;" + - "UPDATE {{table_name}} SET value = 'staging.store.com' WHERE path LIKE 'web/cookie/cookie_domain' AND scope_id = 0;" + local: + sort: 200 + transformations: + admin_user: + - "DELETE FROM {{table_name}};" + - "ALTER TABLE {{table_name}} AUTO_INCREMENT = 1;" + - "INSERT INTO {{table_name}} (firstname, lastname, email, username, password) VALUES ('SwiftOtter', 'Studios', 'joseph@swiftotter.com', 'admin', CONCAT(SHA2('xxxxxxxxswiftotter123', 256), ':xxxxxxxx:1'));" + authorization_role: + - "DELETE FROM {{table_name}};" + - "ALTER TABLE {{table_name}} AUTO_INCREMENT = 1;" + - "INSERT INTO {{table_name}} (role_id, parent_id, tree_level, sort_order, role_type, user_id, user_type, role_name) VALUES (1, '0','1','1','G','0','2','Administrators');" + - "INSERT INTO {{table_name}} (role_id, parent_id, tree_level, sort_order, role_type, user_id, user_type, role_name) VALUES (2, '1','2','0','U','1','2','swiftotter');" + authorization_rule: + - "DELETE FROM {{table_name}};" + - "ALTER TABLE {{table_name}} AUTO_INCREMENT = 1;" + - "INSERT INTO {{table_name}} (role_id, resource_id, permission) VALUES ('1', 'Magento_Backend::all', 'allow');" + - "INSERT INTO {{table_name}} (role_id, resource_id, permission) VALUES ('2', 'Magento_Backend::all', 'allow');" + core_config_data: + - "UPDATE {{table_name}} SET value = 'https://store.local/' WHERE path LIKE 'web/%secure/base_url' AND scope_id = 0;" + - "UPDATE {{table_name}} SET value = 'store.local' WHERE path LIKE 'web/cookie/cookie_domain' AND scope_id = 0;" + - "UPDATE {{table_name}} SET value = 'localhost' WHERE path LIKE 'catalog/search/elasticsearch%_server_hostname' AND scope_id = 0;" + ignored_tables: + - setup_module + - customer_address_entity + - customer_address_entity_datetime + - customer_address_entity_decimal + - customer_address_entity_int + - customer_address_entity_text + - customer_address_entity_varchar + - customer_entity + - customer_entity_datetime + - customer_entity_decimal + - customer_entity_int + - customer_entity_text + - customer_entity_varchar + - sales_creditmemo + - sales_credimemo_comment + - sales_creditmemo_grid + - sales_creditmemo_item + - sales_invoice + - sales_invoice_comment + - sales_invoice_grid + - sales_invoice_item + - sales_order + - sales_order_address + - sales_order_grid + - sales_order_item + - sales_order_payment + - sales_order_status_history + - sales_shipment + - sales_shipment_comment + - sales_shipment_grid + - sales_shipment_item + - sales_shipment_track + - sales_invoiced_aggregated + - sales_invoiced_aggregated_order + - sales_payment_transaction + - sales_order_aggregated_created + - sales_order_tax + - sales_order_tax_item + - sales_quote + - sales_quote_address + - sales_quote_address_item + - sales_quote_item + - sales_quote_item_option + - sales_quote_payment + - sales_quote_shipping_rate diff --git a/.driver/pipelines.yaml b/.driver/pipelines.yaml index 786916b..497fd0f 100755 --- a/.driver/pipelines.yaml +++ b/.driver/pipelines.yaml @@ -7,55 +7,8 @@ # at specific environments (like staging and local). pipelines: - default: # pipeline span, usually default is the only one - - name: setup # pipeline stage - sort: 100 - actions: - - name: connect - sort: 100 - - name: check-filesystem - sort: 200 - - name: start-sandbox - sort: 300 - - - name: import - sort: 200 - actions: - - name: export-data-from-system-primary - sort: 100 - - name: import-data-into-sandbox - sort: 200 - - - name: global-commands - sort: 300 - actions: - - name: reduce - sort: 100 - - name: anonymize - sort: 200 - - name: update-values - sort: 300 - - - name: repeat-commands - sort: 400 - actions: - - name: run-transformations - sort: 100 - - name: connect - sort: 200 - - name: export-data-from-sandbox - sort: 300 - - name: upload-data-to-s3 - sort: 400 - - - name: shutdown - sort: 600 - actions: - - name: shutdown-sandbox - sort: 100 - - tag: # pipeline span, usually default is the only one - - name: setup # pipeline stage + build: + - name: setup sort: 100 actions: - name: connect diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 8dada3e..0000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/LICENSE.MD b/LICENSE.MD new file mode 100644 index 0000000..1f51529 --- /dev/null +++ b/LICENSE.MD @@ -0,0 +1,177 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/README.md b/README.md index 1bca767..3fd23a8 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,64 @@ # Driver -### A database task-runner +Driver is a database task-runner that helps you to turn production database into a staging/development database sandbox. + +## Description Driver is the easy way to turn a production database into a staging or development-friendly database. It is built with the aim of complete flexibility. Additionally, with the built-in capability of working with RDS, Driver can run transformations on database host that is completely separate from your production environment. -Because Driver is a task-runner, there is a good chance that you will need to create some tasks to run. -There are some additional modules out there to help you with this. You will also need to specify configuration. - -## TL;DR +Driver resides on your production machine, with your website's codebase (via Composer). +You set up a CRON job to run Driver. -Driver resides on your production machine, preferrably with your website's codebase (via composer). You setup a cron job to run Driver. - -* **Driver connects to your production database ONCE via `mysqldump`.** +* Driver connects to your production database ONCE via `mysqldump`. * Driver dumps that to a file on your system. -* Driver creates a RDS instance and pushes the database dump up to RDS (via **https**). +* Driver creates an RDS instance and pushes the database dump up to RDS (via https). * Driver runs whatever actions you would like (configured globally or per environment). * Driver dumps the transformed data, zips it and pushes it up to S3. +* You can then download transformed dump from S3 to your staging/development machine, also using Driver. -For a 3-5GB database, this process could take an hour or two. This depends on how many environments you are creating and what type of RDS instance you are using. This causes no downtime to the frontend thanks to the `--single-transaction` flag on `mysqldump`. Yes, it does take a while to run, but there is little tono impact on the frontend. +For a 3-5GB database, this process could take an hour or two. +This depends on how many environments you are creating and what type of RDS instance you are using. +This causes no downtime to the frontend thanks to the `--single-transaction` flag on `mysqldump`. +Yes, it does take a while to run, but there is little-to-no impact on the frontend. -## Quickstart +## Before We Start -Downloading a Driver-created file is quite simple: -```bash -./vendor/bin/driver run --environment=local [or whatever environment that's been configured] import-s3 -``` +At Swift Otter we mainly work with Magento 2. We created separate repo for Magento 2 Driver transformations. +It includes config for anonymization of all database tables of core Magento 2 system. If you are Magento 2 developer, +we recommend you to install that repo, instead of this one (Driver would be installed anyway, as it is a dependency +of that Magento 2 repo). If you're not a Magento 2 developer, we still recommend you to look at that repo to get +a better idea on how things can be configured for your project. -Installing Driver is easy: -``` -composer require swiftotter/driver -``` +Magento 2 Driver transformations repo can be found [here](https://github.com/swiftotter/Driver-Magento2). -Configuring Driver is easy. In the folder that contains your `vendor/` folder, create a folder called `.driver`. -First, you need to create an Amazon AWS account. We will be using RDS to perform the data manipulations. It is -recommended to create a new IAM user with appropriate permissions to access EC2, RDS and S3 (exact permissions -will be coming). - -Place inside it a file with the following information (replacing all of the brackets and their content): -```yaml -# -connections: - database: mysql - mysql: - engine: mysql - database: [DATABASE_NAME] - user: [DATABASE_USER] - password: [DATABASE_PASSWORD] - s3: - engine: s3 - key: [IAM_KEY] - secret: [IAM_KEY] - bucket: [YOUR_BUCKET] - compressed-file-key: sample.gz - uncompressed-file-key: sample.sql - region: us-east-1 - rds: - key: [IAM_KEY] - secret: [IAM_KEY] - region: us-east-1 - ec2: - key: [IAM_KEY] - secret: [IAM_KEY] - region: us-east-1 -``` +## Getting Started -It should run! Be prepared for it to take some time (on the order of hours). -``` -./vendor/bin/driver run -``` +### Dependencies -You can run a specific pipeline. If you use the `default` pipeline, then you don't have to specify the pipeline. Included is a `tag` pipeline to generate one database snapshot. -```bash -./vendor/bin/driver run tag - /\ environment name -``` +- PHP 7.4 or higher + +### Prerequisites + +You need to create an Amazon AWS account. We will be using RDS to perform the data manipulations. +It is recommended to create a new IAM user with appropriate permissions to access EC2, RDS and S3 +(exact permissions will be coming). This is explained in details [here](docs/aws-setup.md). + +### Installation -To tag an export with an issue number (or whatever is desired): ```bash -./vendor/bin/driver run tag --tag=DEV-1234 +composer require swiftotter/driver ``` -## Connection Information +### Configuration + +#### Overview of Config Structure + +Driver configuration goes into a folder named `.driver`. +The files that are recognized inside this folder are: -Connection information goes into a folder named `.driver`. The files that are recognized -inside these folders are: * `anonymize.yaml` * `commands.yaml` * `config.yaml` @@ -110,223 +82,37 @@ files: * `/var/www/.driver/` * `/var/www/vendor/*/*/.driver/` -You can symlink any file you want here. Keep in mind that these files do contain sensitive information and -it is necessary to include a `.htaccess` into that folder: -`Deny from all` - -## AWS Setup - -Driver's default implementation is to use AWS for the database transformation (RDS) and the storage of the transformed -databases (S3). - -You will need to do two things in your AWS control panel: -1. Create a new policy. -2. Assign that policy to a new user. - -### Policy Creation - -Open your control panel and go to IAM. Click on the Policies tab on the sidebar. Choose to Create New Policy. -Select Create Your Own Policy (if you want to use the one below) and enter the following code. - -```json -{ - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Action": [ - "ec2:AuthorizeSecurityGroupIngress", - "ec2:CreateSecurityGroup", - "s3:GetObject", - "s3:PutObject", - "rds:CreateDBInstance", - "rds:DeleteDBInstance", - "rds:DescribeDBInstances" - ], - "Resource": [ - "*" - ] - } - ] -} -``` - -### User Creation - -In the IAM control panel, click on the Users tab. Select Add user. Choose a username. This will only be seen by you -in the control panel. Check the Programmatic access as Driver will be needing a access key ID and a secret access key. -Select Add existing policies directly and choose your newly-created policy. Review it and then create the user. - -Place the Access key ID and Secret access key in your configuration. - - -### Connection Reference - -```yaml -configuration: - compress-output: true # if set, the output will be compressed and the compressed-file-key will be used. - -connections: - database: mysql # Currently, this is the only supported engine. - webhooks: - post-url: https://whatever-your-site-is.com # When the process is complete, Driver will ping this url. - transform-url: # During the transformation process, Driver will ping this url with connection information. - # You could write your own scripts to be executed at this url. - auth: - user: # for HTTP basic authentication - password: # for HTTP basic authentication - mysql: # Source database connection information - database: your_database_name # REQUIRED - charset: # defaults to utf8 - engine: mysql - port: # defaults to 3306 - host: # defaults to 127.0.0.1 - user: # REQUIRED: database username - password: # REQUIRED: database password - dump-path: /tmp # Where to put the dumps while they are transitioning between the server and RDS - s3: - engine: s3 - key: # REQUIRED: your S3 login key (can be the same as RDS if both access policies are allowed) - secret: # REQUIRED: your S3 login secret - bucket: # REQUIRED: which bucket would like this dumped into? - region: # defaults to us-east-1 - compressed-file-key: # name in the bucket for a compressed file. - uncompressed-file-key: # name for an uncompressed file. - # It is recommended to include {{environment}} in the filename to avoid multiple environments overwriting the file. - rds: - key: # REQUIRED: your RDS login key - secret: # REQUIRED: your RDS login secret - region: #defaults to us-east-1 - ## BEGIN NEW RDS INSTANCE: - instance-type: # REQUIRED: choose from left column in https://aws.amazon.com/rds/details/#DB_Instance_Classes - engine: MySQL - storage-type: gp2 - ## END NEW RDS INSTANCE - ## BEGIN EXISTING RDS INSTANCE: - instance-identifier: - instance-username: - instance-password: - instance-db-name: - security-group-name: - ## END EXISTING RDS INSTANCE -``` - -### Terminology - -* **Pipeline** (specified in `pipelines.yaml`): a series of stages. Representative of the work to take a production database and transform it. These are found under the `pipelines` node. You can execute a specific pipeline with the `--pipeline` argument in the command line. -* **Stage**: groups of actions inside of a pipeline. Stages are run sequentially Right now, Driver does work this way, but actions could run in parallel. -* **Action**: Specific command to run. - -### Modifying a existing pipeline - -`default` is the "default" pipeline. This may be all you need. The next section will talk about the syntax for creating a new pipeline. - -Here is an example of adding a custom action to the `default` pipeline: - -```yaml -commands: - reset-admin-password: - class: \YourApplication\Driver\Transformations\ResetAdminPassword - # ensure that: - # 1) the composer autoloader can find this class - # 2) your class implements \Driver\Commands\CommandInterface - # 3) it preferably extends \Symfony\Component\Console\Command\Command - -pipelines: - default: - - name: global-commands - # you can add stages or use an existing one. global-commands runs - # after the data has been pushed into RDS and before any transformations - # run. Keep in mind, you can create a new stage prefixed with "repeat-" - # and it will run it once per environment. - actions: - - name: reset-admin-password - # notice this name matches the name we added in commands - sort: 100 -``` - -### Creating a new pipeline - -The following is taken from `.driver/pipelines.yaml`. You can put this code in any of the `yaml` files that Driver reads. Just ensure that the -`pipelines` root node has no space in front of it (exactly as shown below). - -```yaml -pipelines: # root node - YOUR_PIPELINE_NAME: # pipeline span name - - name: setup # pipeline stage name - sort: 100 # sort order - actions: # stages / actions to run - - name: connect - sort: 100 - - name: check-filesystem - sort: 200 - - name: start-sandbox - sort: 300 - - - name: import - sort: 200 - actions: - - name: export-data-from-system-primary - sort: 100 - - name: import-data-into-sandbox - sort: 200 - - - name: global-commands - sort: 300 - actions: - - name: empty - sort: 1 - - - name: repeat-commands - sort: 400 - actions: - - name: run-transformations - sort: 1000 - - - name: repeat-export - sort: 400 - actions: - - name: export-data-from-sandbox - sort: 100 - - name: upload-data-to-s3 - sort: 200 - - - name: shutdown - sort: 500 - actions: - - name: shutdown-sandbox - sort: 100 - -``` +You can symlink any file you want here. Keep in mind that these files do contain sensitive information, and +it is necessary to include a `.htaccess` into that folder: `Deny from all` +#### Connections Configuration -### Environments +You have to configure connections information for your project. +In the folder that contains your `vendor` folder, create a folder called `.driver`. +Next, copy the file `vendor/swiftotter/driver/.driver/connections.yaml.dist` to `.driver/connections.yaml` +and fill it in with your source MySQL information, as well as destination EC2, RDS and S3 data. -Ok, so Driver sounds really cool to create you a staging database. But, what about a database for the devs? There is a few changes for that: we want to clear out all other admin users (and reset the remaining admin user's password) as well as set unique urls for the website and possibly other things. +Exemplary config can be found in `vendor/swiftotter/driver/.driver/connections.yaml.example`. -There is a solution for that, too. Environments allow you to easily make modifications to the database, per-site. +#### Environments Configuration -**Note:** you can execute specific commands per environment. These changes do not revert for each environment, but rather they are applied according to their sort order. If one environment uses the data in the `admin_users` table, and another environment clears out all data in the `admin_users` table, you set the sort order for the first table lower (ex. `100`) and the sort order for the second table higher (ex. `200`). +Environments allow to make modifications to the database, per-site. You can configure different set of actions for every +environment. For example, for local environment you may want to clear out all admin users as well as set unique URLs +for the website and possibly other things. +**Note:** You can execute specific commands per environment. These changes do not revert for each environment, +but rather they are applied according to their sort order. If one environment uses the data in the `admin_users` table, +and another environment clears out all data in the `admin_users` table, you set the sort order for the first environment +lower (ex. `100`) and the sort order for the second environment higher (ex. `200`). -#### Environment Reference: +To configure your environments copy the file `vendor/swiftotter/driver/.driver/environments.yaml.dist` +to `.driver/environments.yaml` and fill it in with your environments data. -```yaml -environments: - ENVIRONMENT_NAME: - sort: # lower runs sooner, higher runs later - transformations: - TABLE_NAME: - - "UPDATE {{table_name}} SET value = 'test-value' WHERE path = 'id';" - ignored_tables: - # These are ignored in the final dump: mysqldump ... --ignored-tables=DATABASE.table_1 - - table_1 - - table_2 -``` +Exemplary config can be found in `vendor/swiftotter/driver/.driver/environments.yaml.example`. -### Anonymizing Data +#### Anonymization Configuration -Tables can be anonymized by creating `anonymize.yaml` in `.driver/`. The following type of anonymization entities +Tables can be anonymized by creating `anonymize.yaml` file in `.driver/`. The following type of anonymization entities are available in order to provide realistic data and types: * `email` @@ -344,22 +130,86 @@ are available in order to provide realistic data and types: **Example File** ``` anonymize: - tables: - quote: - customer_email: - type: email - remote_ip: - type: ip + tables: + quote: + customer_email: + type: email + remote_ip: + type: ip +``` + +#### Post-Anonymization Values Updates Configuration + +Sometimes in your database you can store in a single field some value that was originally built by concatenating +fields from different tables, eg. `full_name` or `shipping_address`. Driver allows to run some specific values updates +after anonymization of simple fields is finished. Thanks to this feature you can anonymize such complex fields too. + +To create post-anonymization values updates, create `update_values.yaml` file in `.driver/`. + +**Example File** +``` +update-values: + tables: + customer_grid_flat: + joins: + - table: customer_entity + alias: c + on: c.entity_id = customer_grid_flat.entity_id + - table: customer_address_entity + alias: ba + on: ba.entity_id = c.default_billing + - table: customer_address_entity + alias: sa + on: sa.entity_id = c.default_shipping + values: + - field: name + value: CONCAT_WS(' ', c.firstname, c.lastname) + - field: shipping_full + value: CONCAT(sa.street, ', ', sa.city, ', ', IFNULL(sa.region, '-'), ' ', sa.postcode, ', ', sa.country_id) + - field: billing_full + value: CONCAT(ba.street, ', ', ba.city, ', ', IFNULL(ba.region, '-'), ' ', ba.postcode, ', ', ba.country_id) +``` + +## Usage + +### Building Database Sandboxes For All Environments + +Be prepared for it to take some time (on the order of hours). + +``` +./vendor/bin/driver run +``` + +### Building Database Sandbox For Single Environment + +```bash +./vendor/bin/driver run build --environment=envname +``` + +where `envname` is one of the environments defined in `environments.yaml` config file. + +### Tagging Database Sandbox + +Sandboxes built with a tag will include the tag in the file name. + +```bash +./vendor/bin/driver run build --tag=tagname ``` +where `tagname` is an issue number (or whatever is desired). -**Notes:** -* The `{{table_name}}` is substituted for the `TABLE_NAME` reference above. Driver will look for a table that **ends** with `TABLE_NAME`. For example, if your `TABLE_NAME` is `core_config_data`, Driver will search for a table in the database that ends with `core_config_data`. Thus, `mage_core_config_data`, `sample_core_config_data` and `core_config_data` would all match. +### Download and Import Sandbox Database from S3 to staging/local environment -### -#### Download and Import S3 uploaded database on STAGING/Local environment: +The below command run the export/import pipeline which download the database into your project `var/` directory, +create new database in MySQL, and import the downloaded database in it for your environment. -The below command run the export/import pipeline which download the database into your project var/ directory, create new database in mysql, and import the downloaded database in it for your environment. ``` -./vendor/bin/driver run import-s3 +./vendor/bin/driver run import-s3 --environment=envname --tag=tagname ``` + +`tag` is optional. + +## Contribution + +We welcome you to contribute in Driver development. You can find some handy information for developers +[here](docs/development.md). diff --git a/composer.json b/composer.json index 19b2bb2..6d5504a 100755 --- a/composer.json +++ b/composer.json @@ -1,8 +1,10 @@ { "name": "swiftotter/driver", - "description": "A database production to sandbox utility to sanitize data.", + "description": "A database task-runner that helps you to turn production database into a staging/development database sandbox", + "license": "Apache-2.0", "type": "library", "require": { + "php": "^7.4|^8.0", "ext-pdo": "*", "php-di/php-di": "^6.0", "aws/aws-sdk-php": "^3.19", @@ -24,7 +26,7 @@ }, "authors": [ { - "name": "Joseph Maxwell", + "name": "SwiftOtter, Inc.", "email": "joseph@swiftotter.com" } ], diff --git a/docs/aws-setup.md b/docs/aws-setup.md new file mode 100644 index 0000000..18e7934 --- /dev/null +++ b/docs/aws-setup.md @@ -0,0 +1,44 @@ +# AWS Setup + +Driver's default implementation is to use AWS for the database transformation (RDS) and the storage of the transformed +databases (S3). + +You will need to do two things in your AWS control panel: +1. Create a new policy. +2. Assign that policy to a new user. + +## Policy Creation + +Open your control panel and go to IAM. Click on the Policies tab on the sidebar. Choose to Create New Policy. +Select Create Your Own Policy (if you want to use the one below) and enter the following code. + +```json +{ + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "ec2:AuthorizeSecurityGroupIngress", + "ec2:CreateSecurityGroup", + "s3:GetObject", + "s3:PutObject", + "rds:CreateDBInstance", + "rds:DeleteDBInstance", + "rds:DescribeDBInstances" + ], + "Resource": [ + "*" + ] + } + ] +} +``` + +## User Creation + +In the IAM control panel, click on the Users tab. Select Add user. Choose a username. This will only be seen by you +in the control panel. Check the Programmatic access as Driver will be needing a access key ID and a secret access key. +Select Add existing policies directly and choose your newly-created policy. Review it and then create the user. + +Place the Access key ID and Secret access key in your configuration. diff --git a/docs/development.md b/docs/development.md new file mode 100644 index 0000000..0aec4af --- /dev/null +++ b/docs/development.md @@ -0,0 +1,124 @@ +# Development + +If you're a Driver developer, here you will find some handy information that will help you with your work. + +## Terminology + +* **Pipeline** (specified in `.driver/pipelines.yaml`): a series of stages. Representative of the work to take a production database and transform it. These are found under the `pipelines` node. You can execute a specific pipeline with the `--pipeline` argument in the command line. +* **Stage**: groups of actions inside a pipeline. Stages are run sequentially. Right now, Driver does work this way, but actions could run in parallel. +* **Action**: Specific command to run. + +## Modifying an existing pipeline + +`build` is the "default" pipeline. This may be all you need. The next section will talk about the syntax for creating a new pipeline. + +Here is an example of adding a custom action to the `build` pipeline: + +```yaml +commands: + reset-admin-password: + class: \YourApplication\Driver\Transformations\ResetAdminPassword + # ensure that: + # 1) the composer autoloader can find this class + # 2) your class implements \Driver\Commands\CommandInterface + # 3) it preferably extends \Symfony\Component\Console\Command\Command + +pipelines: + build: + - name: global-commands + # you can add stages or use an existing one. global-commands runs + # after the data has been pushed into RDS and before any transformations + # run. Keep in mind, you can create a new stage prefixed with "repeat-" + # and it will run it once per environment. + actions: + - name: reset-admin-password + # notice this name matches the name we added in commands + sort: 100 +``` + +## Creating a new pipeline + +The following is taken from `.driver/pipelines.yaml`. You can put this code in any of the `yaml` files that Driver reads. +Just ensure that the `pipelines` root node has no space in front of it (exactly as shown below). + +```yaml +pipelines: # root node + YOUR_PIPELINE_NAME: # pipeline span name + - name: setup # pipeline stage name + sort: 100 # sort order + actions: # stages / actions to run + - name: connect + sort: 100 + - name: check-filesystem + sort: 200 + - name: start-sandbox + sort: 300 + + - name: import + sort: 200 + actions: + - name: export-data-from-system-primary + sort: 100 + - name: import-data-into-sandbox + sort: 200 + + - name: global-commands + sort: 300 + actions: + - name: empty + sort: 1 + + - name: repeat-commands + sort: 400 + actions: + - name: run-transformations + sort: 1000 + + - name: repeat-export + sort: 400 + actions: + - name: export-data-from-sandbox + sort: 100 + - name: upload-data-to-s3 + sort: 200 + + - name: shutdown + sort: 500 + actions: + - name: shutdown-sandbox + sort: 100 +``` + +## Debug Mode + +Working with AWS RDS is nice but super slow. For development purposes you can configure local database that will act +as RDS. All you need to do is to add the following to your `.driver/connections.yaml` config file: + +```yaml +connections: + mysql_debug: + engine: mysql + host: localhost + database: local_db + username: some_user + password: some_password +``` + +and then run `build` pipeline with `--debug` option, e.g.: + +```shell +./vendor/bin/driver run build --environment=local --debug +``` + +**Watchout!** Debug database should NOT be your local project's database. + +## Increasing Verbosity of Messages + +By default, Driver doesn't output much information to the user. +During development, we recommend to add `-vvv` to all commands you're running, e.g.: + +```shell +./vendor/bin/driver run build --environment=local --debug -vvv +``` + +This will show error and debug information. diff --git a/src/Pipeline/Master.php b/src/Pipeline/Master.php index 80ae513..347fa23 100644 --- a/src/Pipeline/Master.php +++ b/src/Pipeline/Master.php @@ -1,58 +1,41 @@ . - * - * @author Joseph Maxwell - * @copyright SwiftOtter Studios, 10/8/16 - * @package default - **/ + +declare(strict_types=1); namespace Driver\Pipeline; -use Driver\Pipeline\Exception\PipeLineNotFound as PipeLineNotFoundException; use Driver\Pipeline\Span\Factory as PipeLineSpanFactory; use Driver\Pipeline\Transport\Factory as TransportFactory; +use Driver\Pipeline\Transport\TransportInterface; use Driver\System\Configuration; class Master { - const EMPTY_NODE = 'empty'; - const DEFAULT_NODE = 'default'; - protected $configuration; - protected $pipeLineFactory; - protected $transportFactory; + const DEFAULT_NODE = 'build'; - public function __construct(Configuration $configuration, PipeLineSpanFactory $pipeLineFactory, TransportFactory $transportFactory) - { + private Configuration $configuration; + private PipeLineSpanFactory $pipeLineFactory; + private TransportFactory $transportFactory; + + public function __construct( + Configuration $configuration, + PipeLineSpanFactory $pipeLineFactory, + TransportFactory $transportFactory + ) { $this->configuration = $configuration; $this->pipeLineFactory = $pipeLineFactory; $this->transportFactory = $transportFactory; } - public function runDefault() - { - $this->run(self::DEFAULT_NODE); - } - - public function run($set) + public function run(string $set): void { $pipeline = $this->pipeLineFactory->create($set); - $transport = $pipeline($this->createTransport()); + $transport = $pipeline($this->createTransport($set)); $pipeline->cleanup($transport); } - protected function createTransport() + protected function createTransport(string $set): TransportInterface { - return $this->transportFactory->create(self::DEFAULT_NODE); + return $this->transportFactory->create($set); } }