mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-11 14:09:21 +00:00
23 lines
602 B
Go
23 lines
602 B
Go
package resource
|
|
|
|
import (
|
|
"sigs.k8s.io/yaml"
|
|
)
|
|
|
|
type Signature struct {
|
|
Kind, Version, Namespace string
|
|
}
|
|
|
|
// SignatureFromBytes returns key identifying elements from a []byte representing the resource
|
|
func SignatureFromBytes(res []byte) (Signature, error) {
|
|
resource := struct {
|
|
APIVersion string `yaml:"apiVersion"`
|
|
Kind string `yaml:"kind"`
|
|
Metadata struct {
|
|
Namespace string `yaml:"Namespace"`
|
|
} `yaml:"Metadata"`
|
|
}{}
|
|
err := yaml.Unmarshal(res, &resource)
|
|
|
|
return Signature{Kind: resource.Kind, Version: resource.APIVersion, Namespace: resource.Metadata.Namespace}, err
|
|
}
|