Use stdlib function instead of own to check for slice membership#9290
Use stdlib function instead of own to check for slice membership#9290ycombinator wants to merge 1 commit intoelastic:mainfrom
Conversation
|
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
💛 Build succeeded, but was flaky
Failed CI Stepscc @ycombinator |
There was a problem hiding this comment.
Tbh I reviewed the original PR and I thought that you went the manual approach becuase slices.Contains does essentially the following
package slices
// Contains reports whether v is present in s.
func Contains[S ~[]E, E comparable](s S, v E) bool {
return Index(s, v) >= 0
}
// Index returns the index of the first occurrence of v in s,
// or -1 if not present.
func Index[S ~[]E, E comparable](s S, v E) int {
for i := range s {
if v == s[i] {
return i
}
}
return -1
}
and because you pass pointers this essentially is not checking the version equality but the ptr ref, what am I missing?
Also I see in the CI that adding the label doesn't invoke the step which is really weird
Yeah, good point. I could do something like this: for _, ver := range versions {
if slices.ContainsFunc(echVersions, func(candidateVer *version.ParsedSemVer) bool {
return candidateVer.Equal(*ver)
}) {
filteredVersions = append(filteredVersions, ver)
}
}But I'm not sure that's buying us much over the current manual approach. WDYT?
In fairness, I added the label after the CI run had already started. Let me rebuild now and see if the label takes effect. |
|
It feels like the same approach that is already there 🙂
I cannot wrap my head around how BK reacts to the gh labels, because the test is still not invoked |
Agreed. Let's just stick with what we already have. Closing this PR unmerged.
Same. Let's use #9286 to fix the automation for this label. |





Quick cleanup on the heels of #9266. Thought of this right after I merged that PR 🤦.