Skip to content

Commit 68cfa95

Browse files
authored
Merge pull request #139 from rwnx/use-typer
CLI refactor
2 parents da51f34 + d5495eb commit 68cfa95

File tree

15 files changed

+297
-426
lines changed

15 files changed

+297
-426
lines changed

.github/workflows/pypi.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- uses: actions/checkout@v2
4444
- uses: actions/setup-python@v2
4545
with:
46-
python-version: '3.8'
46+
python-version: '3.12'
4747
- name: Setup MSSQL
4848
run: bash tests_integration/mssql/install_mssql.sh
4949
- name: Setup test env
@@ -62,7 +62,7 @@ jobs:
6262
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
6363

6464
runs-on: ubuntu-latest
65-
container: python:3.8
65+
container: python:3.12
6666
env:
6767
PYNONYMIZER_DB_HOST: db
6868
PYNONYMIZER_DB_USER: root
@@ -88,7 +88,7 @@ jobs:
8888
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
8989

9090
runs-on: ubuntu-latest
91-
container: python:3.8
91+
container: python:3.12
9292
env:
9393
PYNONYMIZER_DB_HOST: db
9494
PYNONYMIZER_DB_USER: postgres
@@ -104,7 +104,7 @@ jobs:
104104

105105
package:
106106
runs-on: ubuntu-latest
107-
container: python:3.8
107+
container: python:3.12
108108
needs:
109109
- test
110110
- integration-mysql
@@ -125,7 +125,7 @@ jobs:
125125
needs:
126126
- package
127127
runs-on: ubuntu-latest
128-
container: python:3.8
128+
container: python:3.12
129129
steps:
130130
- uses: actions/download-artifact@v2
131131
with:

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2020
- Better error messages for unsupported fake types - the error should now explain the problem and link to the docs in the right section. [#133]
2121
- Error message for when a fake_type is used with the wrong config kwargs (these would have previously been caught under "unsupported fake types")
2222

23+
### Removed
24+
- Positional INPUT. Use the -i/--input option instead
25+
- Positional STRATEGYFILE. Use the -s/--strategy option instead
26+
- Positional OUTPUT. Use the -o/--output option instead
27+
- Deprecated environment keys: `DB_TYPE, DB_HOST, DB_NAME, DB_USER, DB_PASS`.
28+
- `--fake-locale` `-l` `$PYNONYMIZER_FAKE_LOCALE` cli option. Use the `locale:` key in your strategyfile instead
29+
30+
### Changed
31+
- environment vars
32+
2333
## [1.25.0] 2023-03-29
2434
### Changed
2535
- Postgres FAKE_UPDATE strategy now uses an id-based randomization to pick from the seed table.

README.md

Lines changed: 2 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -104,104 +104,9 @@ If this workflow doesnt work for you, see [process control](https://github.com/r
104104
## Usage
105105
### CLI
106106
1. Write a [strategyfile](https://github.com/rwnx/pynonymizer/blob/main/doc/strategyfiles.md) for your database
107+
1. Check out the help for a description of options `pynonymizer --help`
107108
1. Start Anonymizing!
108-
```
109-
usage: pynonymizer [-h] [--input INPUT] [--strategy STRATEGYFILE]
110-
[--output OUTPUT] [--db-type DB_TYPE] [--db-host DB_HOST]
111-
[--db-port DB_PORT] [--db-name DB_NAME] [--db-user DB_USER]
112-
[--db-password DB_PASSWORD] [--fake-locale FAKE_LOCALE]
113-
[--start-at STEP] [--only-step STEP]
114-
[--skip-steps STEP [STEP ...]] [--stop-at STEP]
115-
[--seed-rows SEED_ROWS] [--mssql-driver MSSQL_DRIVER]
116-
[--mssql-backup-compression]
117-
[--mysql-cmd-opts MYSQL_CMD_OPTS]
118-
[--mysql-dump-opts MYSQL_DUMP_OPTS]
119-
[--postgres-cmd-opts POSTGRES_CMD_OPTS]
120-
[--postgres-dump-opts POSTGRES_DUMP_OPTS] [-v] [--verbose]
121-
[--dry-run] [--ignore-anonymization-errors]
122-
123-
A tool for writing better anonymization strategies for your production
124-
databases.
125-
126-
optional arguments:
127-
-h, --help show this help message and exit
128-
--input INPUT, -i INPUT
129-
The source dump filepath to read from. Use `-` for
130-
stdin. [$PYNONYMIZER_INPUT]
131-
--strategy STRATEGYFILE, -s STRATEGYFILE
132-
A strategyfile to use during anonymization.
133-
[$PYNONYMIZER_STRATEGY]
134-
--output OUTPUT, -o OUTPUT
135-
The destination filepath to write the dumped output
136-
to. Use `-` for stdout. [$PYNONYMIZER_OUTPUT]
137-
--db-type DB_TYPE, -t DB_TYPE
138-
Type of database to interact with. More databases will
139-
be supported in future versions. default: mysql
140-
[$PYNONYMIZER_DB_TYPE]
141-
--db-host DB_HOST, -d DB_HOST
142-
Database hostname or IP address.
143-
[$PYNONYMIZER_DB_HOST]
144-
--db-port DB_PORT, -P DB_PORT
145-
Database port. Defaults to provider default.
146-
[$PYNONYMIZER_DB_PORT]
147-
--db-name DB_NAME, -n DB_NAME
148-
Name of database to restore and anonymize in. If not
149-
provided, a unique name will be generated from the
150-
strategy name. This will be dropped at the end of the
151-
run. [$PYNONYMIZER_DB_NAME]
152-
--db-user DB_USER, -u DB_USER
153-
Database credentials: username. [$PYNONYMIZER_DB_USER]
154-
--db-password DB_PASSWORD, -p DB_PASSWORD
155-
Database credentials: password.
156-
[$PYNONYMIZER_DB_PASSWORD]
157-
--fake-locale FAKE_LOCALE, -l FAKE_LOCALE
158-
Locale setting to initialize fake data generation.
159-
Affects Names, addresses, formats, etc.
160-
[$PYNONYMIZER_FAKE_LOCALE]
161-
--start-at STEP Choose a step to begin the process (inclusive).
162-
[$PYNONYMIZER_START_AT]
163-
--only-step STEP Choose one step to perform. [$PYNONYMIZER_ONLY_STEP]
164-
--skip-steps STEP [STEP ...]
165-
Choose one or more steps to skip.
166-
[$PYNONYMIZER_SKIP_STEPS]
167-
--stop-at STEP Choose a step to stop at (inclusive).
168-
[$PYNONYMIZER_STOP_AT]
169-
--seed-rows SEED_ROWS
170-
Specify a number of rows to populate the fake data
171-
table used during anonymization. Defaults to 150.
172-
[$PYNONYMIZER_SEED_ROWS]
173-
--mssql-driver MSSQL_DRIVER
174-
[MSSQL] ODBC driver to use for database connection
175-
[$PYNONYMIZER_MSSQL_DRIVER]
176-
--mssql-backup-compression
177-
[MSSQL] Use compression when backing up the database.
178-
[$PYNONYMIZER_MSSQL_BACKUP_COMPRESSION]
179-
--mysql-cmd-opts MYSQL_CMD_OPTS
180-
[MYSQL] pass additional arguments to the restore
181-
process (advanced use only!).
182-
[$PYNONYMIZER_MYSQL_CMD_OPTS]
183-
--mysql-dump-opts MYSQL_DUMP_OPTS
184-
[MYSQL] pass additional arguments to the dump process
185-
(advanced use only!). [$PYNONYMIZER_MYSQL_DUMP_OPTS]
186-
--postgres-cmd-opts POSTGRES_CMD_OPTS
187-
[POSTGRES] pass additional arguments to the restore
188-
process (advanced use only!).
189-
[$PYNONYMIZER_POSTGRES_CMD_OPTS]
190-
--postgres-dump-opts POSTGRES_DUMP_OPTS
191-
[POSTGRES] pass additional arguments to the dump
192-
process (advanced use only!).
193-
[$PYNONYMIZER_POSTGRES_DUMP_OPTS]
194-
-v, --version show program's version number and exit
195-
--verbose Increases the verbosity of the logging feature, to
196-
help when troubleshooting issues.
197-
[$PYNONYMIZER_VERBOSE]
198-
--dry-run Instruct pynonymizer to skip all process steps. Useful
199-
for testing safely. [$PYNONYMIZER_DRY_RUN]
200-
--ignore-anonymization-errors
201-
Instruct pynonymizer to ignore errors during the
202-
anonymization process and continue as normal.
203-
[$PYNONYMIZER_IGNORE_ANONYMIZATION_ERRORS]
204-
```
109+
205110
### Package
206111
Pynonymizer can also be invoked programmatically / from other python code. See the module entrypoint [pynonymizer](pynonymizer/__init__.py) or [pynonymizer/pynonymize.py](pynonymizer/pynonymize.py)
207112

0 commit comments

Comments
 (0)