diff --git a/cmd/minikube/cmd/node/node.go b/cmd/minikube/cmd/node.go similarity index 90% rename from cmd/minikube/cmd/node/node.go rename to cmd/minikube/cmd/node.go index be6c8a88bc..39dbac6c7c 100644 --- a/cmd/minikube/cmd/node/node.go +++ b/cmd/minikube/cmd/node.go @@ -14,15 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. */ -package node +package cmd import ( "github.com/spf13/cobra" "k8s.io/minikube/pkg/minikube/exit" ) -// NodeCmd represents the set of node subcommands -var NodeCmd = &cobra.Command{ +// nodeCmd represents the set of node subcommands +var nodeCmd = &cobra.Command{ Use: "node", Short: "Node operations", Long: "Operations on nodes", diff --git a/cmd/minikube/cmd/node/add.go b/cmd/minikube/cmd/node_add.go similarity index 85% rename from cmd/minikube/cmd/node/add.go rename to cmd/minikube/cmd/node_add.go index cbe8f8e451..a0ed29d04f 100644 --- a/cmd/minikube/cmd/node/add.go +++ b/cmd/minikube/cmd/node_add.go @@ -14,12 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -package node +package cmd import ( "strconv" "github.com/spf13/cobra" + "github.com/spf13/pflag" "github.com/spf13/viper" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/exit" @@ -30,7 +31,7 @@ import ( var nodeAddCmd = &cobra.Command{ Use: "add", Short: "Adds a node to the given cluster.", - Long: "Adds a node to the given cluster config, without starting it.", + Long: "Adds a node to the given cluster config, and starts it.", Run: func(cmd *cobra.Command, args []string) { name := viper.GetString("name") profile := viper.GetString(config.MachineProfile) @@ -48,6 +49,8 @@ var nodeAddCmd = &cobra.Command{ if err != nil { exit.WithError("Error adding node to cluster", err) } + + //ok now start the node }, } @@ -55,5 +58,11 @@ func init() { nodeAddCmd.Flags().String("name", "", "The name of the node to add.") nodeAddCmd.Flags().Bool("control-plane", false, "If true, the node added will also be a control plane in addition to a worker.") nodeAddCmd.Flags().Bool("worker", true, "If true, the added node will be marked for work. Defaults to true.") - NodeCmd.AddCommand(nodeAddCmd) + //We should figure out which of these flags to actually import + startCmd.Flags().Visit( + func(f *pflag.Flag) { + nodeAddCmd.Flags().AddFlag(f) + }, + ) + nodeCmd.AddCommand(nodeAddCmd) } diff --git a/cmd/minikube/cmd/node/delete.go b/cmd/minikube/cmd/node_delete.go similarity index 89% rename from cmd/minikube/cmd/node/delete.go rename to cmd/minikube/cmd/node_delete.go index e94915816f..6271f9a875 100644 --- a/cmd/minikube/cmd/node/delete.go +++ b/cmd/minikube/cmd/node_delete.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package node +package cmd import ( "github.com/spf13/cobra" @@ -32,9 +32,15 @@ var nodeDeleteCmd = &cobra.Command{ exit.UsageT("name is required") } }, + + // Retrieve the node + + // If it's running, stop it + + // Delete that sucker } func init() { nodeDeleteCmd.Flags().String("name", "", "The name of the node to delete") - NodeCmd.AddCommand(nodeDeleteCmd) + nodeCmd.AddCommand(nodeDeleteCmd) } diff --git a/cmd/minikube/cmd/node/start.go b/cmd/minikube/cmd/node_start.go similarity index 66% rename from cmd/minikube/cmd/node/start.go rename to cmd/minikube/cmd/node_start.go index ec32dcd86a..353ad09438 100644 --- a/cmd/minikube/cmd/node/start.go +++ b/cmd/minikube/cmd/node_start.go @@ -14,19 +14,28 @@ See the License for the specific language governing permissions and limitations under the License. */ -package node +package cmd -import "github.com/spf13/cobra" +import ( + "github.com/spf13/cobra" + "github.com/spf13/viper" + "k8s.io/minikube/pkg/minikube/exit" +) var nodeStartCmd = &cobra.Command{ Use: "start", Short: "Starts a node.", - Long: "Starts a node.", + Long: "Starts an existing stopped node in a cluster.", Run: func(cmd *cobra.Command, args []string) { - + name := viper.GetString("name") + if name == "" { + exit.UsageT("name is required") + } }, } func init() { + nodeStartCmd.Flags().String("name", "", "The name of the node to delete") + nodeCmd.AddCommand(nodeStartCmd) } diff --git a/cmd/minikube/cmd/node/stop.go b/cmd/minikube/cmd/node_stop.go similarity index 65% rename from cmd/minikube/cmd/node/stop.go rename to cmd/minikube/cmd/node_stop.go index 991e2905d8..0f0b313168 100644 --- a/cmd/minikube/cmd/node/stop.go +++ b/cmd/minikube/cmd/node_stop.go @@ -14,19 +14,33 @@ See the License for the specific language governing permissions and limitations under the License. */ -package node +package cmd -import "github.com/spf13/cobra" +import ( + "github.com/spf13/cobra" + "github.com/spf13/viper" + "k8s.io/minikube/pkg/minikube/exit" +) var nodeStopCmd = &cobra.Command{ - Use: "delete", + Use: "stop", Short: "Stops a node in a cluster.", Long: "Stops a node in a cluster.", Run: func(cmd *cobra.Command, args []string) { + name := viper.GetString("name") + if name == "" { + exit.UsageT("name is required") + } + // Retrieve the node + + // Make sure it's running + + // Stop that sucker }, } func init() { - + nodeStopCmd.Flags().String("name", "", "The name of the node to delete") + nodeCmd.AddCommand(nodeStopCmd) } diff --git a/cmd/minikube/cmd/root.go b/cmd/minikube/cmd/root.go index a285a138fc..4c5a30f206 100644 --- a/cmd/minikube/cmd/root.go +++ b/cmd/minikube/cmd/root.go @@ -31,7 +31,6 @@ import ( "github.com/spf13/viper" "k8s.io/kubectl/pkg/util/templates" configCmd "k8s.io/minikube/cmd/minikube/cmd/config" - "k8s.io/minikube/cmd/minikube/cmd/node" "k8s.io/minikube/pkg/minikube/bootstrapper" "k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm" "k8s.io/minikube/pkg/minikube/config" @@ -206,7 +205,7 @@ func init() { mountCmd, sshCmd, kubectlCmd, - node.NodeCmd, + nodeCmd, }, }, { diff --git a/pkg/minikube/node/node.go b/pkg/minikube/node/node.go index 9c7102fe60..3017f13ac4 100644 --- a/pkg/minikube/node/node.go +++ b/pkg/minikube/node/node.go @@ -46,7 +46,12 @@ func Add(cc *config.MachineConfig, name string, controlPlane bool, worker bool, } cc.Nodes = append(cc.Nodes, n) - return config.SaveProfile(profileName, cc) + err := config.SaveProfile(profileName, cc) + if err != nil { + return err + } + + return Start(cc, name) } // Delete stops and deletes the given node from the given cluster @@ -70,8 +75,6 @@ func Delete(cc *config.MachineConfig, name string) error { glog.Warningf("Failed to stop node %s. Will still try to delete.", name) } - // Spin down the machine, eventually. - cc.Nodes = append(cc.Nodes[:index], cc.Nodes[index+1:]...) return config.SaveProfile(viper.GetString(config.MachineProfile), cc) }