36 Star 414 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.github
app
chart
cleanup
k8s
package
pkg
agent
api
audit
auth
catalog
cert
clustermanager
clusterprovisioninglogger
clusterrouter
configfield
controllers
management
auth
catalog
clusterdeploy
clusterevents
clustergc
clusterprovisioner
clusterstats
clusterstatus
temporarycredentials.go
compose
node
nodedriver
nodepool
podsecuritypolicy
test/e2e
usercontrollers
controller.go
user
dialer
dynamiclistener
embedded
encryptedstore
filter
httpproxy
hyperkube
image
k8scheck
k8slookup
k8sproxy
kubeconfig
kubectl
librke
logserver
namespace
node
nodeconfig
pipeline
project
randomtoken
rbac
ref
remotedialer
resourcequota
rkecerts
rkedialerfactory
rkenodeconfigclient
rkenodeconfigserver
rkeworker
settings
systemaccount
systemtemplate
telemetry
templatecontent
ticker
tls
tunnelserver
rke-templates
scripts
server
tests
vendor
.dockerignore
.drone.yml
.gitignore
CONTRIBUTING.md
Dockerfile.dapper
LICENSE
Makefile
README.md
README_1_6.md
code-of-conduct.md
keybase.md
main.go
vendor.conf
克隆/下载
temporarycredentials.go 1.28 KB
一键复制 编辑 原始数据 按行查看 历史
package clusterstatus
import (
"fmt"
"strconv"
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/rancher/types/config"
)
const TemporaryCredentialsAnnotationKey = "clusterstatus.management.cattle.io/temporary-security-credentials"
func Register(management *config.ManagementContext) {
c := &clusterAnnotations{
clusters: management.Management.Clusters(""),
}
management.Management.Clusters("").AddHandler("temporary-credentials", c.sync)
}
type clusterAnnotations struct {
clusters v3.ClusterInterface
}
func (cd *clusterAnnotations) sync(key string, cluster *v3.Cluster) error {
if key == "" || cluster == nil || cluster.DeletionTimestamp != nil {
return nil
}
if eksConfig := cluster.Spec.AmazonElasticContainerServiceConfig; eksConfig != nil {
newValue := strconv.FormatBool(eksConfig.SessionToken != "")
if newValue != cluster.Annotations[TemporaryCredentialsAnnotationKey] {
original := cluster
cluster = original.DeepCopy()
if cluster.Annotations == nil {
cluster.Annotations = make(map[string]string)
}
cluster.Annotations[TemporaryCredentialsAnnotationKey] = newValue
_, err := cd.clusters.Update(cluster)
if err != nil {
return fmt.Errorf("error updating temporary credentials annotation: %v", err)
}
}
}
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.1.10-rc1

搜索帮助