Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance ExportCommand with Advanced Filtering Flags #369

Closed
rannn505 opened this issue Feb 20, 2024 · 1 comment · Fixed by #381
Closed

Enhance ExportCommand with Advanced Filtering Flags #369

rannn505 opened this issue Feb 20, 2024 · 1 comment · Fixed by #381
Assignees
Labels
feat New feature or request

Comments

@rannn505
Copy link
Contributor

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 all aws 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.

@RonConfigu
Copy link
Contributor

Development Plan

  • Declare protected rawFlags!: FlagToken[]; at BaseCommand and set on init()
  • Add examples
  • Add flags with constrains
  • Implement filtering logic in new function filterFromFlags(): (({ context, result }: EvalCommandReturn['string']) => boolean) | undefined
  • Update docs (if necessary)

Questions / Requests

Notes / Comments / Additional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants