diff --git a/cli/commands.go b/cli/commands.go index 7907bc6a..afe61a40 100644 --- a/cli/commands.go +++ b/cli/commands.go @@ -90,6 +90,10 @@ func CreateCluster(c *cli.Context) error { } // k3s server arguments + // TODO: --port will soon be --api-port since we want to re-use --port for arbitrary port mappings + if c.IsSet("port") { + log.Println("WARNING: --port will soon be used for arbitrary port-mappings. It's original functionality can then be used via --api-port.") + } k3sServerArgs := []string{"--https-listen-port", c.String("port")} if c.IsSet("server-arg") || c.IsSet("x") { k3sServerArgs = append(k3sServerArgs, c.StringSlice("server-arg")...) diff --git a/cli/port.go b/cli/port.go index 3b7bd439..e760f13e 100644 --- a/cli/port.go +++ b/cli/port.go @@ -59,11 +59,11 @@ func CreatePublishedPorts(specs []string) (*PublishedPorts, error) { // validatePortSpecs matches the provided port specs against a set of rules to enable early exit if something is wrong func validatePortSpecs(specs []string) error { - // regex matching (no sophisticated IP/Hostname matching at the moment) - regex := regexp.MustCompile(`^(((?P[\w\.]+)?:)?((?P[0-9]{0,6}):)?(?P[0-9]{1,6}))((/(?Pudp|tcp))?(?P(@(?P[\w-]+))*))$`) + // regex matching (no sophisticated IP matching at the moment) + regex := regexp.MustCompile(`^(((?P[\d\.]+)?:)?((?P[0-9]{0,6}):)?(?P[0-9]{1,6}))((/(?Pudp|tcp))?(?P(@(?P[\w-]+))+))$`) for _, spec := range specs { if !regex.MatchString(spec) { - return fmt.Errorf("[ERROR] Provided port spec [%s] didn't match format specification", spec) + return fmt.Errorf("[ERROR] Provided port spec [%s] didn't match format specification (`[ip:][host-port:]container-port[/protocol]@node-specifier`)", spec) } } return nil diff --git a/main.go b/main.go index 94d70519..222e7a77 100644 --- a/main.go +++ b/main.go @@ -62,7 +62,7 @@ func main() { }, cli.StringSliceFlag{ Name: "publish, add-port", - Usage: "publish k3s node ports to the host (Docker notation: `ip:public:private/proto`, use multiple options to expose more ports)", + Usage: "publish k3s node ports to the host (Format: `[ip:][host-port:]container-port[/protocol]@node-specifier`, use multiple options to expose more ports)", }, cli.StringFlag{ // TODO: to be deprecated