cloudquery/plugin-sdk

When redirecting the plugin output to a file, colors are added to the output

Closed this issue · 2 comments

Describe the bug

Not sure if this belongs here or in https://github.com/cloudquery/cloudquery.

When doing go run main.go serve > output.txt in a plugin's repo (after cloning it), the file will contain the following:

�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_datalake_analytics_accounts
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_frontdoor_doors
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_datalake_store_accounts
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_compute_virtual_machines
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_eventhub_namespaces
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_cdn_profiles
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_iothub_devices
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_container_registries
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_container_managed_clusters
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_compute_disks
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_keyvault_managed_hsms
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_compute_virtual_machine_scale_sets
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_authorization_role_assignments
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_keyvault_vaults
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_batch_accounts
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_authorization_role_definitions
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_logic_workflows
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_mariadb_servers
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_cosmosdb_accounts

This makes it harder to debug plugins

Expected Behavior

The output file should not have special characters

Steps to Reproduce

  1. git@github.com:cloudquery/cloudquery.git
  2. cd plugins/source/gcp
  3. go run main.go serve > output.txt

Examine content of output.txt

Possible Solution

Support NO_COLOR=true env variable and/or automatically set it when piping output to a file

Provider and CloudQuery version

v2

Additional Context

No response

maybe we should disable colors in the plugins at all but otherwise I would add --color and set no color as default. As a work around you can use --log-format=json this will be with no colors

Closing this as wontfix for now