37 Star 407 Fork 74

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))
)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.0-rc13

搜索帮助