cossacklabs / acra

Database security suite. Database proxy with field-level encryption, search through encrypted data, SQL injections prevention, intrusion detection, honeypots. Supports client-side and proxy-side ("transparent") encryption. SQL, NoSQL.
https://www.cossacklabs.com/acra/
Apache License 2.0
1.33k stars 128 forks source link

Implement new CLI approach #561

Closed Zhaars closed 2 years ago

Zhaars commented 2 years ago

The idea of this PR is to change the approach used for CLI args parsing.

Problems: With the new approach of Keystore strategies that are dynamically registered, we used global variables that store CLI params after parsing to initialize some KeystoreFabric. However, in acra-keys we cant use just package global variables as acra-keys migrate should contain two structs for storing CLI args - src_ and dst_. (They were stored on CommonKeyStoreParameters struct)

So the solution proposed is to have the ability to just Register and ParseCLI parameters separately. Besides that, each KeystoreFabric should be able to register its own set of Flags. So the main KeystoreFabric interface was extended with RegisterCLIParameters method.

Currently, I splited CLI params Registration and Parsing to separate steps, so that we can call Parse functions any time from any FlagSet which will create a new object for every Parsing,(It solves the issue with one global var)

All strategy CLI params registration was moved to `RegisterKeyStoreStrategyParametersWithFlags.

Checklist