代码拉取完成,页面将自动刷新
package common
import (
"fmt"
"github.com/rancher/rancher/pkg/ref"
v3 "github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/sirupsen/logrus"
)
func GetRuleID(groupID string, ruleName string) string {
return fmt.Sprintf("%s_%s", groupID, ruleName)
}
func GetGroupID(namespace, name string) string {
return fmt.Sprintf("%s:%s", namespace, name)
}
func GetAlertManagerSecretName(appName string) string {
return fmt.Sprintf("alertmanager-%s", appName)
}
func GetAlertManagerDaemonsetName(appName string) string {
return fmt.Sprintf("alertmanager-%s", appName)
}
func formatProjectDisplayName(projectDisplayName, projectID string) string {
return fmt.Sprintf("%s (ID: %s)", projectDisplayName, projectID)
}
func formatClusterDisplayName(clusterDisplayName, clusterID string) string {
return fmt.Sprintf("%s (ID: %s)", clusterDisplayName, clusterID)
}
func GetClusterDisplayName(clusterName string, clusterLister v3.ClusterLister) string {
cluster, err := clusterLister.Get("", clusterName)
if err != nil {
logrus.Warnf("Failed to get cluster for %s: %v", clusterName, err)
return clusterName
}
return formatClusterDisplayName(cluster.Spec.DisplayName, clusterName)
}
func GetProjectDisplayName(projectID string, projectLister v3.ProjectLister) string {
clusterName, projectName := ref.Parse(projectID)
project, err := projectLister.Get(clusterName, projectName)
if err != nil {
logrus.Warnf("Failed to get project %s: %v", projectID, err)
return projectID
}
return formatProjectDisplayName(project.Spec.DisplayName, projectID)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。