Merge pull request #374 from technosophos/feat/revert-helm-deploy

fix(cli): revert to older deploy formatting
pull/376/head
Matt Butcher 9 years ago
commit e0d7bad126

@ -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. // isLocalChart returns true if the given path can be statted.

@ -17,6 +17,7 @@ limitations under the License.
package client package client
import ( import (
"bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
@ -29,6 +30,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/ghodss/yaml"
"github.com/kubernetes/deployment-manager/pkg/common" "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. // CallService is a low-level function for making an API call.
// //
// This calls the service and then unmarshals the returned data into dest. // 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) u, err := c.url(path)
if err != nil { if err != nil {
return err 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. // 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) request, err := http.NewRequest(method, path, reader)
// TODO: dynamically set version // TODO: dynamically set version
@ -280,7 +282,25 @@ func (c *Client) DeleteDeployment(name string) (*common.Deployment, error) {
return deployment, nil return deployment, nil
} }
// PostDeployment posts a deployment objec to the manager service. // PostDeployment posts a deployment object to the manager service.
func (c *Client) PostDeployment(cfg *common.Configuration) error { func (c *Client) PostDeployment(name string, cfg *common.Configuration) error {
return c.CallService("/deployments", "POST", "post deployment", cfg, nil) 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)
} }

@ -169,7 +169,7 @@ func TestPostDeployment(t *testing.T) {
} }
defer fc.teardown() 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) t.Fatalf("failed to post deployment: %s", err)
} }
} }

Loading…
Cancel
Save