From 593d3fc73e1d61c1c4e432192addd4df8cafe429 Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Tue, 28 Jan 2020 17:09:00 -0800 Subject: [PATCH] moving packages around --- cmd/minikube/cmd/config/node/add.go | 36 ------------------------ cmd/minikube/cmd/config/node/delete.go | 32 --------------------- cmd/minikube/cmd/config/node/node.go | 31 -------------------- cmd/minikube/cmd/config/node/start.go | 32 --------------------- cmd/minikube/cmd/config/node/stop.go | 32 --------------------- pkg/minikube/cluster/node/node.go | 39 -------------------------- pkg/minikube/node/node.go | 27 ++++++++++++++++-- 7 files changed, 24 insertions(+), 205 deletions(-) delete mode 100644 cmd/minikube/cmd/config/node/add.go delete mode 100644 cmd/minikube/cmd/config/node/delete.go delete mode 100644 cmd/minikube/cmd/config/node/node.go delete mode 100644 cmd/minikube/cmd/config/node/start.go delete mode 100644 cmd/minikube/cmd/config/node/stop.go delete mode 100644 pkg/minikube/cluster/node/node.go diff --git a/cmd/minikube/cmd/config/node/add.go b/cmd/minikube/cmd/config/node/add.go deleted file mode 100644 index dd385e680b..0000000000 --- a/cmd/minikube/cmd/config/node/add.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package config - -import ( - "github.com/spf13/cobra" -) - -var name string - -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.", - Run: func(cmd *cobra.Command, args []string) { - - }, -} - -func init() { - -} diff --git a/cmd/minikube/cmd/config/node/delete.go b/cmd/minikube/cmd/config/node/delete.go deleted file mode 100644 index c15b1a8603..0000000000 --- a/cmd/minikube/cmd/config/node/delete.go +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package config - -import "github.com/spf13/cobra" - -var nodeDeleteCmd = &cobra.Command{ - Use: "delete", - Short: "Deletes a node from a cluster.", - Long: "Deletes a node from a cluster.", - Run: func(cmd *cobra.Command, args []string) { - - }, -} - -func init() { - -} diff --git a/cmd/minikube/cmd/config/node/node.go b/cmd/minikube/cmd/config/node/node.go deleted file mode 100644 index 697f9ac6e7..0000000000 --- a/cmd/minikube/cmd/config/node/node.go +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package config - -import ( - "github.com/spf13/cobra" - "k8s.io/minikube/pkg/minikube/exit" -) - -var NodeCmd = &cobra.Command{ - Use: "node", - Short: "Node operations", - Long: "Operations on nodes", - Run: func(cmd *cobra.Command, args []string) { - exit.UsageT("Usage: minikube node [add|start|stop|delete]") - }, -} diff --git a/cmd/minikube/cmd/config/node/start.go b/cmd/minikube/cmd/config/node/start.go deleted file mode 100644 index bbb1392947..0000000000 --- a/cmd/minikube/cmd/config/node/start.go +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package config - -import "github.com/spf13/cobra" - -var nodeStartCmd = &cobra.Command{ - Use: "start", - Short: "Starts a node.", - Long: "Starts a node.", - Run: func(cmd *cobra.Command, args []string) { - - }, -} - -func init() { - -} diff --git a/cmd/minikube/cmd/config/node/stop.go b/cmd/minikube/cmd/config/node/stop.go deleted file mode 100644 index be38017928..0000000000 --- a/cmd/minikube/cmd/config/node/stop.go +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package config - -import "github.com/spf13/cobra" - -var nodeStopCmd = &cobra.Command{ - Use: "delete", - Short: "Stops a node in a cluster.", - Long: "Stops a node in a cluster.", - Run: func(cmd *cobra.Command, args []string) { - - }, -} - -func init() { - -} diff --git a/pkg/minikube/cluster/node/node.go b/pkg/minikube/cluster/node/node.go deleted file mode 100644 index a756c4bb8a..0000000000 --- a/pkg/minikube/cluster/node/node.go +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright 2019 The Kubernetes Authors All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cluster - -import "k8s.io/minikube/pkg/minikube/config" - -// AddNode adds a new node config to a cluster. -func AddNode(cfg config.MachineConfig, name string) error { - return nil -} - -// StartNode starts the given node -func StartNode(node config.Node) error { - return nil -} - -// StopNode stops the given node -func StopNode(node config.Node) error { - return nil -} - -// DeleteNode deletes the given node from the given cluster -func DeleteNode(cfg config.MachineConfig, node config.Node) error { - return nil -} diff --git a/pkg/minikube/node/node.go b/pkg/minikube/node/node.go index 90b0c4aa13..4b227539d4 100644 --- a/pkg/minikube/node/node.go +++ b/pkg/minikube/node/node.go @@ -19,6 +19,8 @@ package node import ( "errors" + "github.com/golang/glog" + "github.com/spf13/viper" "k8s.io/minikube/pkg/minikube/config" ) @@ -43,10 +45,12 @@ func Add(cc *config.MachineConfig, name string, controlPlane bool, k8sVersion st // Delete stops and deletes the given node from the given cluster func Delete(cc *config.MachineConfig, name string) error { - nd := nil - for _, n := range cc.Nodes { + var nd *config.Node + index := 0 + for i, n := range cc.Nodes { if n.Name == name { - nd = n + nd = &n + index = i break } } @@ -54,8 +58,25 @@ func Delete(cc *config.MachineConfig, name string) error { if nd == nil { return errors.New("Could not find node " + name) } + + err := Stop(cc, name) + if err != nil { + 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) } +// Stop stops the node in the given cluster func Stop(cc *config.MachineConfig, name string) error { return nil } + +// Start spins up a guest and starts the kubernetes node. +func Start(cc *config.MachineConfig, name string) error { + // Throw all the slop from cmd.start in here + return nil +}