37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
lookup.go 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
Darren Shepherd 提交于 2018-04-04 13:44 . Drop cluster.Spec.DisplayName
package rkecerts
import (
"fmt"
"github.com/rancher/kontainer-engine/cluster"
"github.com/rancher/kontainer-engine/drivers/rke/rkecerts"
"github.com/rancher/rancher/pkg/controllers/management/clusterprovisioner"
"github.com/rancher/rke/pki"
"github.com/rancher/types/apis/core/v1"
"github.com/rancher/types/apis/management.cattle.io/v3"
typedv1 "k8s.io/client-go/kubernetes/typed/core/v1"
)
type BundleLookup struct {
engineStore cluster.PersistentStore
}
func NewLookup(namespaces v1.NamespaceInterface, secrets typedv1.SecretsGetter) *BundleLookup {
return &BundleLookup{
engineStore: clusterprovisioner.NewPersistentStore(namespaces, secrets),
}
}
func (r *BundleLookup) Lookup(cluster *v3.Cluster) (*Bundle, error) {
c, err := r.engineStore.Get(cluster.Name)
if err != nil {
return nil, err
}
certs, ok := c.Metadata["Certs"]
if !ok {
return nil, fmt.Errorf("waiting for certs to be generated for cluster %s", cluster.Name)
}
certMap, err := rkecerts.LoadString(certs)
if err != nil {
return nil, err
}
newCertMap := map[string]pki.CertificatePKI{}
for k, v := range certMap {
if v.Config != "" {
v.ConfigPath = pki.GetConfigPath(k)
}
if v.Key != nil {
v.KeyPath = pki.GetKeyPath(k)
}
if v.Certificate != nil {
v.Path = pki.GetCertPath(k)
}
newCertMap[k] = v
}
return newBundle(newCertMap), nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.0.0-beta4-rc3

搜索帮助

0d507c66 1850385 C8b1a773 1850385