Use util.WithPrefix (#9005)

Tiny change to use this helper where we can.

Signed-off-by: Anders Eknert <anders.eknert@apple.com>
This commit is contained in:
Anders Eknert
2026-08-12 15:03:38 +02:00
committed by GitHub
parent 8a424f7652
commit 413f49f28c
2 changed files with 6 additions and 14 deletions
+3 -6
View File
@@ -7,7 +7,8 @@ import (
"encoding/json"
"errors"
"io"
"strings"
"github.com/open-policy-agent/opa/v1/util"
)
type TarGzWriter struct {
@@ -62,11 +63,7 @@ func MustWriteTarGz(files [][2]string) *bytes.Buffer {
defer tgw.Close()
for _, file := range files {
if !strings.HasPrefix(file[0], "/") {
file[0] = "/" + file[0]
}
if err := tgw.WriteFile(file[0], []byte(file[1])); err != nil {
if err := tgw.WriteFile(util.WithPrefix(file[0], "/"), []byte(file[1])); err != nil {
panic(err)
}
}