Acehaidrey opened a new pull request #18916:
URL: https://github.com/apache/airflow/pull/18916


   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   The purpose of this PR is to add the ability to import and export roles to 
and from the DB to a JSON file locally.
   The reason why at Pinterest we need this flexibility is that our production 
environment have a lot of different team roles from all the different 
organizations. Then we have users bring up their own dev environments, but when 
they load the dags (mono-repo), the dags will fail due to the roles not 
existing. So part of our deploy tools for users to setup their dev 
environments, we import the roles from a central file. I.e. we export the roles 
from the production periodically to a file that we push to s3, and then for 
dev, we import the roles from that file.
   We keep it as local file to maintain flexibility. We also use this feature 
to just backup the roles in case.
   We do not allow dev hosts talk to the productions dbs/hosts for security and 
permission concerns.
   
   Some examples of the use case:
   ```
   Step 1 : airflow roles list
   Existing roles:
   ╒════════════╕
   │ Role │
   ╞════════════╡
   │ Admin │
   ├────────────┤
   │ Op │
   ├────────────┤
   │ Public │
   ├────────────┤
   │ User │
   ├────────────┤
   │ Viewer │
   ├────────────┤
   │ test2_role │
   ├────────────┤
   │ test3_role │
   ├────────────┤
   │ test_role │
   ╘════════════╛
   
   Step 2: airflow roles export ./test.json
   3 roles successfully exported to ./test.json
   
   check: cat ./test.json
   [
   "test2_role",
   "test3_role",
   "test_role"
   ]
   
   ->. modify the test.json to :
   [
   "test2_role",
   "test3_role",
   "test4_role",
   "test_role"
   ]
   
   Step 3: airflow roles import ./test.json
   roles '['test4_role']' successfully imported
   
   Step 4 (sanity): airflow roles list
   ╒════════════╕
   │ Role │
   ╞════════════╡
   │ Admin │
   ├────────────┤
   │ Op │
   ├────────────┤
   │ Public │
   ├────────────┤
   │ User │
   ├────────────┤
   │ Viewer │
   ├────────────┤
   │ test2_role │
   ├────────────┤
   │ test3_role │
   ├────────────┤
   │ test4_role │
   ├────────────┤
   │ test_role │
   ╘════════════╛
   ```
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)**
 for more information.
   In case of fundamental code change, Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals))
 is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party 
License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in 
[UPDATING.md](https://github.com/apache/airflow/blob/main/UPDATING.md).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to