diff --git a/cmd/helm/deploy.go b/cmd/helm/deploy.go index c6042dba7..3e33572e0 100644 --- a/cmd/helm/deploy.go +++ b/cmd/helm/deploy.go @@ -102,7 +102,7 @@ func deploy(c *cli.Context) error { } } - return NewClient(c).PostDeployment(cfg) + return NewClient(c).PostDeployment(cfg.Resources[0].Name, cfg) } // isLocalChart returns true if the given path can be statted. diff --git a/pkg/client/client.go b/pkg/client/client.go index 6aa8183ad..5780917db 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -17,6 +17,7 @@ limitations under the License. package client import ( + "bytes" "encoding/json" "fmt" "io" @@ -29,6 +30,7 @@ import ( "strings" "time" + "github.com/ghodss/yaml" "github.com/kubernetes/deployment-manager/pkg/common" ) @@ -108,7 +110,7 @@ func (c *Client) agent() string { // CallService is a low-level function for making an API call. // // This calls the service and then unmarshals the returned data into dest. -func (c *Client) CallService(path, method, action string, dest interface{}, reader io.ReadCloser) error { +func (c *Client) CallService(path, method, action string, dest interface{}, reader io.Reader) error { u, err := c.url(path) if err != nil { return err @@ -125,7 +127,7 @@ func (c *Client) CallService(path, method, action string, dest interface{}, read } // callHTTP is a low-level primitive for executing HTTP operations. -func (c *Client) callHTTP(path, method, action string, reader io.ReadCloser) (string, error) { +func (c *Client) callHTTP(path, method, action string, reader io.Reader) (string, error) { request, err := http.NewRequest(method, path, reader) // TODO: dynamically set version @@ -280,7 +282,25 @@ func (c *Client) DeleteDeployment(name string) (*common.Deployment, error) { return deployment, nil } -// PostDeployment posts a deployment objec to the manager service. -func (c *Client) PostDeployment(cfg *common.Configuration) error { - return c.CallService("/deployments", "POST", "post deployment", cfg, nil) +// PostDeployment posts a deployment object to the manager service. +func (c *Client) PostDeployment(name string, cfg *common.Configuration) error { + d, err := yaml.Marshal(cfg) + if err != nil { + return err + } + // This is a stop-gap until we get this API cleaned up. + t := common.Template{ + Name: name, + Content: string(d), + } + + data, err := json.Marshal(t) + if err != nil { + return err + } + + var out interface{} + + b := bytes.NewBuffer(data) + return c.CallService("/deployments", "POST", "post deployment", &out, b) } diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index 3843f047f..91e6e5357 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -169,7 +169,7 @@ func TestPostDeployment(t *testing.T) { } defer fc.teardown() - if err := fc.setup().PostDeployment(cfg); err != nil { + if err := fc.setup().PostDeployment("foo", cfg); err != nil { t.Fatalf("failed to post deployment: %s", err) } }