Closed reivilibre closed 2 years ago
@reivilibre Do you mean the Filter
type used for the RPC communication? 🤔 Could you provide some additional context?
@reivilibre Do you mean the
Filter
type used for the RPC communication? thinking Could you provide some additional context?
my apologies, I hit enter in the title bar and sent it without a body :(. I added some details now
We just released some new docs with #282 two days ago and there are still some points missing / outdated. Would be super cool if you could create a PR and document some of the points you found out. Maybe a new page called Agent config
similar to the Server config would be the best place.
In the agent's flags, there seems to be the ability to specify some filters: https://github.com/woodpecker-ci/woodpecker/blob/a07f120d1245bab2c6eb4f896cbc3348f5e04d72/cmd/drone-agent/flags.go#L67-L71
It says we can restrict builds by label — perfect, but it's not clear what those labels are or what the filters look like.
I've been digging through the code a little bit, and it turns out that:
1: this has examples of the filter syntax: https://github.com/woodpecker-ci/expr/blob/164b8b3d0915b31a990c04f93e20928ed67a45fb/selector_test.go#L11
2: the below defines the 'filter function' — one thing I notice is that it seems to be that if you specify a filter, you MUST manually specify
platform == ...
in that filter otherwise you won't be filtering by platform anymore (The 'platform' is special-cased into thefilter.Labels
map at some point leading up to here, but I've lost track) https://github.com/woodpecker-ci/woodpecker/blob/a07f120d1245bab2c6eb4f896cbc3348f5e04d72/server/rpc.go#L494-L5183: this below is where the labels are attached to the Task https://github.com/woodpecker-ci/woodpecker/blob/master/server/hook.go#L390-L395
4: it seems like this might be specifiable as a
labels
map in the pipeline YAML, but that part is not entirely clear to me — seems to belibcompose.SliceorMap
.Point (2) seems like a bug to me — surely you shouldn't be able to bypass the platform filter. But in any case, none of this seems documented (please point it out if it is :)) and it'd be nice to change that (I'm happy to do so, just wanted to know if I'm missing anything / not understanding properly).