Make validation optional, handle YAML

This commit is contained in:
Brendan Burns
2014-11-25 20:10:21 -08:00
parent c29f5db81c
commit 18cfac0d31
4 changed files with 100 additions and 13 deletions

View File

@@ -54,6 +54,7 @@ var (
json = flag.Bool("json", false, "If true, print raw JSON for responses")
yaml = flag.Bool("yaml", false, "If true, print raw YAML for responses")
verbose = flag.Bool("verbose", false, "If true, print extra information")
validate = flag.Bool("validate", false, "If true, try to validate the passed in object using a swagger schema on the api server")
proxy = flag.Bool("proxy", false, "If true, run a proxy to the api server")
www = flag.String("www", "", "If -proxy is true, use this directory to serve static files")
templateFile = flag.String("template_file", "", "If present, load this file as a golang template and use it for output printing")
@@ -159,9 +160,11 @@ func readConfig(storage string, c *client.Client) []byte {
}
dataInput := readConfigData()
err := kubecfg.ValidateObject(dataInput, c)
if err != nil {
glog.Fatalf("Error validating %v as an object for %v: %v\n", *config, storage, err)
if *validate {
err := kubecfg.ValidateObject(dataInput, c)
if err != nil {
glog.Fatalf("Error validating %v as an object for %v: %v\n", *config, storage, err)
}
}
data, err := parser.ToWireFormat(dataInput, storage, latest.Codec, serverCodec)