1 Star 0 Fork 0

powerpaas/rke

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
common.go 1.15 KB
一键复制 编辑 原始数据 按行查看 历史
Bill Maxwell 提交于 2018-03-05 17:52 . Leverage global SSHAgentAuth setting
package cmd
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/urfave/cli"
)
var sshCliOptions = []cli.Flag{
cli.BoolFlag{
Name: "ssh-agent-auth",
Usage: "Use SSH Agent Auth defined by SSH_AUTH_SOCK",
},
}
func resolveClusterFile(ctx *cli.Context) (string, string, error) {
clusterFile := ctx.String("config")
fp, err := filepath.Abs(clusterFile)
if err != nil {
return "", "", fmt.Errorf("failed to lookup current directory name: %v", err)
}
file, err := os.Open(fp)
if err != nil {
return "", "", fmt.Errorf("Can not find cluster configuration file: %v", err)
}
defer file.Close()
buf, err := ioutil.ReadAll(file)
if err != nil {
return "", "", fmt.Errorf("failed to read file: %v", err)
}
clusterFileBuff := string(buf)
return clusterFileBuff, clusterFile, nil
}
func setOptionsFromCLI(c *cli.Context, rkeConfig *v3.RancherKubernetesEngineConfig) (*v3.RancherKubernetesEngineConfig, error) {
// If true... override the file.. else let file value go through
if c.Bool("ssh-agent-auth") {
rkeConfig.SSHAgentAuth = c.Bool("ssh-agent-auth")
}
return rkeConfig, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/powerpaas/rke.git
git@gitee.com:powerpaas/rke.git
powerpaas
rke
rke
v0.1.7-rc1

搜索帮助