clever-tools icon indicating copy to clipboard operation
clever-tools copied to clipboard

[logs] support passing services options

Open KannarFr opened this issue 1 year ago • 8 comments

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.

KannarFr avatar Feb 19 '24 19:02 KannarFr

@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?

hsablonniere avatar Feb 20 '24 09:02 hsablonniere

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.

davlgd avatar Feb 20 '24 12:02 davlgd

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).

KannarFr avatar Feb 20 '24 12:02 KannarFr

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:)

hsablonniere avatar Feb 21 '24 16:02 hsablonniere

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?

KannarFr avatar Feb 21 '24 23:02 KannarFr

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).

aurrelhebert avatar Feb 22 '24 08:02 aurrelhebert

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

KannarFr avatar Feb 22 '24 12:02 KannarFr

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'

miton18 avatar Mar 07 '24 08:03 miton18