36 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
utils.go 829 Bytes
一键复制 编辑 原始数据 按行查看 历史
package networkpolicy
import (
"fmt"
"github.com/rancher/norman/types/convert"
"github.com/rancher/types/apis/management.cattle.io/v3"
corev1 "k8s.io/api/core/v1"
)
func isNetworkPolicyDisabled(clusterNamespace string, clusterLister v3.ClusterLister) (bool, error) {
cluster, err := clusterLister.Get("", clusterNamespace)
if err != nil {
return false, fmt.Errorf("error getting cluster %v", err)
}
return !convert.ToBool(cluster.Annotations[netPolAnnotation]), nil
}
func nodePortService(service *corev1.Service) bool {
for _, port := range service.Spec.Ports {
if port.NodePort != 0 {
return true
}
}
return false
}
func hostPortPod(pod *corev1.Pod) bool {
for _, c := range pod.Spec.Containers {
for _, port := range c.Ports {
if port.HostPort != 0 {
return true
}
}
}
return false
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.0.9-rc1

搜索帮助