Merge pull request #18 from adamreese/fix/dm-install

fix(dm-install): do not require a namespace on kubectl create
pull/291/head
Adam Reese 9 years ago
commit 08aed00f93

@ -103,7 +103,7 @@ func (c *Client) CallService(path, method, action string, dest interface{}, read
return nil
}
// callHTTP is a low-level primative 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) {
request, err := http.NewRequest(method, path, reader)

@ -10,7 +10,7 @@ import (
// Returns the string output received from the operation, and an error if the
// command failed.
func Install(runner kubectl.Runner) (string, error) {
o, err := runner.Create([]byte(InstallYAML), "dm")
o, err := runner.Create([]byte(InstallYAML))
return string(o), err
}

@ -9,6 +9,6 @@ import (
// Returns the string output received from the operation, and an error if the
// command failed.
func Uninstall(runner kubectl.Runner) (string, error) {
o, err := runner.Delete("dm", "Namespace", "dm")
o, err := runner.Delete("dm", "Namespace")
return string(o), err
}

@ -1,13 +1,9 @@
package kubectl
// Create uploads a chart to Kubernetes
func (r RealRunner) Create(stdin []byte, ns string) ([]byte, error) {
func (r RealRunner) Create(stdin []byte) ([]byte, error) {
args := []string{"create", "-f", "-"}
if ns != "" {
args = append([]string{"--namespace=" + ns}, args...)
}
cmd := command(args...)
assignStdin(cmd, stdin)
@ -15,13 +11,9 @@ func (r RealRunner) Create(stdin []byte, ns string) ([]byte, error) {
}
// Create returns the commands to kubectl
func (r PrintRunner) Create(stdin []byte, ns string) ([]byte, error) {
func (r PrintRunner) Create(stdin []byte) ([]byte, error) {
args := []string{"create", "-f", "-"}
if ns != "" {
args = append([]string{"--namespace=" + ns}, args...)
}
cmd := command(args...)
assignStdin(cmd, stdin)

@ -7,9 +7,9 @@ import (
func TestPrintCreate(t *testing.T) {
var client Runner = PrintRunner{}
expected := `[CMD] kubectl --namespace=default-namespace create -f - < some stdin data`
expected := `[CMD] kubectl create -f - < some stdin data`
out, err := client.Create([]byte("some stdin data"), "default-namespace")
out, err := client.Create([]byte("some stdin data"))
if err != nil {
t.Error(err)
}

@ -1,25 +1,18 @@
package kubectl
// Delete removes a chart from Kubernetes.
func (r RealRunner) Delete(name, ktype, ns string) ([]byte, error) {
func (r RealRunner) Delete(name, ktype string) ([]byte, error) {
args := []string{"delete", ktype, name}
if ns != "" {
args = append([]string{"--namespace=" + ns}, args...)
}
return command(args...).CombinedOutput()
}
// Delete returns the commands to kubectl
func (r PrintRunner) Delete(name, ktype, ns string) ([]byte, error) {
func (r PrintRunner) Delete(name, ktype string) ([]byte, error) {
args := []string{"delete", ktype, name}
if ns != "" {
args = append([]string{"--namespace=" + ns}, args...)
}
cmd := command(args...)
return []byte(cmd.String()), nil
}

@ -8,11 +8,11 @@ type Runner interface {
// ClusterInfo returns Kubernetes cluster info
ClusterInfo() ([]byte, error)
// Create uploads a chart to Kubernetes
Create([]byte, string) ([]byte, error)
Create(stdin []byte) ([]byte, error)
// Delete removes a chart from Kubernetes.
Delete(string, string, string) ([]byte, error)
Delete(name string, ktype string) ([]byte, error)
// Get returns Kubernetes resources
Get([]byte, string) ([]byte, error)
Get(stdin []byte, ns string) ([]byte, error)
// GetByKind gets an entry by kind, name, and namespace.
//

Loading…
Cancel
Save