37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
templates.go 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
package kubeconfig
import "html/template"
const (
tokenTemplateText = `apiVersion: v1
kind: Config
clusters:
{{- range .Nodes}}
- name: "{{.ClusterName}}"
cluster:
server: "{{.Server}}"
{{- if ne .Cert "" }}
certificate-authority-data: "{{.Cert}}"
{{- end }}
{{- end}}
users:
- name: "{{.User}}"
user:
token: "{{.Token}}"
contexts:
{{- range .Nodes}}
- name: "{{.ClusterName}}"
context:
user: "{{.User}}"
cluster: "{{.ClusterName}}"
{{- end}}
current-context: "{{.ClusterName}}"
`
basicTemplateText = `apiVersion: v1
kind: Config
clusters:
- name: "{{.ClusterName}}"
cluster:
server: "https://{{.Host}}"
api-version: v1
users:
- name: "{{.User}}"
user:
username: "{{.Username}}"
password: "{{.Password}}"
contexts:
- name: "{{.ClusterName}}"
context:
user: "{{.User}}"
cluster: "{{.ClusterName}}"
current-context: "{{.ClusterName}}"
`
)
var (
basicTemplate = template.Must(template.New("basicTemplate").Parse(basicTemplateText))
tokenTemplate = template.Must(template.New("tokenTemplate").Parse(tokenTemplateText))
)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.4-rc23

搜索帮助

0d507c66 1850385 C8b1a773 1850385