From f33fa2d4cce26d0c1d95bb2257329a6c6a157b29 Mon Sep 17 00:00:00 2001 From: iwilltry42 Date: Fri, 6 Sep 2019 11:55:22 +0200 Subject: [PATCH] move global constants to types.go --- cli/commands.go | 6 +++--- cli/types.go | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cli/commands.go b/cli/commands.go index 0e0bf66b..1372b5e8 100644 --- a/cli/commands.go +++ b/cli/commands.go @@ -85,7 +85,7 @@ func CreateCluster(c *cli.Context) error { image := c.String("image") // if no registry was provided, use the default docker.io if len(strings.Split(image, "/")) <= 2 { - image = fmt.Sprintf("%s/%s", defaultRegistry, image) + image = fmt.Sprintf("%s/%s", DefaultRegistry, image) } /* @@ -165,7 +165,7 @@ func CreateCluster(c *cli.Context) error { * List of ports, that should be mapped from some or all k3d node containers to the host system (or other interface) */ // new port map - portmap, err := mapNodesToPortSpecs(c.StringSlice("port"), GetAllContainerNames(c.String("name"), defaultServerCount, c.Int("workers"))) + portmap, err := mapNodesToPortSpecs(c.StringSlice("port"), GetAllContainerNames(c.String("name"), DefaultServerCount, c.Int("workers"))) if err != nil { log.Fatal(err) } @@ -480,7 +480,7 @@ func AddNode(c *cli.Context) error { image := c.String("image") // if no registry was provided, use the default docker.io if len(strings.Split(image, "/")) <= 2 { - image = fmt.Sprintf("%s/%s", defaultRegistry, image) + image = fmt.Sprintf("%s/%s", DefaultRegistry, image) } clusterSpec.Image = image diff --git a/cli/types.go b/cli/types.go index 80cf6899..60b0cff3 100644 --- a/cli/types.go +++ b/cli/types.go @@ -5,6 +5,12 @@ import ( "github.com/docker/go-connections/nat" ) +// Globally used constants +const ( + DefaultRegistry = "docker.io" + DefaultServerCount = 1 +) + // Cluster describes an existing cluster type Cluster struct { name string