37 Star 402 Fork 75

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ingress_common.go 919 Bytes
一键复制 编辑 原始数据 按行查看 历史
package ingress
import (
"encoding/base64"
"encoding/json"
"fmt"
"strings"
"github.com/rancher/norman/types/convert"
"github.com/rancher/rancher/pkg/settings"
"k8s.io/api/extensions/v1beta1"
)
const (
ingressStateAnnotation = "field.cattle.io/ingressState"
)
func GetStateKey(name, namespace, host string, path string, port string) string {
ipDomain := settings.IngressIPDomain.Get()
if ipDomain != "" && strings.HasSuffix(host, ipDomain) {
host = ipDomain
}
key := fmt.Sprintf("%s/%s/%s/%s/%s", name, namespace, host, path, port)
return base64.URLEncoding.EncodeToString([]byte(key))
}
func GetIngressState(obj *v1beta1.Ingress) map[string]string {
annotations := obj.Annotations
if annotations == nil {
return nil
}
if v, ok := annotations[ingressStateAnnotation]; ok {
state := make(map[string]string)
json.Unmarshal([]byte(convert.ToString(v)), &state)
return state
}
return nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.0.1-rc4

搜索帮助