start with --wait flag

pull/227/head v3.0.0-dev-20191205-0
iwilltry42 5 years ago
parent 68609ec3a0
commit 1a91401d19
  1. 14
      cmd/create/createCluster.go
  2. 5
      pkg/types/types.go

@ -68,6 +68,7 @@ func NewCmdCreateCluster() *cobra.Command {
cmd.Flags().String("secret", "", "Specify a cluster secret. By default, we generate one.")
cmd.Flags().StringArrayP("volume", "v", nil, "Mount volumes into the nodes (Format: `--volume [SOURCE:]DEST[@NODEFILTER[;NODEFILTER...]]`\n - Example: `k3d create -w 2 -v /my/path@worker[0,1] -v /tmp/test:/tmp/other@master[0]`")
cmd.Flags().StringArrayP("port", "p", nil, "Map ports from the node containers to the host (Format: `[HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER]`)\n - Example: `k3d create -w 2 -p 8080:80@worker[0] -p 8081@worker[1]`")
cmd.Flags().Int("wait", -1, "Wait for a specified amount of time (seconds, >= 0, 0 = forever) for the master(s) to be ready or timeout and rollback before returning")
/* Image Importing */
cmd.Flags().Bool("no-image-volume", false, "Disable the creation of a volume for importing images")
@ -151,6 +152,18 @@ func parseCreateClusterCmd(cmd *cobra.Command, args []string) (runtimes.Runtime,
log.Fatalln(err)
}
// --wait
wait, err := cmd.Flags().GetInt("wait")
if err != nil {
log.Fatalln(err)
}
if cmd.Flags().Changed("wait") && wait < 0 {
log.Fatalln("Value of '--wait' can't be less than 0")
}
if cmd.Flags().Changed("wait") {
log.Warnln("--wait not implemented yet") // TODO:
}
// --api-port
apiPortFlags, err := cmd.Flags().GetStringArray("api-port")
if err != nil {
@ -305,6 +318,7 @@ func parseCreateClusterCmd(cmd *cobra.Command, args []string) (runtimes.Runtime,
Secret: secret,
ClusterCreationOpts: &k3d.ClusterCreationOpts{
DisableImageVolume: noImageVolume,
WaitForMaster: wait,
},
}

@ -21,7 +21,9 @@ THE SOFTWARE.
*/
package types
import "fmt"
import (
"fmt"
)
// DefaultClusterName specifies the default name used for newly created clusters
const DefaultClusterName = "k3s-default"
@ -88,6 +90,7 @@ const DefaultKubeconfigPrefix = DefaultObjectNamePrefix + "-kubeconfig"
// ClusterCreationOpts describe a set of options one can set when creating a cluster
type ClusterCreationOpts struct {
DisableImageVolume bool
WaitForMaster int
}
// ClusterNetwork describes a network which a cluster is running in

Loading…
Cancel
Save