CleverCloud / clever-tools

The official command line interface for Clever Cloud
https://www.clever-cloud.com/
Apache License 2.0
74 stars 46 forks source link

[logs] support passing services options #691

Open KannarFr opened 7 months ago

KannarFr commented 7 months ago

Logs v4 provides the flexibility to specify logged services, offering a default set that includes (bas, bas-deploy, cronie, run-*). It also supports the all keyword.

I intend to incorporate the usage of these options into clever logs. However, I am unsure about the preferred format. Should it be implemented as a repeated option like -s --service --services, or perhaps as a list of services passed to a non-repeatable option? I welcome your guidance on this matter.

hsablonniere commented 7 months ago

@KannarFr I'm not sure we ever used repeated options in the CLI, can you check in the existing commands? I guess it would be a nice way to provide the option.

@miton18 @davlgd @aurrelhebert WDYT?

davlgd commented 7 months ago

I think it's a behavior expected from an API an in cURL requests, but not from CLI flags (even if you can repeat some parameters in tools such as git for example, but I see this more as the exception than the main rule). IMHO, it could be interesting to discuss about the good way to implement this in Clever Tools.

KannarFr commented 7 months ago

IMHO, it could be interesting to discuss about the good way to implement this in Clever Tools.

This is the goal here. Then I suggest clever logs -s|--services bas,cronie,run-* (it supports regex).

hsablonniere commented 7 months ago

I think it's a behavior expected from an API an in cURL requests, but not from CLI flags (even if you can repeat some parameters in tools such as git for example, but I see this more as the exception than the main rule). IMHO, it could be interesting to discuss about the good way to implement this in Clever Tools.

Docker does this with env vars, volumes and port mapping. I think people are used to that.

This is the goal here. Then I suggest clever logs -s|--services bas,cronie,run-* (it supports regex).

Coma separated value is fine by me but when you say supports regex, you mean we give bas,cronie,run-* directly to the API?

(FYI run-* is not a regex :stuck_out_tongue:)

KannarFr commented 7 months ago

Let's say we only support regex on the API side, not exposing just "internal" stuff for default retuned services because systemd-timers services names are generated on run.

run-* is a valid regex but not the one I expected, is ^run\-* better?

aurrelhebert commented 7 months ago

Same as @hsablonniere to start with Coma separated value is fine by me and to support an all keyword. For regexp if we only have 5 to 6 items, it seems to me to be overkill. However if it supported on the API side, there are no issues for me to support it too on the CLI (without adding any validation on the regexp).

KannarFr commented 7 months ago

API is not supporting it. It's only used "internally" for default services when no service query strings are passed.

miton18 commented 6 months ago

From API side, 'service' query parameter supports

'bas', 'bas-deploy', '^run\\-*', "cronie" if no value is set

a list of regex (Ex: ?service=bas&service=^run\\-*)

the special keyword '?service=all'