Add option to overwrites tags option with values specified in an file (#62)

Reviewed-on: https://codeberg.org/woodpecker-plugins/docker-buildx/pulls/62
Reviewed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
6543
2023-05-02 19:25:49 +00:00
parent a5ea4573b0
commit 37718ded77
6 changed files with 60 additions and 7 deletions

9
utils/lamda.go Normal file
View File

@@ -0,0 +1,9 @@
package utils
func Map[T any](in []T, fn func(T) T) []T {
out := in
for i := range in {
out[i] = fn(out[i])
}
return out
}

18
utils/lamda_test.go Normal file
View File

@@ -0,0 +1,18 @@
package utils
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestMap(t *testing.T) {
ints := []int{1, 2, 3, 4}
ints = Map(ints, func(i int) int { return i * 10 })
assert.EqualValues(t, []int{10, 20, 30, 40}, ints)
sl := []string{"a ", "b", " c"}
sl = Map(sl, func(s string) string { return "#" + strings.TrimSpace(s) })
assert.EqualValues(t, []string{"#a", "#b", "#c"}, sl)
}