代码拉取完成,页面将自动刷新
package clusterprovisioner
import (
"encoding/json"
"github.com/rancher/kontainer-engine/cluster"
"github.com/rancher/rancher/pkg/encryptedstore"
"github.com/rancher/types/apis/core/v1"
"github.com/sirupsen/logrus"
typedv1 "k8s.io/client-go/kubernetes/typed/core/v1"
)
const (
dataKey = "cluster"
)
func NewPersistentStore(namespaces v1.NamespaceInterface, secretsGetter typedv1.SecretsGetter) cluster.PersistentStore {
store, err := encryptedstore.NewGenericEncrypedStore("c-", "", namespaces, secretsGetter)
if err != nil {
logrus.Fatal(err)
}
return &engineStore{
store: store,
}
}
type engineStore struct {
store *encryptedstore.GenericEncryptedStore
}
func (s *engineStore) GetStatus(name string) (string, error) {
cls, err := s.Get(name)
if err != nil {
return "", err
}
return cls.Status, nil
}
func (s *engineStore) Get(name string) (cluster.Cluster, error) {
cluster := cluster.Cluster{}
data, err := s.store.Get(name)
if err != nil {
return cluster, err
}
return cluster, json.Unmarshal([]byte(data[dataKey]), &cluster)
}
func (s *engineStore) Remove(name string) error {
return s.store.Remove(name)
}
func (s *engineStore) Store(cluster cluster.Cluster) error {
content, err := json.Marshal(cluster)
if err != nil {
return err
}
return s.store.Set(cluster.Name, map[string]string{
dataKey: string(content),
})
}
func (s *engineStore) PersistStatus(cluster cluster.Cluster, status string) error {
cluster.Status = status
return s.Store(cluster)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。