buildflags: make work on go 1.22 by reverting rangefunc usage

Reverts the usage of rangefunc and attempts to keep the foundation of it
in for when we move to go 1.23. We have downstream dependencies that
aren't ready to move to go 1.23. We can likely move after go 1.24 is
released.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
Jonathan A. Sternberg
2025-02-10 11:03:46 -06:00
parent 0a4eb7ec76
commit 3ae9970da5
7 changed files with 52 additions and 33 deletions

View File

@ -22,16 +22,19 @@ func (e *Attests) FromCtyValue(in cty.Value, p cty.Path) error {
return p.NewErrorf("%s", convert.MismatchMessage(got, want))
}
func (e *Attests) fromCtyValue(in cty.Value, p cty.Path) error {
func (e *Attests) fromCtyValue(in cty.Value, p cty.Path) (retErr error) {
*e = make([]*Attest, 0, in.LengthInt())
for value := range eachElement(in) {
yield := func(value cty.Value) bool {
entry := &Attest{}
if err := entry.FromCtyValue(value, p); err != nil {
return err
if retErr = entry.FromCtyValue(value, p); retErr != nil {
return false
}
*e = append(*e, entry)
return true
}
return nil
eachElement(in)(yield)
return retErr
}
func (e Attests) ToCtyValue() cty.Value {