make node-specifier mandatory
This commit is contained in:
parent
58b1682e32
commit
7d6ae201e9
@ -90,6 +90,10 @@ func CreateCluster(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// k3s server arguments
|
// 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")}
|
k3sServerArgs := []string{"--https-listen-port", c.String("port")}
|
||||||
if c.IsSet("server-arg") || c.IsSet("x") {
|
if c.IsSet("server-arg") || c.IsSet("x") {
|
||||||
k3sServerArgs = append(k3sServerArgs, c.StringSlice("server-arg")...)
|
k3sServerArgs = append(k3sServerArgs, c.StringSlice("server-arg")...)
|
||||||
|
@ -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
|
// validatePortSpecs matches the provided port specs against a set of rules to enable early exit if something is wrong
|
||||||
func validatePortSpecs(specs []string) error {
|
func validatePortSpecs(specs []string) error {
|
||||||
// regex matching (no sophisticated IP/Hostname matching at the moment)
|
// regex matching (no sophisticated IP matching at the moment)
|
||||||
regex := regexp.MustCompile(`^(((?P<host>[\w\.]+)?:)?((?P<hostPort>[0-9]{0,6}):)?(?P<containerPort>[0-9]{1,6}))((/(?P<protocol>udp|tcp))?(?P<nodes>(@(?P<node>[\w-]+))*))$`)
|
regex := regexp.MustCompile(`^(((?P<ip>[\d\.]+)?:)?((?P<hostPort>[0-9]{0,6}):)?(?P<containerPort>[0-9]{1,6}))((/(?P<protocol>udp|tcp))?(?P<nodes>(@(?P<node>[\w-]+))+))$`)
|
||||||
for _, spec := range specs {
|
for _, spec := range specs {
|
||||||
if !regex.MatchString(spec) {
|
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
|
return nil
|
||||||
|
2
main.go
2
main.go
@ -62,7 +62,7 @@ func main() {
|
|||||||
},
|
},
|
||||||
cli.StringSliceFlag{
|
cli.StringSliceFlag{
|
||||||
Name: "publish, add-port",
|
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{
|
cli.StringFlag{
|
||||||
// TODO: to be deprecated
|
// TODO: to be deprecated
|
||||||
|
Loading…
Reference in New Issue
Block a user