From 2c7aad5f632e346a2f1a58f8ad0bd555e53a4f36 Mon Sep 17 00:00:00 2001 From: vaikas-google Date: Wed, 27 Jan 2016 15:22:09 -0800 Subject: [PATCH] Wire [gs]etcredential to backend --- dm/dm.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dm/dm.go b/dm/dm.go index 1fa9da578..ec11acfce 100644 --- a/dm/dm.go +++ b/dm/dm.go @@ -65,6 +65,8 @@ var commands = []string{ "templates \t\t Lists the templates in a given template registry", "registries \t\t Lists the registries available", "describe \t\t Describes the named template in a given template registry", + "getcredential \t\t Gets the named credential used by a registry", + "setcredential \t\t Sets a credential used by a registry", } var usage = func() { @@ -153,6 +155,21 @@ func execute() { callService("deployments", "POST", action, marshalTemplate(template)) case "list": callService("deployments", "GET", "list deployments", nil) + case "getcredential": + path := fmt.Sprintf("credentials/%s", args[1]) + callService(path, "GET", "get credential", nil) + case "setcredential": + c := getGithubCredential() + if c == nil { + panic(fmt.Errorf("Failed to create a credential from flags/arguments")) + } + y, err := yaml.Marshal(c) + if err != nil { + panic(fmt.Errorf("Failed to serialize credential: %#v : %s", c, err)) + } + + path := fmt.Sprintf("credentials/%s", args[1]) + callService(path, "POST", "get credential", ioutil.NopCloser(bytes.NewReader(y))) case "get": if len(args) < 2 { fmt.Fprintln(os.Stderr, "No deployment name supplied")