Skip to content

Commit

Permalink
Merge pull request #102 from rancher/feature/add-node-command
Browse files Browse the repository at this point in the history
[Feature] `add-node` command and deprecation cleanup
  • Loading branch information
iwilltry42 authored Jan 2, 2020
2 parents 122ea46 + 97bebba commit 8a65268
Show file tree
Hide file tree
Showing 7 changed files with 527 additions and 134 deletions.
15 changes: 3 additions & 12 deletions cli/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ const (
defaultContainerNamePrefix = "k3d"
)

type cluster struct {
name string
image string
status string
serverPorts []string
server types.Container
workers []types.Container
}

// GetContainerName generates the container names
func GetContainerName(role, clusterName string, postfix int) string {
if postfix >= 0 {
Expand Down Expand Up @@ -256,7 +247,7 @@ func getClusterStatus(server types.Container, workers []types.Container) string
// When 'all' is true, 'cluster' contains all clusters found from the docker daemon
// When 'all' is false, 'cluster' contains up to one cluster whose name matches 'name'. 'cluster' can
// be empty if no matching cluster is found.
func getClusters(all bool, name string) (map[string]cluster, error) {
func getClusters(all bool, name string) (map[string]Cluster, error) {
ctx := context.Background()
docker, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
Expand All @@ -277,7 +268,7 @@ func getClusters(all bool, name string) (map[string]cluster, error) {
return nil, fmt.Errorf("WARNING: couldn't list server containers\n%+v", err)
}

clusters := make(map[string]cluster)
clusters := make(map[string]Cluster)

// don't filter for servers but for workers now
filters.Del("label", "component=server")
Expand Down Expand Up @@ -308,7 +299,7 @@ func getClusters(all bool, name string) (map[string]cluster, error) {
for _, port := range server.Ports {
serverPorts = append(serverPorts, strconv.Itoa(int(port.PublicPort)))
}
clusters[clusterName] = cluster{
clusters[clusterName] = Cluster{
name: clusterName,
image: server.Image,
status: getClusterStatus(server, workers),
Expand Down
Loading

0 comments on commit 8a65268

Please # to comment.