Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

Commit

Permalink
clean ups
Browse files Browse the repository at this point in the history
Signed-off-by: Chuck Ha <[email protected]>
  • Loading branch information
chuckha committed Jun 19, 2019
1 parent 6b8d570 commit d67e28e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 44 deletions.
28 changes: 0 additions & 28 deletions actuators/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"fmt"
"time"

v1 "k8s.io/api/core/v1"

"github.com/chuckha/cluster-api-provider-docker/kind/actions"
"k8s.io/apimachinery/pkg/types"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
Expand Down Expand Up @@ -197,32 +195,6 @@ func (m *Machine) save(old, new *clusterv1.Machine) error {
return nil
}

// This should be the cloud-provider for docker, but that doesn't exist.
func (m *Machine) setProviderID(node *v1.Node, kindName string) error {
old := node.DeepCopy()
node.Spec.ProviderID = providerID(kindName)
p, err := patch.NewJSONPatch(old, node)
if err != nil {
fmt.Printf("%+v\n", err)
return err
}
fmt.Println("Patches for node", p)
if len(p) != 0 {
pb, err := json.MarshalIndent(p, "", " ")
if err != nil {
fmt.Printf("%+v\n", err)
return err
}
if _, err := m.Core.Nodes().Patch(node.Name, types.JSONPatchType, pb); err != nil {
fmt.Printf("%+v\n", err)
return err
}
fmt.Println("updated node")
}
return nil

}

func providerNameToLookupID(providerName string) string {
return providerName[len("docker://"):]
}
Expand Down
24 changes: 8 additions & 16 deletions cmd/capdctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ import (
"fmt"
"io/ioutil"
"os"
"strings"

"github.com/chuckha/cluster-api-provider-docker/execer"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
)

const (
// Important to keep this consistent.
controlPlaneSet = "controlplane"
)

type machineOptions struct {
name, namespace, clusterName, set, version *string
}
Expand All @@ -54,7 +58,7 @@ func main() {
controlPlane := flag.NewFlagSet("control-plane", flag.ExitOnError)
controlPlaneOpts := new(machineOptions)
controlPlaneOpts.initFlags(controlPlane)
*controlPlaneOpts.set = "controlplane"
*controlPlaneOpts.set = controlPlaneSet

worker := flag.NewFlagSet("worker", flag.ExitOnError)
workerOpts := new(machineOptions)
Expand Down Expand Up @@ -149,15 +153,15 @@ func machineYAML(opts *machineOptions) string {
Namespace: *opts.namespace,
Labels: map[string]string{
"cluster.k8s.io/cluster-name": *opts.clusterName,
"set": *opts.set,
"set": *opts.set,
},
},
Spec: v1alpha1.MachineSpec{
ProviderSpec: v1alpha1.ProviderSpec{},
},
}
// TODO: 🤔
if *opts.set == "control-plane" {
if *opts.set == controlPlaneSet {
machine.Spec.Versions.ControlPlane = *opts.version
}
if *opts.set == "worker" {
Expand All @@ -173,18 +177,6 @@ func machineYAML(opts *machineOptions) string {

func makeManagementCluster(clusterName string) {
kind := execer.NewClient("kind")
// if a cluster named kind already exists then we assume we're good to go:
clusters, err := kind.RunCommandReturnOutput("get", "clusters")
if err != nil {
panic(err)
}
for _, cluster := range strings.Split(clusters, "\n") {
if strings.TrimSpace(cluster) == "kind" {
fmt.Println("Management cluster detected")
return
}
}

// start kind with docker mount
kindConfig, err := kindConfigFile()
if err != nil {
Expand Down

0 comments on commit d67e28e

Please sign in to comment.