Skip to content

Commit

Permalink
minikube_node -> minikube_cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-the-programmer committed Oct 14, 2022
1 parent ebf3017 commit a529ff0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion hack/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func main() {
IsoUrls: []string{"https://github.com/kubernetes/minikube/releases/download/v1.26.1/minikube-v1.26.1-amd64.iso"},
DeleteOnFailure: true},
service.MinikubeClientDeps{
Node: service.NewMinikubeNode(),
Node: service.NewMinikubeCluster(),
Downloader: service.NewMinikubeDownloader(),
})

Expand Down
4 changes: 2 additions & 2 deletions minikube/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func setClusterState(d *schema.ResourceData, config *config.ClusterConfig, ports
d.Set("vm_driver", config.VMDriver)
}

//getClusterOutputs return the cluster key, certificate and certificate authority from the provided kubeconfig
// getClusterOutputs return the cluster key, certificate and certificate authority from the provided kubeconfig
func getClusterOutputs(kc *kubeconfig.Settings) (string, string, string, string, error) {
key, err := state_utils.ReadContents(kc.ClientKey)
if err != nil {
Expand Down Expand Up @@ -325,7 +325,7 @@ func initialiseMinikubeClient(d *schema.ResourceData, m interface{}) (service.Cl
})

clusterClient.SetDependencies(service.MinikubeClientDeps{
Node: service.NewMinikubeNode(),
Node: service.NewMinikubeCluster(),
Downloader: service.NewMinikubeDownloader(),
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/host"
delete "k8s.io/minikube/cmd/minikube/cmd"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
Expand All @@ -25,15 +26,15 @@ type Node interface {
Add(cc *config.ClusterConfig, starter node.Starter) error
}

type MinikubeNode struct {
type MinikubeCluster struct {
workerNodes int
}

func NewMinikubeNode() *MinikubeNode {
return &MinikubeNode{workerNodes: 0}
func NewMinikubeCluster() *MinikubeCluster {
return &MinikubeCluster{workerNodes: 0}
}

func (m *MinikubeNode) Provision(cc *config.ClusterConfig, n *config.Node, apiServer bool, delOnFail bool) (command.Runner, bool, libmachine.API, *host.Host, error) {
func (m *MinikubeCluster) Provision(cc *config.ClusterConfig, n *config.Node, apiServer bool, delOnFail bool) (command.Runner, bool, libmachine.API, *host.Host, error) {
makeAllMinikubeDirectories()
_, err := node.CacheKubectlBinary(cc.KubernetesConfig.KubernetesVersion, cc.BinaryMirror)
if err != nil {
Expand All @@ -43,13 +44,13 @@ func (m *MinikubeNode) Provision(cc *config.ClusterConfig, n *config.Node, apiSe
return node.Provision(cc, n, apiServer, delOnFail)
}

func (m *MinikubeNode) Start(starter node.Starter, apiServer bool) (*kubeconfig.Settings, error) {
func (m *MinikubeCluster) Start(starter node.Starter, apiServer bool) (*kubeconfig.Settings, error) {

return node.Start(starter, apiServer)
}

//Add adds nodes to the clusters node pool
func (m *MinikubeNode) Add(cc *config.ClusterConfig, starter node.Starter) error {
// Add adds nodes to the clusters node pool
func (m *MinikubeCluster) Add(cc *config.ClusterConfig, starter node.Starter) error {
n := config.Node{
Name: node.Name(m.workerNodes),
Worker: true,
Expand All @@ -61,28 +62,33 @@ func (m *MinikubeNode) Add(cc *config.ClusterConfig, starter node.Starter) error
return node.Add(cc, n, true)
}

func (m *MinikubeNode) Delete(cc config.ClusterConfig, name string) (*config.Node, error) {
node, err := node.Delete(cc, name)
if err != nil {
return node, err
func (m *MinikubeCluster) Delete(cc config.ClusterConfig, name string) (*config.Node, error) {
errs := delete.DeleteProfiles([]*config.Profile{
{
Name: name,
Config: &cc,
},
})
if len(errs) > 0 {
return nil, errs[0]
}

machineDir := filepath.Join(localpath.MiniPath(), "machines", name)
profilesDir := filepath.Join(localpath.MiniPath(), "profiles", name)
err = rmdir(machineDir)
err := rmdir(machineDir)
if err != nil {
return node, err
return nil, err
}

err = rmdir(profilesDir)
if err != nil {
return node, err
return nil, err
}

return node, err
return nil, err
}

func (m *MinikubeNode) Get(name string) mustload.ClusterController {
func (m *MinikubeCluster) Get(name string) mustload.ClusterController {
return mustload.Running(name)
}

Expand Down

0 comments on commit a529ff0

Please sign in to comment.