Commit f6f8b503 authored by Sharif Elgamal's avatar Sharif Elgamal

fill in cmd code

parent eded9a17
......@@ -50,7 +50,7 @@ var nodeAddCmd = &cobra.Command{
exit.WithError("Error adding node to cluster", err)
}
//ok now start the node
node.Start(mc, name)
},
}
......
......@@ -19,7 +19,11 @@ package cmd
import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/machine"
"k8s.io/minikube/pkg/minikube/node"
)
var nodeDeleteCmd = &cobra.Command{
......@@ -31,13 +35,24 @@ var nodeDeleteCmd = &cobra.Command{
if name == "" {
exit.UsageT("name is required")
}
},
// Retrieve the node
// Make sure it's not running
api, err := machine.NewAPIClient()
if err != nil {
exit.WithError("creating api client", err)
}
cc, err := config.Load(viper.GetString(config.MachineProfile))
if err != nil {
exit.WithError("loading config", err)
}
// If it's running, stop it
if cluster.IsHostRunning(api, name) {
node.Stop(cc, name)
}
// Delete that sucker
node.Delete(cc, name)
},
}
func init() {
......
......@@ -17,9 +17,16 @@ limitations under the License.
package cmd
import (
"os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/machine"
"k8s.io/minikube/pkg/minikube/node"
"k8s.io/minikube/pkg/minikube/out"
)
var nodeStartCmd = &cobra.Command{
......@@ -31,11 +38,28 @@ var nodeStartCmd = &cobra.Command{
if name == "" {
exit.UsageT("name is required")
}
// Make sure it's not running
api, err := machine.NewAPIClient()
if err != nil {
exit.WithError("creating api client", err)
}
if cluster.IsHostRunning(api, name) {
out.T(out.Check, "{{.name}} is already running", out.V{"name": name})
os.Exit(0)
}
cc, err := config.Load(viper.GetString(config.MachineProfile))
if err != nil {
exit.WithError("loading config", err)
}
// Start it up baby
node.Start(cc, name)
},
}
func init() {
nodeStartCmd.Flags().String("name", "", "The name of the node to delete")
nodeCmd.AddCommand(nodeStartCmd)
}
......@@ -17,9 +17,16 @@ limitations under the License.
package cmd
import (
"os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/machine"
"k8s.io/minikube/pkg/minikube/node"
"k8s.io/minikube/pkg/minikube/out"
)
var nodeStopCmd = &cobra.Command{
......@@ -32,11 +39,22 @@ var nodeStopCmd = &cobra.Command{
exit.UsageT("name is required")
}
// Retrieve the node
api, err := machine.NewAPIClient()
if err != nil {
exit.WithError("creating api client", err)
}
// Make sure it's running
if !cluster.IsHostRunning(api, name) {
out.T(out.Check, "{{.name}} is already stopped", out.V{"name": name})
os.Exit(0)
}
// Stop that sucker
cc, err := config.Load(viper.GetString(config.MachineProfile))
if err != nil {
exit.WithError("loading config", err)
}
// Start it up baby
node.Stop(cc, name)
},
}
......
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