Rewrite kubectl explain to use openapi

This removes all dependencies on swagger 1.2 for explain.
This commit is contained in:
Antoine Pelisse
2017-09-24 20:40:33 -07:00
parent 566364da49
commit 249caa95b5
14 changed files with 751 additions and 259 deletions

View File

@@ -18,6 +18,7 @@ package openapi
import (
"fmt"
"sort"
"strings"
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -181,6 +182,26 @@ func (k *Kind) GetName() string {
return fmt.Sprintf("Kind(%v)", properties)
}
// IsRequired returns true if `field` is a required field for this type.
func (k *Kind) IsRequired(field string) bool {
for _, f := range k.RequiredFields {
if f == field {
return true
}
}
return false
}
// Keys returns a alphabetically sorted list of keys.
func (k *Kind) Keys() []string {
keys := make([]string, 0)
for key := range k.Fields {
keys = append(keys, key)
}
sort.Strings(keys)
return keys
}
// Map is an object who values must all be of the same `SubType`.
// The key of the object is always of type `string`.
type Map struct {