From 988fbdbdc5174f6923a9c4021ebfa421891feda1 Mon Sep 17 00:00:00 2001 From: Andy Zhou Date: Mon, 6 May 2019 16:22:00 -0700 Subject: [PATCH] Refactor createWorker() API Use postfix as int instead string. This make the following patch easier to read. --- cli/commands.go | 2 +- cli/container.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/commands.go b/cli/commands.go index 16fdf79c..6fd46731 100644 --- a/cli/commands.go +++ b/cli/commands.go @@ -148,7 +148,7 @@ func CreateCluster(c *cli.Context) error { env, c.String("name"), strings.Split(c.String("volume"), ","), - strconv.Itoa(i), + i, c.String("port"), ) if err != nil { diff --git a/cli/container.go b/cli/container.go index 752ca552..12ef8ebd 100644 --- a/cli/container.go +++ b/cli/container.go @@ -190,14 +190,14 @@ func createServer(verbose bool, image string, port string, args []string, env [] } // createWorker creates/starts a k3s agent node that connects to the server -func createWorker(verbose bool, image string, args []string, env []string, name string, volumes []string, postfix string, serverPort string) (string, error) { +func createWorker(verbose bool, image string, args []string, env []string, name string, volumes []string, postfix int, serverPort string) (string, error) { containerLabels := make(map[string]string) containerLabels["app"] = "k3d" containerLabels["component"] = "worker" containerLabels["created"] = time.Now().Format("2006-01-02 15:04:05") containerLabels["cluster"] = name - containerName := fmt.Sprintf("k3d-%s-worker-%s", name, postfix) + containerName := fmt.Sprintf("k3d-%s-worker-%d", name, postfix) env = append(env, fmt.Sprintf("K3S_URL=https://k3d-%s-server:%s", name, serverPort))