Merge pull request #337 from pixiake/devel

supported privateKey
This commit is contained in:
KubeSphere CI Bot 2020-10-12 16:26:05 +08:00 committed by GitHub
commit 660906928d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 11 deletions

View File

@ -19,13 +19,14 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager
FROM debian:stable
RUN useradd -m kubekey && apt-get update && apt-get install bash curl -y; apt-get autoclean; rm -rf /var/lib/apt/lists/*
WORKDIR /home/kubekey
#ADD addons /home/kubekey/addons
#ADD addons /home/kubekey/addons
#ADD kubekey /home/kubekey/kubekey
#RUN chown kubekey:kubekey -R /home/kubekey/kubekey
COPY --from=builder /workspace/manager /home/kubekey
USER kubekey:kubekey
WORKDIR /home/kubekey
COPY --from=builder /workspace/manager /home/kubekey
ENTRYPOINT ["/home/kubekey/manager"]

View File

@ -110,13 +110,16 @@ func SetDefaultHostsCfg(cfg *ClusterSpec) []HostCfg {
if host.Port == "" {
host.Port = DefaultSSHPort
}
if host.Password == "" && host.PrivateKeyPath == "" {
host.PrivateKeyPath = "~/.ssh/id_rsa"
}
if host.PrivateKeyPath != "" && strings.HasPrefix(strings.TrimSpace(host.PrivateKeyPath), "~/") {
homeDir, _ := util.Home()
host.PrivateKeyPath = strings.Replace(host.PrivateKeyPath, "~/", fmt.Sprintf("%s/", homeDir), 1)
if host.PrivateKey == "" {
if host.Password == "" && host.PrivateKeyPath == "" {
host.PrivateKeyPath = "~/.ssh/id_rsa"
}
if host.PrivateKeyPath != "" && strings.HasPrefix(strings.TrimSpace(host.PrivateKeyPath), "~/") {
homeDir, _ := util.Home()
host.PrivateKeyPath = strings.Replace(host.PrivateKeyPath, "~/", fmt.Sprintf("%s/", homeDir), 1)
}
}
if host.Arch == "" {
host.Arch = DefaultArch
}

View File

@ -55,7 +55,7 @@ func CreateCluster(clusterCfgFile, k8sVersion, ksVersion string, logger *log.Log
return errors.New("Please do not use uppercase letters in hostname: " + host.Name)
}
}
fmt.Println(objName)
return Execute(executor.NewExecutor(&cfg.Spec, objName, logger, "", verbose, skipCheck, skipPullImages, false))
}

View File

@ -81,7 +81,7 @@ func validateOptions(cfg Cfg) (Cfg, error) {
return cfg, errors.New("Must specify at least one of password, private key, keyfile or agent socket")
}
if len(cfg.KeyFile) > 0 {
if len(cfg.PrivateKey) == 0 && len(cfg.KeyFile) > 0 {
content, err := ioutil.ReadFile(cfg.KeyFile)
if err != nil {
return cfg, errors.Wrapf(err, "Failed to read keyfile %q", cfg.KeyFile)