Commit 08aed00f authored by Adam Reese's avatar Adam Reese

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

fix(dm-install): do not require a namespace on kubectl create
parents 4a5cf501 838d5c04
...@@ -103,7 +103,7 @@ func (c *Client) CallService(path, method, action string, dest interface{}, read ...@@ -103,7 +103,7 @@ func (c *Client) CallService(path, method, action string, dest interface{}, read
return nil 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) { func (c *Client) callHTTP(path, method, action string, reader io.ReadCloser) (string, error) {
request, err := http.NewRequest(method, path, reader) request, err := http.NewRequest(method, path, reader)
......
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
// Returns the string output received from the operation, and an error if the // Returns the string output received from the operation, and an error if the
// command failed. // command failed.
func Install(runner kubectl.Runner) (string, error) { func Install(runner kubectl.Runner) (string, error) {
o, err := runner.Create([]byte(InstallYAML), "dm") o, err := runner.Create([]byte(InstallYAML))
return string(o), err return string(o), err
} }
......
...@@ -9,6 +9,6 @@ import ( ...@@ -9,6 +9,6 @@ import (
// Returns the string output received from the operation, and an error if the // Returns the string output received from the operation, and an error if the
// command failed. // command failed.
func Uninstall(runner kubectl.Runner) (string, error) { func Uninstall(runner kubectl.Runner) (string, error) {
o, err := runner.Delete("dm", "Namespace", "dm") o, err := runner.Delete("dm", "Namespace")
return string(o), err return string(o), err
} }
package kubectl package kubectl
// Create uploads a chart to Kubernetes // 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", "-"} args := []string{"create", "-f", "-"}
if ns != "" {
args = append([]string{"--namespace=" + ns}, args...)
}
cmd := command(args...) cmd := command(args...)
assignStdin(cmd, stdin) assignStdin(cmd, stdin)
...@@ -15,13 +11,9 @@ func (r RealRunner) Create(stdin []byte, ns string) ([]byte, error) { ...@@ -15,13 +11,9 @@ func (r RealRunner) Create(stdin []byte, ns string) ([]byte, error) {
} }
// Create returns the commands to kubectl // 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", "-"} args := []string{"create", "-f", "-"}
if ns != "" {
args = append([]string{"--namespace=" + ns}, args...)
}
cmd := command(args...) cmd := command(args...)
assignStdin(cmd, stdin) assignStdin(cmd, stdin)
......
...@@ -7,9 +7,9 @@ import ( ...@@ -7,9 +7,9 @@ import (
func TestPrintCreate(t *testing.T) { func TestPrintCreate(t *testing.T) {
var client Runner = PrintRunner{} 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 { if err != nil {
t.Error(err) t.Error(err)
} }
......
package kubectl package kubectl
// Delete removes a chart from Kubernetes. // 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} args := []string{"delete", ktype, name}
if ns != "" {
args = append([]string{"--namespace=" + ns}, args...)
}
return command(args...).CombinedOutput() return command(args...).CombinedOutput()
} }
// Delete returns the commands to kubectl // 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} args := []string{"delete", ktype, name}
if ns != "" {
args = append([]string{"--namespace=" + ns}, args...)
}
cmd := command(args...) cmd := command(args...)
return []byte(cmd.String()), nil return []byte(cmd.String()), nil
} }
...@@ -8,11 +8,11 @@ type Runner interface { ...@@ -8,11 +8,11 @@ type Runner interface {
// ClusterInfo returns Kubernetes cluster info // ClusterInfo returns Kubernetes cluster info
ClusterInfo() ([]byte, error) ClusterInfo() ([]byte, error)
// Create uploads a chart to Kubernetes // Create uploads a chart to Kubernetes
Create([]byte, string) ([]byte, error) Create(stdin []byte) ([]byte, error)
// Delete removes a chart from Kubernetes. // Delete removes a chart from Kubernetes.
Delete(string, string, string) ([]byte, error) Delete(name string, ktype string) ([]byte, error)
// Get returns Kubernetes resources // 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. // GetByKind gets an entry by kind, name, and namespace.
// //
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment