mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-05 14:31:27 +02:00
* Simplified bootstrapping of a cluster Introduced a new convention about a pre-defined `bootstrap-admin` account for `orchard controller run`. Providing `ORCHARD_BOOTSTRAP_ADMIN_TOKEN` will auto-create such user for easier configuration. `bootstrap-admin` can be used for creating other service accounts on the first run and after that can be disposed. Also change `orchard worker run` to expect controller URL as the only parameter and a bootstrap token passed via an argument instead of using a context that might not be created. * Missing error check
29 lines
539 B
Go
29 lines
539 B
Go
package netconstants
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
DefaultControllerPort = 6120
|
|
DefaultControllerServerName = "orchard-controller"
|
|
)
|
|
|
|
func NormalizeAddress(addr string) (*url.URL, error) {
|
|
if !strings.HasPrefix(addr, "https://") && !strings.HasPrefix(addr, "http://") {
|
|
addr = "https://" + addr
|
|
}
|
|
|
|
controllerURL, err := url.Parse(addr)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if controllerURL.Port() == "" {
|
|
controllerURL.Host += fmt.Sprintf(":%d", DefaultControllerPort)
|
|
}
|
|
return controllerURL, nil
|
|
}
|