sensu / sensu-plugin-sdk

A framework for creating Sensu plugins
MIT License
7 stars 8 forks source link

enable []string as option value #84

Closed elfranne closed 1 year ago

elfranne commented 1 year ago

Have been trying to update sensu/http-checks but it has a --headers CLI argument that uses []string as data type. (WIP for http-check)

The test code was already present.

echlebek commented 1 year ago

Can you use SliceOptionValue?

elfranne commented 1 year ago

@echlebek Can you explain a bit more what you mean ?

elfranne commented 1 year ago

I was probably a bit tired, i ll give it a try.

echlebek commented 1 year ago

@elfranne A while back, I made a way of handling slices as options that differs from the regular option handling. https://github.com/sensu/sensu-plugin-sdk/blob/master/sensu/plugin.go#L57

SliceOptionValue is a generic type constraint that can be used with SlicePluginConfigOption for handling slices. I made this to avoid awkwardness when dealing with slice types, to simplify the PluginConfigOption code. There is also, similarly, a MapPluginConfigOption.

elfranne commented 1 year ago

Thanks for the explanation, I managed to use that instead.