shuffling stuff around for import purposes

parent dc0be4ae
......@@ -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",
......
......@@ -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)
}
......@@ -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)
}
......@@ -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)
}
......@@ -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)
}
......@@ -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,
},
},
{
......
......@@ -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)
}
......
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