Enhance `ExportCommand` with Advanced Filtering Flags
rannn505 opened this issue · comments
Suggestion
Expand the ExportCommand
in the Configu CLI to include comprehensive filtering flags, offering users refined control over their configuration export results. These new flags will invoke the filter callback functionality, allowing for more granular selection or exclusion of configuration data based on labels, key names, visibility, and value presence.
-
--pick-label
/--omit-label
: Specify labels to include or exclude. Can be used multiple times to specify multiple labels. -
--pick-key
/--omit-key
: Specify exact config keys to include or exclude. Can be used multiple times for multiple keys. this is casing sensitive and according to the original key specified from the user's schema, the key mutations come last. -
--pick-hidden
/--omit-hidden
: Explicitly include or exclude config keys marked as hidden. By default, hidden keys are omitted. -
--pick-empty
/--omit-empty
: Choose to include or exclude config keys with empty values. By default, empty values are included.
Important notes
- The order of the flags sets the priority of the filter when there are collisions
- If any
pick
flag is specified all other are omitted by default - if any
omit
flag is specified all other are included by default - if a combination of pick and omit are specified, keep the above. for example
--pick-label 'aws' --omit-key 'AWS_SECRET_ACCESS_KEY'
will return allaws
labeled keys without the secret access key.
Example Usage:
# Exclude specific labels
configu eval ... | configu export --omit-label 'deprecated' --omit-label 'temporary'
# Include only configs under specific labels
configu eval ... | configu export --pick-label 'production' --pick-label 'secure'
# Exclude specific keys
configu eval ... | configu export --omit-key 'DEBUG_MODE' --omit-key 'TEST_ACCOUNT'
# Include hidden configs and Exclude configs with empty values
configu eval ... | configu export --pick-hidden --omit-empty
Motivation
These enhancements aim to provide users with intuitive, command-line-driven mechanisms to tailor their configuration export results precisely, catering to diverse operational and deployment scenarios. By offering the ability to include or exclude configurations based on their characteristics, users gain more flexibility in managing configurations for different environments or purposes, aligning with best practices in configuration management.
Context
This feature builds on the recently introduced filter
callback functionality within the ExportCommand
, translating it into practical, user-friendly CLI options.
Development Plan
- Declare
protected rawFlags!: FlagToken[];
atBaseCommand
and set oninit()
- Add examples
- Add flags with constrains
- Implement filtering logic in new function
filterFromFlags(): (({ context, result }: EvalCommandReturn['string']) => boolean) | undefined
- Update docs (if necessary)