mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-15 16:59:51 +00:00
try to validate
This commit is contained in:
parent
fe33d14dc4
commit
96e35cb926
6 changed files with 87 additions and 21 deletions
|
|
@ -1,22 +1,15 @@
|
|||
package resource
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
type Resource struct {
|
||||
type Signature struct {
|
||||
Kind, Version, Namespace string
|
||||
}
|
||||
|
||||
// TODO: Support multi-resources yaml files
|
||||
func Read(r io.Reader) (Resource, error) {
|
||||
s, err := ioutil.ReadAll(r)
|
||||
if err != nil {
|
||||
return Resource{}, err
|
||||
}
|
||||
|
||||
func SignatureFromBytes(s []byte) (Signature, error) {
|
||||
resource := struct {
|
||||
APIVersion string `yaml:"apiVersion"`
|
||||
Kind string `yaml:"kind"`
|
||||
|
|
@ -24,7 +17,8 @@ func Read(r io.Reader) (Resource, error) {
|
|||
Namespace string `yaml:"Namespace"`
|
||||
} `yaml:"Metadata"`
|
||||
}{}
|
||||
err = yaml.Unmarshal(s, &resource)
|
||||
err := yaml.Unmarshal(s, &resource)
|
||||
|
||||
return Signature{Kind: resource.Kind, Version: resource.APIVersion, Namespace: resource.Metadata.Namespace}, err
|
||||
}
|
||||
|
||||
return Resource{Kind: resource.Kind, Version: resource.APIVersion, Namespace: resource.Metadata.Namespace}, err
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue