mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-11 14:09:21 +00:00
add a few comments on exported vars
This commit is contained in:
parent
7db0febbd1
commit
d9a6468d09
4 changed files with 8 additions and 3 deletions
|
|
@ -36,6 +36,7 @@ func JSON(w io.Writer, withSummary bool, verbose bool) Output {
|
|||
}
|
||||
}
|
||||
|
||||
// JSON.Write will only write when JSON.Flush has been called
|
||||
func (o *jsono) Write(filename, kind, version string, err error, skipped bool) error {
|
||||
msg, st := "", ""
|
||||
|
||||
|
|
@ -65,6 +66,7 @@ func (o *jsono) Write(filename, kind, version string, err error, skipped bool) e
|
|||
return nil
|
||||
}
|
||||
|
||||
// Flush outputs the results as JSON
|
||||
func (o *jsono) Flush() error {
|
||||
var err error
|
||||
var res []byte
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ type LocalSchemas struct {
|
|||
schemas map[string]string
|
||||
}
|
||||
|
||||
// NewLocalSchemas creates a new "registry", that will serve schemas from files, given a list of schema filenames
|
||||
func NewLocalSchemas(schemaFiles []string) (*LocalSchemas, error) {
|
||||
schemas := &LocalSchemas{
|
||||
schemas: map[string]string{},
|
||||
|
|
@ -46,6 +47,7 @@ func NewLocalSchemas(schemaFiles []string) (*LocalSchemas, error) {
|
|||
return schemas, nil
|
||||
}
|
||||
|
||||
// DownloadSchema retrieves the schema from a file for the resource
|
||||
func (r LocalSchemas) DownloadSchema(resourceKind, resourceAPIVersion, k8sVersion string) ([]byte, error) {
|
||||
schemaFile, ok := r.schemas[resourceKind]
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ type Signature struct {
|
|||
Kind, Version, Namespace string
|
||||
}
|
||||
|
||||
func SignatureFromBytes(s []byte) (Signature, error) {
|
||||
// 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"`
|
||||
|
|
@ -16,7 +17,7 @@ func SignatureFromBytes(s []byte) (Signature, error) {
|
|||
Namespace string `yaml:"Namespace"`
|
||||
} `yaml:"Metadata"`
|
||||
}{}
|
||||
err := yaml.Unmarshal(s, &resource)
|
||||
err := yaml.Unmarshal(res, &resource)
|
||||
|
||||
return Signature{Kind: resource.Kind, Version: resource.APIVersion, Namespace: resource.Metadata.Namespace}, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ func (f ValidFormat) IsFormat(input interface{}) bool {
|
|||
// gojsonschema.FormatCheckers.Add("int-or-string", ValidFormat{})
|
||||
// }
|
||||
|
||||
// Validates a single Kubernetes resource against a Json Schema
|
||||
// Validate validates a single Kubernetes resource against a Json Schema
|
||||
func Validate(rawResource []byte, schema *gojsonschema.Schema) error {
|
||||
if schema == nil {
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue