1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-24 08:36:46 +00:00
kyverno/cmd/cli/kubectl-kyverno/data/data.go
Charles-Edouard Brétéché 0bcc850d77
feat: support GVK to GVR mapping in the CLI (#12301)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2025-03-06 14:24:48 +08:00

32 lines
598 B
Go

package data
import (
"embed"
"encoding/json"
"io/fs"
"sync"
"k8s.io/client-go/restmapper"
)
const crdsFolder = "crds"
//go:embed crds
var crdsFs embed.FS
//go:embed api-group-resources.json
var apiGroupResources []byte
var _apiGroupResources = sync.OnceValues(func() ([]*restmapper.APIGroupResources, error) {
var out []*restmapper.APIGroupResources
err := json.Unmarshal(apiGroupResources, &out)
return out, err
})
func Crds() (fs.FS, error) {
return fs.Sub(crdsFs, crdsFolder)
}
func APIGroupResources() ([]*restmapper.APIGroupResources, error) {
return _apiGroupResources()
}