From 0eb6cd5aa85d926568a0800854a0fbab0a76480a Mon Sep 17 00:00:00 2001 From: Brendan Melville Date: Wed, 18 Nov 2015 10:01:11 -0800 Subject: [PATCH 1/2] Deployment name can now be set when doing "dm deploy". The default is still either template file name or -. Override using the "name" flag. --- dm/dm.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dm/dm.go b/dm/dm.go index 35af4860b..fec9ed482 100644 --- a/dm/dm.go +++ b/dm/dm.go @@ -36,6 +36,7 @@ import ( ) var ( + deployment_name = flag.String("name", "", "Name of deployment, used for deploy and update commands (defaults to template name)") stdin = flag.Bool("stdin", false, "Reads a configuration from the standard input") properties = flag.String("properties", "", "Properties to use when deploying a template (e.g., --properties k1=v1,k2=v2)") template_registry = flag.String("registry", "kubernetes/deployment-manager/templates", "Github based template registry (owner/repo[/path])") @@ -250,6 +251,11 @@ func loadTemplate(args []string) *expander.Template { log.Fatalf("cannot create configuration from supplied arguments: %s\n", err) } + // Override name if set from flags. + if *deployment_name != "" { + template.Name = *deployment_name + } + return template } From 82e7d0884462dc10e656e01c7042615be07c9782 Mon Sep 17 00:00:00 2001 From: Brendan Melville Date: Wed, 18 Nov 2015 15:06:51 -0800 Subject: [PATCH 2/2] Pretty print JSON responses from service. --- dm/dm.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dm/dm.go b/dm/dm.go index 35af4860b..ac95a2b74 100644 --- a/dm/dm.go +++ b/dm/dm.go @@ -169,7 +169,13 @@ func main() { func callService(path, method, action string, reader io.ReadCloser) { u := fmt.Sprintf("%s/%s", *service, path) - fmt.Println(callHttp(u, method, action, reader)) + + resp := callHttp(u, method, action, reader) + var prettyJSON bytes.Buffer + if err := json.Indent(&prettyJSON, []byte(resp), "", " "); err != nil { + log.Fatalf("Failed to parse JSON response from service: %s", resp) + } + fmt.Println(prettyJSON.String()) } func callHttp(path, method, action string, reader io.ReadCloser) string {