37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ingress_endpoints.go 1.81 KB
一键复制 编辑 原始数据 按行查看 历史
Darren Shepherd 提交于 2018-11-06 10:06 . Change return type
package endpoints
import (
"strings"
workloadutil "github.com/rancher/rancher/pkg/controllers/user/workload"
"github.com/rancher/types/apis/extensions/v1beta1"
managementv3 "github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/sirupsen/logrus"
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
"k8s.io/apimachinery/pkg/runtime"
)
type IngressEndpointsController struct {
workloadController workloadutil.CommonController
ingressInterface v1beta1.IngressInterface
machinesLister managementv3.NodeLister
isRKE bool
clusterName string
}
func (c *IngressEndpointsController) sync(key string, obj *extensionsv1beta1.Ingress) (runtime.Object, error) {
namespace := ""
if obj != nil {
namespace = obj.Namespace
} else {
split := strings.Split(key, "/")
if len(split) == 2 {
namespace = split[0]
}
}
c.workloadController.EnqueueAllWorkloads(namespace)
if obj == nil || obj.DeletionTimestamp != nil {
return nil, nil
}
if _, err := c.reconcileEndpointsForIngress(obj); err != nil {
return nil, err
}
return nil, nil
}
func (c *IngressEndpointsController) reconcileEndpointsForIngress(obj *extensionsv1beta1.Ingress) (bool, error) {
fromObj := convertIngressToPublicEndpoints(obj, c.isRKE)
fromAnnotation := getPublicEndpointsFromAnnotations(obj.Annotations)
if areEqualEndpoints(fromAnnotation, fromObj) {
return false, nil
}
epsToUpdate, err := publicEndpointsToString(fromObj)
if err != nil {
return false, err
}
logrus.Infof("Updating ingress [%s:%s] with public endpoints [%v]", obj.Namespace, obj.Name, epsToUpdate)
toUpdate := obj.DeepCopy()
if toUpdate.Annotations == nil {
toUpdate.Annotations = make(map[string]string)
}
toUpdate.Annotations[endpointsAnnotation] = epsToUpdate
_, err = c.ingressInterface.Update(toUpdate)
return false, err
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.2-rc7

搜索帮助

0d507c66 1850385 C8b1a773 1850385