mirror of
https://github.com/rancher/rke.git
synced 2025-09-19 10:26:20 +00:00
Minor fixes
This commit is contained in:
@@ -23,10 +23,9 @@ const (
|
|||||||
|
|
||||||
func ConfigCommand() cli.Command {
|
func ConfigCommand() cli.Command {
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "config",
|
Name: "config",
|
||||||
ShortName: "config",
|
Usage: "Setup cluster configuration",
|
||||||
Usage: "Setup cluster configuration",
|
Action: clusterConfig,
|
||||||
Action: clusterConfig,
|
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "name,n",
|
Name: "name,n",
|
||||||
@@ -48,9 +47,9 @@ func ConfigCommand() cli.Command {
|
|||||||
func getConfig(reader *bufio.Reader, text, def string) (string, error) {
|
func getConfig(reader *bufio.Reader, text, def string) (string, error) {
|
||||||
for {
|
for {
|
||||||
if def == "" {
|
if def == "" {
|
||||||
fmt.Printf("%s [%s]: ", text, "none")
|
fmt.Printf("[+] %s [%s]: ", text, "none")
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("%s [%s]: ", text, def)
|
fmt.Printf("[+] %s [%s]: ", text, def)
|
||||||
}
|
}
|
||||||
input, err := reader.ReadString('\n')
|
input, err := reader.ReadString('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -101,7 +100,7 @@ func clusterConfig(ctx *cli.Context) error {
|
|||||||
cluster.SSHKeyPath = sshKeyPath
|
cluster.SSHKeyPath = sshKeyPath
|
||||||
|
|
||||||
// Get number of hosts
|
// Get number of hosts
|
||||||
numberOfHostsString, err := getConfig(reader, "Number of Hosts", "3")
|
numberOfHostsString, err := getConfig(reader, "Number of Hosts", "1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -113,7 +112,7 @@ func clusterConfig(ctx *cli.Context) error {
|
|||||||
// Get Hosts config
|
// Get Hosts config
|
||||||
cluster.Nodes = make([]v3.RKEConfigNode, 0)
|
cluster.Nodes = make([]v3.RKEConfigNode, 0)
|
||||||
for i := 0; i < numberOfHostsInt; i++ {
|
for i := 0; i < numberOfHostsInt; i++ {
|
||||||
hostCfg, err := getHostConfig(reader, i)
|
hostCfg, err := getHostConfig(reader, i, cluster.SSHKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -151,7 +150,7 @@ func clusterConfig(ctx *cli.Context) error {
|
|||||||
return writeConfig(&cluster, configFile, print)
|
return writeConfig(&cluster, configFile, print)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getHostConfig(reader *bufio.Reader, index int) (*v3.RKEConfigNode, error) {
|
func getHostConfig(reader *bufio.Reader, index int, clusterSSHKeyPath string) (*v3.RKEConfigNode, error) {
|
||||||
host := v3.RKEConfigNode{}
|
host := v3.RKEConfigNode{}
|
||||||
|
|
||||||
address, err := getConfig(reader, fmt.Sprintf("SSH Address of host (%d)", index+1), "")
|
address, err := getConfig(reader, fmt.Sprintf("SSH Address of host (%d)", index+1), "")
|
||||||
@@ -164,13 +163,21 @@ func getHostConfig(reader *bufio.Reader, index int) (*v3.RKEConfigNode, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
host.SSHKeyPath = sshKeyPath
|
if len(sshKeyPath) == 0 {
|
||||||
|
fmt.Printf("[-] You have entered empty SSH key path, trying fetch from SSH key parameter\n")
|
||||||
sshKey, err := getConfig(reader, fmt.Sprintf("SSH Private Key of host (%s)", address), "")
|
sshKey, err := getConfig(reader, fmt.Sprintf("SSH Private Key of host (%s)", address), "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(sshKey) == 0 {
|
||||||
|
fmt.Printf("[-] You have entered empty SSH key, defaulting to cluster level SSH key: %s\n", clusterSSHKeyPath)
|
||||||
|
host.SSHKeyPath = clusterSSHKeyPath
|
||||||
|
} else {
|
||||||
|
host.SSHKey = sshKey
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
host.SSHKeyPath = sshKeyPath
|
||||||
}
|
}
|
||||||
host.SSHKey = sshKey
|
|
||||||
|
|
||||||
sshUser, err := getConfig(reader, fmt.Sprintf("SSH User of host (%s)", address), "ubuntu")
|
sshUser, err := getConfig(reader, fmt.Sprintf("SSH User of host (%s)", address), "ubuntu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -303,7 +310,7 @@ func getAuthnConfig(reader *bufio.Reader) (*v3.AuthnConfig, error) {
|
|||||||
|
|
||||||
func getAuthzConfig(reader *bufio.Reader) (*v3.AuthzConfig, error) {
|
func getAuthzConfig(reader *bufio.Reader) (*v3.AuthzConfig, error) {
|
||||||
authzConfig := v3.AuthzConfig{}
|
authzConfig := v3.AuthzConfig{}
|
||||||
authzMode, err := getConfig(reader, "Authorization Mode", "")
|
authzMode, err := getConfig(reader, "Authorization Mode (rbac, none)", cluster.DefaultAuthorizationMode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -314,7 +321,7 @@ func getAuthzConfig(reader *bufio.Reader) (*v3.AuthzConfig, error) {
|
|||||||
func getNetworkConfig(reader *bufio.Reader) (*v3.NetworkConfig, error) {
|
func getNetworkConfig(reader *bufio.Reader) (*v3.NetworkConfig, error) {
|
||||||
networkConfig := v3.NetworkConfig{}
|
networkConfig := v3.NetworkConfig{}
|
||||||
|
|
||||||
networkPlugin, err := getConfig(reader, "Network Plugin Type", cluster.DefaultNetworkCloudProvider)
|
networkPlugin, err := getConfig(reader, "Network Plugin Type (flannel, calico, weave, canal)", cluster.DefaultNetworkPlugin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user