k3s/pkg/util/bindata/embed.go
Brad Davidson ed57fb5e61
Some checks failed
govulncheck / govulncheck (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Fix windows build os (#13201)
* Pass GOOS into Dockerfile.local build args
  Fixes issue with build-windows job not actually building for windows
* Remove `go generate` from package-cli
  We no longer use codegen in this repo
* Fix go:embed path separator on Windows
* Bump hcsshim for containerd 2.1 compat on windows
* Include failing lister in error message
* Bump k3s-io/api and k3s-io/helm-controller for embedded CRD windows path fix

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-11-15 02:02:12 -08:00

35 lines
974 B
Go

package bindata
import (
"embed"
"io/fs"
"path"
"sort"
"strings"
)
// Bindata is a wrapper around embed.FS that allows us to continue to use
// go-bindata style Asset and AssetNames functions to access the embedded FS.
type Bindata struct {
FS *embed.FS
Prefix string
}
func (b Bindata) Asset(name string) ([]byte, error) {
return b.FS.ReadFile(path.Join(b.Prefix, name))
}
func (b Bindata) AssetNames() []string {
var assets []string
fs.WalkDir(b.FS, ".", func(path string, entry fs.DirEntry, err error) error {
// do not list hidden files - there is a .empty file checked in as a
// placeholder for files that are generated at build time to satisy
// `go vet`, but these should not be include when listing assets.
if n := entry.Name(); entry.Type().IsRegular() && !strings.HasPrefix(n, ".") && !strings.HasPrefix(n, "_") {
assets = append(assets, strings.TrimPrefix(path, b.Prefix))
}
return nil
})
sort.Strings(assets)
return assets
}