In text mode, CLI should output nice-looking types: "MySQL", "msqld_exporter", etc. In JSON mode, CLI should output types as they are specified in Swagger: "MYSQL_SERVICE", "MYSQLD_EXPORTER", etc.
My idea was to add helpers to convert Swagger type strings/ints and gRPC strings/enums to nice-looking strings and use those helpers in pmm-admin templates. In result structures, original Swagger strings should be used for proper JSON output. See this PR: https://github.com/percona/pmm/pull/475
If I use
list
to show the agents then the JSON output usesagent
to name the list of agents:Whereas, if I use
status
then the JSON output usesagents
:Also,
status
changes from "running" to "RUNNING",agent_type
changes from "node_exporter" to "NODE_EXPORTER", etcMost pmm-admin command results use generated API object strucutres:
https://github.com/percona/pmm-admin/blob/84d77ee2860b703bd7de551a9b61b18cc09b96de/commands/status.go#L43
https://github.com/percona/pmm-admin/blob/84d77ee2860b703bd7de551a9b61b18cc09b96de/commands/management/add_mysql.go#L40
etc
Some commands (list, inventory list) use plain strings instead:
https://github.com/percona/pmm-admin/blob/84d77ee2860b703bd7de551a9b61b18cc09b96de/commands/list.go#L43-L60
https://github.com/percona/pmm-admin/blob/84d77ee2860b703bd7de551a9b61b18cc09b96de/commands/inventory/list_agents.go#L37-L47
https://github.com/percona/pmm-admin/blob/84d77ee2860b703bd7de551a9b61b18cc09b96de/commands/inventory/list_nodes.go#L34-L43
https://github.com/percona/pmm-admin/blob/84d77ee2860b703bd7de551a9b61b18cc09b96de/commands/inventory/list_services.go#L37-L46
maybe something else?
All results should use generated API object structures. Tests should be added.