id
int32 0
167k
| repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
163,700 | cilium/cilium | pkg/k8s/service.go | ParseServiceID | func ParseServiceID(svc *types.Service) ServiceID {
return ServiceID{
Name: svc.ObjectMeta.Name,
Namespace: svc.ObjectMeta.Namespace,
}
} | go | func ParseServiceID(svc *types.Service) ServiceID {
return ServiceID{
Name: svc.ObjectMeta.Name,
Namespace: svc.ObjectMeta.Namespace,
}
} | [
"func",
"ParseServiceID",
"(",
"svc",
"*",
"types",
".",
"Service",
")",
"ServiceID",
"{",
"return",
"ServiceID",
"{",
"Name",
":",
"svc",
".",
"ObjectMeta",
".",
"Name",
",",
"Namespace",
":",
"svc",
".",
"ObjectMeta",
".",
"Namespace",
",",
"}",
"\n",
"}"
] | // ParseServiceID parses a Kubernetes service and returns the ServiceID | [
"ParseServiceID",
"parses",
"a",
"Kubernetes",
"service",
"and",
"returns",
"the",
"ServiceID"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service.go#L50-L55 |
163,701 | cilium/cilium | pkg/k8s/service.go | ParseService | func ParseService(svc *types.Service) (ServiceID, *Service) {
scopedLog := log.WithFields(logrus.Fields{
logfields.K8sSvcName: svc.ObjectMeta.Name,
logfields.K8sNamespace: svc.ObjectMeta.Namespace,
logfields.K8sAPIVersion: svc.TypeMeta.APIVersion,
logfields.K8sSvcType: svc.Spec.Type,
})
svcID := ParseServiceID(svc)
switch svc.Spec.Type {
case v1.ServiceTypeClusterIP, v1.ServiceTypeNodePort, v1.ServiceTypeLoadBalancer:
break
case v1.ServiceTypeExternalName:
// External-name services must be ignored
return svcID, nil
default:
scopedLog.Warn("Ignoring k8s service: unsupported type")
return svcID, nil
}
if svc.Spec.ClusterIP == "" {
return svcID, nil
}
clusterIP := net.ParseIP(svc.Spec.ClusterIP)
headless := false
if strings.ToLower(svc.Spec.ClusterIP) == "none" {
headless = true
}
svcInfo := NewService(clusterIP, headless, svc.Labels, svc.Spec.Selector)
svcInfo.IncludeExternal = getAnnotationIncludeExternal(svc)
svcInfo.Shared = getAnnotationShared(svc)
// FIXME: Add support for
// - NodePort
for _, port := range svc.Spec.Ports {
p := loadbalancer.NewFEPort(loadbalancer.L4Type(port.Protocol), uint16(port.Port))
if _, ok := svcInfo.Ports[loadbalancer.FEPortName(port.Name)]; !ok {
svcInfo.Ports[loadbalancer.FEPortName(port.Name)] = p
}
}
return svcID, svcInfo
} | go | func ParseService(svc *types.Service) (ServiceID, *Service) {
scopedLog := log.WithFields(logrus.Fields{
logfields.K8sSvcName: svc.ObjectMeta.Name,
logfields.K8sNamespace: svc.ObjectMeta.Namespace,
logfields.K8sAPIVersion: svc.TypeMeta.APIVersion,
logfields.K8sSvcType: svc.Spec.Type,
})
svcID := ParseServiceID(svc)
switch svc.Spec.Type {
case v1.ServiceTypeClusterIP, v1.ServiceTypeNodePort, v1.ServiceTypeLoadBalancer:
break
case v1.ServiceTypeExternalName:
// External-name services must be ignored
return svcID, nil
default:
scopedLog.Warn("Ignoring k8s service: unsupported type")
return svcID, nil
}
if svc.Spec.ClusterIP == "" {
return svcID, nil
}
clusterIP := net.ParseIP(svc.Spec.ClusterIP)
headless := false
if strings.ToLower(svc.Spec.ClusterIP) == "none" {
headless = true
}
svcInfo := NewService(clusterIP, headless, svc.Labels, svc.Spec.Selector)
svcInfo.IncludeExternal = getAnnotationIncludeExternal(svc)
svcInfo.Shared = getAnnotationShared(svc)
// FIXME: Add support for
// - NodePort
for _, port := range svc.Spec.Ports {
p := loadbalancer.NewFEPort(loadbalancer.L4Type(port.Protocol), uint16(port.Port))
if _, ok := svcInfo.Ports[loadbalancer.FEPortName(port.Name)]; !ok {
svcInfo.Ports[loadbalancer.FEPortName(port.Name)] = p
}
}
return svcID, svcInfo
} | [
"func",
"ParseService",
"(",
"svc",
"*",
"types",
".",
"Service",
")",
"(",
"ServiceID",
",",
"*",
"Service",
")",
"{",
"scopedLog",
":=",
"log",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"logfields",
".",
"K8sSvcName",
":",
"svc",
".",
"ObjectMeta",
".",
"Name",
",",
"logfields",
".",
"K8sNamespace",
":",
"svc",
".",
"ObjectMeta",
".",
"Namespace",
",",
"logfields",
".",
"K8sAPIVersion",
":",
"svc",
".",
"TypeMeta",
".",
"APIVersion",
",",
"logfields",
".",
"K8sSvcType",
":",
"svc",
".",
"Spec",
".",
"Type",
",",
"}",
")",
"\n\n",
"svcID",
":=",
"ParseServiceID",
"(",
"svc",
")",
"\n\n",
"switch",
"svc",
".",
"Spec",
".",
"Type",
"{",
"case",
"v1",
".",
"ServiceTypeClusterIP",
",",
"v1",
".",
"ServiceTypeNodePort",
",",
"v1",
".",
"ServiceTypeLoadBalancer",
":",
"break",
"\n\n",
"case",
"v1",
".",
"ServiceTypeExternalName",
":",
"// External-name services must be ignored",
"return",
"svcID",
",",
"nil",
"\n\n",
"default",
":",
"scopedLog",
".",
"Warn",
"(",
"\"",
"\"",
")",
"\n",
"return",
"svcID",
",",
"nil",
"\n",
"}",
"\n\n",
"if",
"svc",
".",
"Spec",
".",
"ClusterIP",
"==",
"\"",
"\"",
"{",
"return",
"svcID",
",",
"nil",
"\n",
"}",
"\n\n",
"clusterIP",
":=",
"net",
".",
"ParseIP",
"(",
"svc",
".",
"Spec",
".",
"ClusterIP",
")",
"\n",
"headless",
":=",
"false",
"\n",
"if",
"strings",
".",
"ToLower",
"(",
"svc",
".",
"Spec",
".",
"ClusterIP",
")",
"==",
"\"",
"\"",
"{",
"headless",
"=",
"true",
"\n",
"}",
"\n",
"svcInfo",
":=",
"NewService",
"(",
"clusterIP",
",",
"headless",
",",
"svc",
".",
"Labels",
",",
"svc",
".",
"Spec",
".",
"Selector",
")",
"\n",
"svcInfo",
".",
"IncludeExternal",
"=",
"getAnnotationIncludeExternal",
"(",
"svc",
")",
"\n",
"svcInfo",
".",
"Shared",
"=",
"getAnnotationShared",
"(",
"svc",
")",
"\n\n",
"// FIXME: Add support for",
"// - NodePort",
"for",
"_",
",",
"port",
":=",
"range",
"svc",
".",
"Spec",
".",
"Ports",
"{",
"p",
":=",
"loadbalancer",
".",
"NewFEPort",
"(",
"loadbalancer",
".",
"L4Type",
"(",
"port",
".",
"Protocol",
")",
",",
"uint16",
"(",
"port",
".",
"Port",
")",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"svcInfo",
".",
"Ports",
"[",
"loadbalancer",
".",
"FEPortName",
"(",
"port",
".",
"Name",
")",
"]",
";",
"!",
"ok",
"{",
"svcInfo",
".",
"Ports",
"[",
"loadbalancer",
".",
"FEPortName",
"(",
"port",
".",
"Name",
")",
"]",
"=",
"p",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"svcID",
",",
"svcInfo",
"\n",
"}"
] | // ParseService parses a Kubernetes service and returns a Service | [
"ParseService",
"parses",
"a",
"Kubernetes",
"service",
"and",
"returns",
"a",
"Service"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service.go#L58-L104 |
163,702 | cilium/cilium | pkg/k8s/service.go | String | func (s ServiceID) String() string {
return fmt.Sprintf("%s/%s", s.Namespace, s.Name)
} | go | func (s ServiceID) String() string {
return fmt.Sprintf("%s/%s", s.Namespace, s.Name)
} | [
"func",
"(",
"s",
"ServiceID",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"Namespace",
",",
"s",
".",
"Name",
")",
"\n",
"}"
] | // String returns the string representation of a service ID | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"service",
"ID"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service.go#L113-L115 |
163,703 | cilium/cilium | pkg/k8s/service.go | ParseServiceIDFrom | func ParseServiceIDFrom(dn string) *ServiceID {
// typical service name "cilium-etcd-client.kube-system.svc"
idx1 := strings.IndexByte(dn, '.')
if idx1 >= 0 {
svc := ServiceID{
Name: dn[:idx1],
}
idx2 := strings.IndexByte(dn[idx1+1:], '.')
if idx2 >= 0 {
// "cilium-etcd-client.kube-system.svc"
// ^idx1+1 ^ idx1+1+idx2
svc.Namespace = dn[idx1+1 : idx1+1+idx2]
} else {
// "cilium-etcd-client.kube-system"
// ^idx1+1
svc.Namespace = dn[idx1+1:]
}
return &svc
}
return nil
} | go | func ParseServiceIDFrom(dn string) *ServiceID {
// typical service name "cilium-etcd-client.kube-system.svc"
idx1 := strings.IndexByte(dn, '.')
if idx1 >= 0 {
svc := ServiceID{
Name: dn[:idx1],
}
idx2 := strings.IndexByte(dn[idx1+1:], '.')
if idx2 >= 0 {
// "cilium-etcd-client.kube-system.svc"
// ^idx1+1 ^ idx1+1+idx2
svc.Namespace = dn[idx1+1 : idx1+1+idx2]
} else {
// "cilium-etcd-client.kube-system"
// ^idx1+1
svc.Namespace = dn[idx1+1:]
}
return &svc
}
return nil
} | [
"func",
"ParseServiceIDFrom",
"(",
"dn",
"string",
")",
"*",
"ServiceID",
"{",
"// typical service name \"cilium-etcd-client.kube-system.svc\"",
"idx1",
":=",
"strings",
".",
"IndexByte",
"(",
"dn",
",",
"'.'",
")",
"\n",
"if",
"idx1",
">=",
"0",
"{",
"svc",
":=",
"ServiceID",
"{",
"Name",
":",
"dn",
"[",
":",
"idx1",
"]",
",",
"}",
"\n",
"idx2",
":=",
"strings",
".",
"IndexByte",
"(",
"dn",
"[",
"idx1",
"+",
"1",
":",
"]",
",",
"'.'",
")",
"\n",
"if",
"idx2",
">=",
"0",
"{",
"// \"cilium-etcd-client.kube-system.svc\"",
"// ^idx1+1 ^ idx1+1+idx2",
"svc",
".",
"Namespace",
"=",
"dn",
"[",
"idx1",
"+",
"1",
":",
"idx1",
"+",
"1",
"+",
"idx2",
"]",
"\n",
"}",
"else",
"{",
"// \"cilium-etcd-client.kube-system\"",
"// ^idx1+1",
"svc",
".",
"Namespace",
"=",
"dn",
"[",
"idx1",
"+",
"1",
":",
"]",
"\n",
"}",
"\n",
"return",
"&",
"svc",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // ParseServiceIDFrom returns a ServiceID derived from the given kubernetes
// service FQDN. | [
"ParseServiceIDFrom",
"returns",
"a",
"ServiceID",
"derived",
"from",
"the",
"given",
"kubernetes",
"service",
"FQDN",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service.go#L119-L139 |
163,704 | cilium/cilium | pkg/k8s/service.go | String | func (s *Service) String() string {
if s == nil {
return "nil"
}
ports := make([]string, len(s.Ports))
i := 0
for p := range s.Ports {
ports[i] = string(p)
i++
}
return fmt.Sprintf("frontend:%s/ports=%s/selector=%v", s.FrontendIP.String(), ports, s.Selector)
} | go | func (s *Service) String() string {
if s == nil {
return "nil"
}
ports := make([]string, len(s.Ports))
i := 0
for p := range s.Ports {
ports[i] = string(p)
i++
}
return fmt.Sprintf("frontend:%s/ports=%s/selector=%v", s.FrontendIP.String(), ports, s.Selector)
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"String",
"(",
")",
"string",
"{",
"if",
"s",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"ports",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"s",
".",
"Ports",
")",
")",
"\n",
"i",
":=",
"0",
"\n",
"for",
"p",
":=",
"range",
"s",
".",
"Ports",
"{",
"ports",
"[",
"i",
"]",
"=",
"string",
"(",
"p",
")",
"\n",
"i",
"++",
"\n",
"}",
"\n\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"FrontendIP",
".",
"String",
"(",
")",
",",
"ports",
",",
"s",
".",
"Selector",
")",
"\n",
"}"
] | // String returns the string representation of a service resource | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"service",
"resource"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service.go#L160-L173 |
163,705 | cilium/cilium | pkg/k8s/service.go | DeepEquals | func (s *Service) DeepEquals(o *Service) bool {
switch {
case (s == nil) != (o == nil):
return false
case (s == nil) && (o == nil):
return true
}
if s.IsHeadless == o.IsHeadless &&
s.FrontendIP.Equal(o.FrontendIP) &&
comparator.MapStringEquals(s.Labels, o.Labels) &&
comparator.MapStringEquals(s.Selector, o.Selector) {
if ((s.Ports == nil) != (o.Ports == nil)) ||
len(s.Ports) != len(o.Ports) {
return false
}
for portName, port := range s.Ports {
oPort, ok := o.Ports[portName]
if !ok {
return false
}
if !port.EqualsIgnoreID(oPort) {
return false
}
}
return true
}
return false
} | go | func (s *Service) DeepEquals(o *Service) bool {
switch {
case (s == nil) != (o == nil):
return false
case (s == nil) && (o == nil):
return true
}
if s.IsHeadless == o.IsHeadless &&
s.FrontendIP.Equal(o.FrontendIP) &&
comparator.MapStringEquals(s.Labels, o.Labels) &&
comparator.MapStringEquals(s.Selector, o.Selector) {
if ((s.Ports == nil) != (o.Ports == nil)) ||
len(s.Ports) != len(o.Ports) {
return false
}
for portName, port := range s.Ports {
oPort, ok := o.Ports[portName]
if !ok {
return false
}
if !port.EqualsIgnoreID(oPort) {
return false
}
}
return true
}
return false
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"DeepEquals",
"(",
"o",
"*",
"Service",
")",
"bool",
"{",
"switch",
"{",
"case",
"(",
"s",
"==",
"nil",
")",
"!=",
"(",
"o",
"==",
"nil",
")",
":",
"return",
"false",
"\n",
"case",
"(",
"s",
"==",
"nil",
")",
"&&",
"(",
"o",
"==",
"nil",
")",
":",
"return",
"true",
"\n",
"}",
"\n",
"if",
"s",
".",
"IsHeadless",
"==",
"o",
".",
"IsHeadless",
"&&",
"s",
".",
"FrontendIP",
".",
"Equal",
"(",
"o",
".",
"FrontendIP",
")",
"&&",
"comparator",
".",
"MapStringEquals",
"(",
"s",
".",
"Labels",
",",
"o",
".",
"Labels",
")",
"&&",
"comparator",
".",
"MapStringEquals",
"(",
"s",
".",
"Selector",
",",
"o",
".",
"Selector",
")",
"{",
"if",
"(",
"(",
"s",
".",
"Ports",
"==",
"nil",
")",
"!=",
"(",
"o",
".",
"Ports",
"==",
"nil",
")",
")",
"||",
"len",
"(",
"s",
".",
"Ports",
")",
"!=",
"len",
"(",
"o",
".",
"Ports",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"portName",
",",
"port",
":=",
"range",
"s",
".",
"Ports",
"{",
"oPort",
",",
"ok",
":=",
"o",
".",
"Ports",
"[",
"portName",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"!",
"port",
".",
"EqualsIgnoreID",
"(",
"oPort",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // DeepEquals returns true if both services are equal | [
"DeepEquals",
"returns",
"true",
"if",
"both",
"services",
"are",
"equal"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service.go#L181-L209 |
163,706 | cilium/cilium | pkg/k8s/service.go | NewService | func NewService(ip net.IP, headless bool, labels map[string]string, selector map[string]string) *Service {
return &Service{
FrontendIP: ip,
IsHeadless: headless,
Ports: map[loadbalancer.FEPortName]*loadbalancer.FEPort{},
Labels: labels,
Selector: selector,
}
} | go | func NewService(ip net.IP, headless bool, labels map[string]string, selector map[string]string) *Service {
return &Service{
FrontendIP: ip,
IsHeadless: headless,
Ports: map[loadbalancer.FEPortName]*loadbalancer.FEPort{},
Labels: labels,
Selector: selector,
}
} | [
"func",
"NewService",
"(",
"ip",
"net",
".",
"IP",
",",
"headless",
"bool",
",",
"labels",
"map",
"[",
"string",
"]",
"string",
",",
"selector",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"Service",
"{",
"return",
"&",
"Service",
"{",
"FrontendIP",
":",
"ip",
",",
"IsHeadless",
":",
"headless",
",",
"Ports",
":",
"map",
"[",
"loadbalancer",
".",
"FEPortName",
"]",
"*",
"loadbalancer",
".",
"FEPort",
"{",
"}",
",",
"Labels",
":",
"labels",
",",
"Selector",
":",
"selector",
",",
"}",
"\n",
"}"
] | // NewService returns a new Service with the Ports map initialized. | [
"NewService",
"returns",
"a",
"new",
"Service",
"with",
"the",
"Ports",
"map",
"initialized",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service.go#L212-L220 |
163,707 | cilium/cilium | pkg/k8s/service.go | UniquePorts | func (s *Service) UniquePorts() map[uint16]bool {
// We are not discriminating the different L4 protocols on the same L4
// port so we create the number of unique sets of service IP + service
// port.
uniqPorts := map[uint16]bool{}
for _, p := range s.Ports {
uniqPorts[p.Port] = true
}
return uniqPorts
} | go | func (s *Service) UniquePorts() map[uint16]bool {
// We are not discriminating the different L4 protocols on the same L4
// port so we create the number of unique sets of service IP + service
// port.
uniqPorts := map[uint16]bool{}
for _, p := range s.Ports {
uniqPorts[p.Port] = true
}
return uniqPorts
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"UniquePorts",
"(",
")",
"map",
"[",
"uint16",
"]",
"bool",
"{",
"// We are not discriminating the different L4 protocols on the same L4",
"// port so we create the number of unique sets of service IP + service",
"// port.",
"uniqPorts",
":=",
"map",
"[",
"uint16",
"]",
"bool",
"{",
"}",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"s",
".",
"Ports",
"{",
"uniqPorts",
"[",
"p",
".",
"Port",
"]",
"=",
"true",
"\n",
"}",
"\n",
"return",
"uniqPorts",
"\n",
"}"
] | // UniquePorts returns a map of all unique ports configured in the service | [
"UniquePorts",
"returns",
"a",
"map",
"of",
"all",
"unique",
"ports",
"configured",
"in",
"the",
"service"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service.go#L223-L232 |
163,708 | cilium/cilium | pkg/k8s/service.go | NewClusterService | func NewClusterService(id ServiceID, k8sService *Service, k8sEndpoints *Endpoints) service.ClusterService {
svc := service.NewClusterService(id.Name, id.Namespace)
for key, value := range k8sService.Labels {
svc.Labels[key] = value
}
for key, value := range k8sService.Selector {
svc.Selector[key] = value
}
portConfig := service.PortConfiguration{}
for portName, port := range k8sService.Ports {
portConfig[string(portName)] = port.L4Addr
}
svc.Frontends = map[string]service.PortConfiguration{}
svc.Frontends[k8sService.FrontendIP.String()] = portConfig
svc.Backends = map[string]service.PortConfiguration{}
for ipString, portConfig := range k8sEndpoints.Backends {
svc.Backends[ipString] = portConfig
}
return svc
} | go | func NewClusterService(id ServiceID, k8sService *Service, k8sEndpoints *Endpoints) service.ClusterService {
svc := service.NewClusterService(id.Name, id.Namespace)
for key, value := range k8sService.Labels {
svc.Labels[key] = value
}
for key, value := range k8sService.Selector {
svc.Selector[key] = value
}
portConfig := service.PortConfiguration{}
for portName, port := range k8sService.Ports {
portConfig[string(portName)] = port.L4Addr
}
svc.Frontends = map[string]service.PortConfiguration{}
svc.Frontends[k8sService.FrontendIP.String()] = portConfig
svc.Backends = map[string]service.PortConfiguration{}
for ipString, portConfig := range k8sEndpoints.Backends {
svc.Backends[ipString] = portConfig
}
return svc
} | [
"func",
"NewClusterService",
"(",
"id",
"ServiceID",
",",
"k8sService",
"*",
"Service",
",",
"k8sEndpoints",
"*",
"Endpoints",
")",
"service",
".",
"ClusterService",
"{",
"svc",
":=",
"service",
".",
"NewClusterService",
"(",
"id",
".",
"Name",
",",
"id",
".",
"Namespace",
")",
"\n\n",
"for",
"key",
",",
"value",
":=",
"range",
"k8sService",
".",
"Labels",
"{",
"svc",
".",
"Labels",
"[",
"key",
"]",
"=",
"value",
"\n",
"}",
"\n\n",
"for",
"key",
",",
"value",
":=",
"range",
"k8sService",
".",
"Selector",
"{",
"svc",
".",
"Selector",
"[",
"key",
"]",
"=",
"value",
"\n",
"}",
"\n\n",
"portConfig",
":=",
"service",
".",
"PortConfiguration",
"{",
"}",
"\n",
"for",
"portName",
",",
"port",
":=",
"range",
"k8sService",
".",
"Ports",
"{",
"portConfig",
"[",
"string",
"(",
"portName",
")",
"]",
"=",
"port",
".",
"L4Addr",
"\n",
"}",
"\n\n",
"svc",
".",
"Frontends",
"=",
"map",
"[",
"string",
"]",
"service",
".",
"PortConfiguration",
"{",
"}",
"\n",
"svc",
".",
"Frontends",
"[",
"k8sService",
".",
"FrontendIP",
".",
"String",
"(",
")",
"]",
"=",
"portConfig",
"\n\n",
"svc",
".",
"Backends",
"=",
"map",
"[",
"string",
"]",
"service",
".",
"PortConfiguration",
"{",
"}",
"\n",
"for",
"ipString",
",",
"portConfig",
":=",
"range",
"k8sEndpoints",
".",
"Backends",
"{",
"svc",
".",
"Backends",
"[",
"ipString",
"]",
"=",
"portConfig",
"\n",
"}",
"\n\n",
"return",
"svc",
"\n",
"}"
] | // NewClusterService returns the service.ClusterService representing a
// Kubernetes Service | [
"NewClusterService",
"returns",
"the",
"service",
".",
"ClusterService",
"representing",
"a",
"Kubernetes",
"Service"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/service.go#L236-L261 |
163,709 | cilium/cilium | pkg/service/store.go | DeepEquals | func (p PortConfiguration) DeepEquals(o PortConfiguration) bool {
if len(p) != len(o) {
return false
}
for portName1, port1 := range p {
port2, ok := o[portName1]
if !ok || !port1.Equals(port2) {
return false
}
}
return true
} | go | func (p PortConfiguration) DeepEquals(o PortConfiguration) bool {
if len(p) != len(o) {
return false
}
for portName1, port1 := range p {
port2, ok := o[portName1]
if !ok || !port1.Equals(port2) {
return false
}
}
return true
} | [
"func",
"(",
"p",
"PortConfiguration",
")",
"DeepEquals",
"(",
"o",
"PortConfiguration",
")",
"bool",
"{",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"o",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"for",
"portName1",
",",
"port1",
":=",
"range",
"p",
"{",
"port2",
",",
"ok",
":=",
"o",
"[",
"portName1",
"]",
"\n\n",
"if",
"!",
"ok",
"||",
"!",
"port1",
".",
"Equals",
"(",
"port2",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"true",
"\n",
"}"
] | // DeepEquals returns true if both PortConfigurations are identical | [
"DeepEquals",
"returns",
"true",
"if",
"both",
"PortConfigurations",
"are",
"identical"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/service/store.go#L40-L54 |
163,710 | cilium/cilium | pkg/service/store.go | GetKeyName | func (s *ClusterService) GetKeyName() string {
// WARNING - STABLE API: Changing the structure of the key may break
// backwards compatibility
return path.Join(s.Cluster, s.Namespace, s.Name)
} | go | func (s *ClusterService) GetKeyName() string {
// WARNING - STABLE API: Changing the structure of the key may break
// backwards compatibility
return path.Join(s.Cluster, s.Namespace, s.Name)
} | [
"func",
"(",
"s",
"*",
"ClusterService",
")",
"GetKeyName",
"(",
")",
"string",
"{",
"// WARNING - STABLE API: Changing the structure of the key may break",
"// backwards compatibility",
"return",
"path",
".",
"Join",
"(",
"s",
".",
"Cluster",
",",
"s",
".",
"Namespace",
",",
"s",
".",
"Name",
")",
"\n",
"}"
] | // GetKeyName returns the kvstore key to be used for the global service | [
"GetKeyName",
"returns",
"the",
"kvstore",
"key",
"to",
"be",
"used",
"for",
"the",
"global",
"service"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/service/store.go#L96-L100 |
163,711 | cilium/cilium | pkg/service/store.go | Unmarshal | func (s *ClusterService) Unmarshal(data []byte) error {
newService := NewClusterService("", "")
if err := json.Unmarshal(data, &newService); err != nil {
return err
}
*s = newService
return nil
} | go | func (s *ClusterService) Unmarshal(data []byte) error {
newService := NewClusterService("", "")
if err := json.Unmarshal(data, &newService); err != nil {
return err
}
*s = newService
return nil
} | [
"func",
"(",
"s",
"*",
"ClusterService",
")",
"Unmarshal",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"newService",
":=",
"NewClusterService",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"newService",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"*",
"s",
"=",
"newService",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Unmarshal parses the JSON byte slice and updates the global service receiver | [
"Unmarshal",
"parses",
"the",
"JSON",
"byte",
"slice",
"and",
"updates",
"the",
"global",
"service",
"receiver"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/service/store.go#L113-L123 |
163,712 | cilium/cilium | pkg/service/store.go | NewClusterService | func NewClusterService(name, namespace string) ClusterService {
return ClusterService{
Name: name,
Namespace: namespace,
Frontends: map[string]PortConfiguration{},
Backends: map[string]PortConfiguration{},
Labels: map[string]string{},
Selector: map[string]string{},
}
} | go | func NewClusterService(name, namespace string) ClusterService {
return ClusterService{
Name: name,
Namespace: namespace,
Frontends: map[string]PortConfiguration{},
Backends: map[string]PortConfiguration{},
Labels: map[string]string{},
Selector: map[string]string{},
}
} | [
"func",
"NewClusterService",
"(",
"name",
",",
"namespace",
"string",
")",
"ClusterService",
"{",
"return",
"ClusterService",
"{",
"Name",
":",
"name",
",",
"Namespace",
":",
"namespace",
",",
"Frontends",
":",
"map",
"[",
"string",
"]",
"PortConfiguration",
"{",
"}",
",",
"Backends",
":",
"map",
"[",
"string",
"]",
"PortConfiguration",
"{",
"}",
",",
"Labels",
":",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
",",
"Selector",
":",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
",",
"}",
"\n",
"}"
] | // NewClusterService returns a new cluster service definition | [
"NewClusterService",
"returns",
"a",
"new",
"cluster",
"service",
"definition"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/service/store.go#L126-L135 |
163,713 | cilium/cilium | pkg/k8s/client/clientset/versioned/typed/cilium.io/v2/fake/fake_ciliumendpoint.go | List | func (c *FakeCiliumEndpoints) List(opts v1.ListOptions) (result *v2.CiliumEndpointList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(ciliumendpointsResource, ciliumendpointsKind, c.ns, opts), &v2.CiliumEndpointList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v2.CiliumEndpointList{ListMeta: obj.(*v2.CiliumEndpointList).ListMeta}
for _, item := range obj.(*v2.CiliumEndpointList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
} | go | func (c *FakeCiliumEndpoints) List(opts v1.ListOptions) (result *v2.CiliumEndpointList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(ciliumendpointsResource, ciliumendpointsKind, c.ns, opts), &v2.CiliumEndpointList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v2.CiliumEndpointList{ListMeta: obj.(*v2.CiliumEndpointList).ListMeta}
for _, item := range obj.(*v2.CiliumEndpointList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
} | [
"func",
"(",
"c",
"*",
"FakeCiliumEndpoints",
")",
"List",
"(",
"opts",
"v1",
".",
"ListOptions",
")",
"(",
"result",
"*",
"v2",
".",
"CiliumEndpointList",
",",
"err",
"error",
")",
"{",
"obj",
",",
"err",
":=",
"c",
".",
"Fake",
".",
"Invokes",
"(",
"testing",
".",
"NewListAction",
"(",
"ciliumendpointsResource",
",",
"ciliumendpointsKind",
",",
"c",
".",
"ns",
",",
"opts",
")",
",",
"&",
"v2",
".",
"CiliumEndpointList",
"{",
"}",
")",
"\n\n",
"if",
"obj",
"==",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"label",
",",
"_",
",",
"_",
":=",
"testing",
".",
"ExtractFromListOptions",
"(",
"opts",
")",
"\n",
"if",
"label",
"==",
"nil",
"{",
"label",
"=",
"labels",
".",
"Everything",
"(",
")",
"\n",
"}",
"\n",
"list",
":=",
"&",
"v2",
".",
"CiliumEndpointList",
"{",
"ListMeta",
":",
"obj",
".",
"(",
"*",
"v2",
".",
"CiliumEndpointList",
")",
".",
"ListMeta",
"}",
"\n",
"for",
"_",
",",
"item",
":=",
"range",
"obj",
".",
"(",
"*",
"v2",
".",
"CiliumEndpointList",
")",
".",
"Items",
"{",
"if",
"label",
".",
"Matches",
"(",
"labels",
".",
"Set",
"(",
"item",
".",
"Labels",
")",
")",
"{",
"list",
".",
"Items",
"=",
"append",
"(",
"list",
".",
"Items",
",",
"item",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"list",
",",
"err",
"\n",
"}"
] | // List takes label and field selectors, and returns the list of CiliumEndpoints that match those selectors. | [
"List",
"takes",
"label",
"and",
"field",
"selectors",
"and",
"returns",
"the",
"list",
"of",
"CiliumEndpoints",
"that",
"match",
"those",
"selectors",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/client/clientset/versioned/typed/cilium.io/v2/fake/fake_ciliumendpoint.go#L51-L70 |
163,714 | cilium/cilium | pkg/k8s/client/clientset/versioned/typed/cilium.io/v2/fake/fake_ciliumendpoint.go | Watch | func (c *FakeCiliumEndpoints) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(ciliumendpointsResource, c.ns, opts))
} | go | func (c *FakeCiliumEndpoints) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(ciliumendpointsResource, c.ns, opts))
} | [
"func",
"(",
"c",
"*",
"FakeCiliumEndpoints",
")",
"Watch",
"(",
"opts",
"v1",
".",
"ListOptions",
")",
"(",
"watch",
".",
"Interface",
",",
"error",
")",
"{",
"return",
"c",
".",
"Fake",
".",
"InvokesWatch",
"(",
"testing",
".",
"NewWatchAction",
"(",
"ciliumendpointsResource",
",",
"c",
".",
"ns",
",",
"opts",
")",
")",
"\n\n",
"}"
] | // Watch returns a watch.Interface that watches the requested ciliumEndpoints. | [
"Watch",
"returns",
"a",
"watch",
".",
"Interface",
"that",
"watches",
"the",
"requested",
"ciliumEndpoints",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/client/clientset/versioned/typed/cilium.io/v2/fake/fake_ciliumendpoint.go#L73-L77 |
163,715 | cilium/cilium | pkg/k8s/client/clientset/versioned/typed/cilium.io/v2/fake/fake_ciliumendpoint.go | Delete | func (c *FakeCiliumEndpoints) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(ciliumendpointsResource, c.ns, name), &v2.CiliumEndpoint{})
return err
} | go | func (c *FakeCiliumEndpoints) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(ciliumendpointsResource, c.ns, name), &v2.CiliumEndpoint{})
return err
} | [
"func",
"(",
"c",
"*",
"FakeCiliumEndpoints",
")",
"Delete",
"(",
"name",
"string",
",",
"options",
"*",
"v1",
".",
"DeleteOptions",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"Fake",
".",
"Invokes",
"(",
"testing",
".",
"NewDeleteAction",
"(",
"ciliumendpointsResource",
",",
"c",
".",
"ns",
",",
"name",
")",
",",
"&",
"v2",
".",
"CiliumEndpoint",
"{",
"}",
")",
"\n\n",
"return",
"err",
"\n",
"}"
] | // Delete takes name of the ciliumEndpoint and deletes it. Returns an error if one occurs. | [
"Delete",
"takes",
"name",
"of",
"the",
"ciliumEndpoint",
"and",
"deletes",
"it",
".",
"Returns",
"an",
"error",
"if",
"one",
"occurs",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/client/clientset/versioned/typed/cilium.io/v2/fake/fake_ciliumendpoint.go#L114-L119 |
163,716 | cilium/cilium | pkg/fqdn/helpers.go | getRuleUUIDLabel | func getRuleUUIDLabel(rule *api.Rule) (uuid string) {
return rule.Labels.Get(uuidLabelSearchKey)
} | go | func getRuleUUIDLabel(rule *api.Rule) (uuid string) {
return rule.Labels.Get(uuidLabelSearchKey)
} | [
"func",
"getRuleUUIDLabel",
"(",
"rule",
"*",
"api",
".",
"Rule",
")",
"(",
"uuid",
"string",
")",
"{",
"return",
"rule",
".",
"Labels",
".",
"Get",
"(",
"uuidLabelSearchKey",
")",
"\n",
"}"
] | // getUUIDFromRuleLabels returns the value of the UUID label | [
"getUUIDFromRuleLabels",
"returns",
"the",
"value",
"of",
"the",
"UUID",
"label"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/helpers.go#L33-L35 |
163,717 | cilium/cilium | pkg/fqdn/helpers.go | generateUUIDLabel | func generateUUIDLabel() labels.Label {
return labels.NewLabel(generatedLabelNameUUID, uuid.NewUUID().String(), labels.LabelSourceCiliumGenerated)
} | go | func generateUUIDLabel() labels.Label {
return labels.NewLabel(generatedLabelNameUUID, uuid.NewUUID().String(), labels.LabelSourceCiliumGenerated)
} | [
"func",
"generateUUIDLabel",
"(",
")",
"labels",
".",
"Label",
"{",
"return",
"labels",
".",
"NewLabel",
"(",
"generatedLabelNameUUID",
",",
"uuid",
".",
"NewUUID",
"(",
")",
".",
"String",
"(",
")",
",",
"labels",
".",
"LabelSourceCiliumGenerated",
")",
"\n",
"}"
] | // generateUUIDLabel builds a random UUID label that can be used to uniquely identify
// rules augmented with a "toCIDRSet" based on "toFQDNs". | [
"generateUUIDLabel",
"builds",
"a",
"random",
"UUID",
"label",
"that",
"can",
"be",
"used",
"to",
"uniquely",
"identify",
"rules",
"augmented",
"with",
"a",
"toCIDRSet",
"based",
"on",
"toFQDNs",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/helpers.go#L39-L41 |
163,718 | cilium/cilium | pkg/fqdn/helpers.go | stripToCIDRSet | func stripToCIDRSet(rule *api.Rule) {
for i := range rule.Egress {
egressRule := &rule.Egress[i]
if len(egressRule.ToFQDNs) > 0 {
egressRule.ToCIDRSet = nil
}
}
} | go | func stripToCIDRSet(rule *api.Rule) {
for i := range rule.Egress {
egressRule := &rule.Egress[i]
if len(egressRule.ToFQDNs) > 0 {
egressRule.ToCIDRSet = nil
}
}
} | [
"func",
"stripToCIDRSet",
"(",
"rule",
"*",
"api",
".",
"Rule",
")",
"{",
"for",
"i",
":=",
"range",
"rule",
".",
"Egress",
"{",
"egressRule",
":=",
"&",
"rule",
".",
"Egress",
"[",
"i",
"]",
"\n",
"if",
"len",
"(",
"egressRule",
".",
"ToFQDNs",
")",
">",
"0",
"{",
"egressRule",
".",
"ToCIDRSet",
"=",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // stripToCIDRSet ensures no ToCIDRSet is nil when ToFQDNs is non-nil | [
"stripToCIDRSet",
"ensures",
"no",
"ToCIDRSet",
"is",
"nil",
"when",
"ToFQDNs",
"is",
"non",
"-",
"nil"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/helpers.go#L125-L132 |
163,719 | cilium/cilium | pkg/fqdn/helpers.go | hasToFQDN | func hasToFQDN(rule *api.Rule) bool {
for _, egressRule := range rule.Egress {
if len(egressRule.ToFQDNs) > 0 {
return true
}
}
return false
} | go | func hasToFQDN(rule *api.Rule) bool {
for _, egressRule := range rule.Egress {
if len(egressRule.ToFQDNs) > 0 {
return true
}
}
return false
} | [
"func",
"hasToFQDN",
"(",
"rule",
"*",
"api",
".",
"Rule",
")",
"bool",
"{",
"for",
"_",
",",
"egressRule",
":=",
"range",
"rule",
".",
"Egress",
"{",
"if",
"len",
"(",
"egressRule",
".",
"ToFQDNs",
")",
">",
"0",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] | // hasToFQDN indicates whether a ToFQDN rule exists in the api.Rule | [
"hasToFQDN",
"indicates",
"whether",
"a",
"ToFQDN",
"rule",
"exists",
"in",
"the",
"api",
".",
"Rule"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/helpers.go#L135-L143 |
163,720 | cilium/cilium | pkg/fqdn/helpers.go | sortedIPsAreEqual | func sortedIPsAreEqual(a, b []net.IP) bool {
// the IP set is definitely different if the lengths are different
if len(a) != len(b) {
return false
}
// lengths are equal, so each member in one set must be in the other
// Note: we sorted fullNewIPs above, and sorted oldIPs when they were
// inserted in this function, previously.
// If any IPs at the same index differ, updated = true.
for i := range a {
if !a[i].Equal(b[i]) {
return false
}
}
return true
} | go | func sortedIPsAreEqual(a, b []net.IP) bool {
// the IP set is definitely different if the lengths are different
if len(a) != len(b) {
return false
}
// lengths are equal, so each member in one set must be in the other
// Note: we sorted fullNewIPs above, and sorted oldIPs when they were
// inserted in this function, previously.
// If any IPs at the same index differ, updated = true.
for i := range a {
if !a[i].Equal(b[i]) {
return false
}
}
return true
} | [
"func",
"sortedIPsAreEqual",
"(",
"a",
",",
"b",
"[",
"]",
"net",
".",
"IP",
")",
"bool",
"{",
"// the IP set is definitely different if the lengths are different",
"if",
"len",
"(",
"a",
")",
"!=",
"len",
"(",
"b",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"// lengths are equal, so each member in one set must be in the other",
"// Note: we sorted fullNewIPs above, and sorted oldIPs when they were",
"// inserted in this function, previously.",
"// If any IPs at the same index differ, updated = true.",
"for",
"i",
":=",
"range",
"a",
"{",
"if",
"!",
"a",
"[",
"i",
"]",
".",
"Equal",
"(",
"b",
"[",
"i",
"]",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] | // sortedIPsAreEqual compares two lists of sorted IPs. If any differ it returns
// false. | [
"sortedIPsAreEqual",
"compares",
"two",
"lists",
"of",
"sorted",
"IPs",
".",
"If",
"any",
"differ",
"it",
"returns",
"false",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/helpers.go#L147-L163 |
163,721 | cilium/cilium | pkg/fqdn/helpers.go | KeepUniqueNames | func KeepUniqueNames(names []string) []string {
result := []string{}
entries := map[string]bool{}
for _, item := range names {
if _, ok := entries[item]; ok {
continue
}
entries[item] = true
result = append(result, item)
}
return result
} | go | func KeepUniqueNames(names []string) []string {
result := []string{}
entries := map[string]bool{}
for _, item := range names {
if _, ok := entries[item]; ok {
continue
}
entries[item] = true
result = append(result, item)
}
return result
} | [
"func",
"KeepUniqueNames",
"(",
"names",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"result",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"entries",
":=",
"map",
"[",
"string",
"]",
"bool",
"{",
"}",
"\n\n",
"for",
"_",
",",
"item",
":=",
"range",
"names",
"{",
"if",
"_",
",",
"ok",
":=",
"entries",
"[",
"item",
"]",
";",
"ok",
"{",
"continue",
"\n",
"}",
"\n",
"entries",
"[",
"item",
"]",
"=",
"true",
"\n",
"result",
"=",
"append",
"(",
"result",
",",
"item",
")",
"\n",
"}",
"\n",
"return",
"result",
"\n",
"}"
] | // KeepUniqueNames it gets a array of strings and return a new array of strings
// with the unique names. | [
"KeepUniqueNames",
"it",
"gets",
"a",
"array",
"of",
"strings",
"and",
"return",
"a",
"new",
"array",
"of",
"strings",
"with",
"the",
"unique",
"names",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/helpers.go#L172-L184 |
163,722 | cilium/cilium | pkg/policy/api/rule_validation.go | Sanitize | func (r Rule) Sanitize() error {
// reject cilium-generated labels on insert.
// This isn't a proper function because r.Labels is a labels.LabelArray and
// not a labels.Labels, where we could add a function similar to GetReserved
for _, lbl := range r.Labels {
if lbl.Source == labels.LabelSourceCiliumGenerated {
return fmt.Errorf("rule labels cannot have cilium-generated source")
}
}
if r.EndpointSelector.LabelSelector == nil {
return fmt.Errorf("rule cannot have nil EndpointSelector")
}
if err := r.EndpointSelector.sanitize(); err != nil {
return err
}
for i := range r.Ingress {
if err := r.Ingress[i].sanitize(); err != nil {
return err
}
}
for i := range r.Egress {
if err := r.Egress[i].sanitize(); err != nil {
return err
}
}
return nil
} | go | func (r Rule) Sanitize() error {
// reject cilium-generated labels on insert.
// This isn't a proper function because r.Labels is a labels.LabelArray and
// not a labels.Labels, where we could add a function similar to GetReserved
for _, lbl := range r.Labels {
if lbl.Source == labels.LabelSourceCiliumGenerated {
return fmt.Errorf("rule labels cannot have cilium-generated source")
}
}
if r.EndpointSelector.LabelSelector == nil {
return fmt.Errorf("rule cannot have nil EndpointSelector")
}
if err := r.EndpointSelector.sanitize(); err != nil {
return err
}
for i := range r.Ingress {
if err := r.Ingress[i].sanitize(); err != nil {
return err
}
}
for i := range r.Egress {
if err := r.Egress[i].sanitize(); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"r",
"Rule",
")",
"Sanitize",
"(",
")",
"error",
"{",
"// reject cilium-generated labels on insert.",
"// This isn't a proper function because r.Labels is a labels.LabelArray and",
"// not a labels.Labels, where we could add a function similar to GetReserved",
"for",
"_",
",",
"lbl",
":=",
"range",
"r",
".",
"Labels",
"{",
"if",
"lbl",
".",
"Source",
"==",
"labels",
".",
"LabelSourceCiliumGenerated",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"r",
".",
"EndpointSelector",
".",
"LabelSelector",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"r",
".",
"EndpointSelector",
".",
"sanitize",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"range",
"r",
".",
"Ingress",
"{",
"if",
"err",
":=",
"r",
".",
"Ingress",
"[",
"i",
"]",
".",
"sanitize",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"range",
"r",
".",
"Egress",
"{",
"if",
"err",
":=",
"r",
".",
"Egress",
"[",
"i",
"]",
".",
"sanitize",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Sanitize validates and sanitizes a policy rule. Minor edits such as
// capitalization of the protocol name are automatically fixed up. More
// fundamental violations will cause an error to be returned. | [
"Sanitize",
"validates",
"and",
"sanitizes",
"a",
"policy",
"rule",
".",
"Minor",
"edits",
"such",
"as",
"capitalization",
"of",
"the",
"protocol",
"name",
"are",
"automatically",
"fixed",
"up",
".",
"More",
"fundamental",
"violations",
"will",
"cause",
"an",
"error",
"to",
"be",
"returned",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/rule_validation.go#L37-L69 |
163,723 | cilium/cilium | pkg/policy/api/rule_validation.go | sanitize | func (c *CIDRRule) sanitize() (prefixLength int, err error) {
// Only allow notation <IP address>/<prefix>. Note that this differs from
// the logic in api.CIDR.Sanitize().
_, cidrNet, err := net.ParseCIDR(string(c.Cidr))
if err != nil {
return 0, fmt.Errorf("Unable to parse CIDRRule %q: %s", c.Cidr, err)
}
var bits int
prefixLength, bits = cidrNet.Mask.Size()
if prefixLength == 0 && bits == 0 {
return 0, fmt.Errorf("CIDR cannot specify non-contiguous mask %s",
cidrNet.Mask.String())
}
// Ensure that each provided exception CIDR prefix is formatted correctly,
// and is contained within the CIDR prefix to/from which we want to allow
// traffic.
for _, p := range c.ExceptCIDRs {
exceptCIDRAddr, _, err := net.ParseCIDR(string(p))
if err != nil {
return 0, err
}
// Note: this also checks that the allow CIDR prefix and the exception
// CIDR prefixes are part of the same address family.
if !cidrNet.Contains(exceptCIDRAddr) {
return 0, fmt.Errorf("allow CIDR prefix %s does not contain "+
"exclude CIDR prefix %s", c.Cidr, p)
}
}
return prefixLength, nil
} | go | func (c *CIDRRule) sanitize() (prefixLength int, err error) {
// Only allow notation <IP address>/<prefix>. Note that this differs from
// the logic in api.CIDR.Sanitize().
_, cidrNet, err := net.ParseCIDR(string(c.Cidr))
if err != nil {
return 0, fmt.Errorf("Unable to parse CIDRRule %q: %s", c.Cidr, err)
}
var bits int
prefixLength, bits = cidrNet.Mask.Size()
if prefixLength == 0 && bits == 0 {
return 0, fmt.Errorf("CIDR cannot specify non-contiguous mask %s",
cidrNet.Mask.String())
}
// Ensure that each provided exception CIDR prefix is formatted correctly,
// and is contained within the CIDR prefix to/from which we want to allow
// traffic.
for _, p := range c.ExceptCIDRs {
exceptCIDRAddr, _, err := net.ParseCIDR(string(p))
if err != nil {
return 0, err
}
// Note: this also checks that the allow CIDR prefix and the exception
// CIDR prefixes are part of the same address family.
if !cidrNet.Contains(exceptCIDRAddr) {
return 0, fmt.Errorf("allow CIDR prefix %s does not contain "+
"exclude CIDR prefix %s", c.Cidr, p)
}
}
return prefixLength, nil
} | [
"func",
"(",
"c",
"*",
"CIDRRule",
")",
"sanitize",
"(",
")",
"(",
"prefixLength",
"int",
",",
"err",
"error",
")",
"{",
"// Only allow notation <IP address>/<prefix>. Note that this differs from",
"// the logic in api.CIDR.Sanitize().",
"_",
",",
"cidrNet",
",",
"err",
":=",
"net",
".",
"ParseCIDR",
"(",
"string",
"(",
"c",
".",
"Cidr",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"c",
".",
"Cidr",
",",
"err",
")",
"\n",
"}",
"\n\n",
"var",
"bits",
"int",
"\n",
"prefixLength",
",",
"bits",
"=",
"cidrNet",
".",
"Mask",
".",
"Size",
"(",
")",
"\n",
"if",
"prefixLength",
"==",
"0",
"&&",
"bits",
"==",
"0",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"cidrNet",
".",
"Mask",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n\n",
"// Ensure that each provided exception CIDR prefix is formatted correctly,",
"// and is contained within the CIDR prefix to/from which we want to allow",
"// traffic.",
"for",
"_",
",",
"p",
":=",
"range",
"c",
".",
"ExceptCIDRs",
"{",
"exceptCIDRAddr",
",",
"_",
",",
"err",
":=",
"net",
".",
"ParseCIDR",
"(",
"string",
"(",
"p",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"}",
"\n\n",
"// Note: this also checks that the allow CIDR prefix and the exception",
"// CIDR prefixes are part of the same address family.",
"if",
"!",
"cidrNet",
".",
"Contains",
"(",
"exceptCIDRAddr",
")",
"{",
"return",
"0",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"c",
".",
"Cidr",
",",
"p",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"prefixLength",
",",
"nil",
"\n",
"}"
] | // sanitize validates a CIDRRule by checking that the CIDR prefix itself is
// valid, and ensuring that all of the exception CIDR prefixes are contained
// within the allowed CIDR prefix. | [
"sanitize",
"validates",
"a",
"CIDRRule",
"by",
"checking",
"that",
"the",
"CIDR",
"prefix",
"itself",
"is",
"valid",
"and",
"ensuring",
"that",
"all",
"of",
"the",
"exception",
"CIDR",
"prefixes",
"are",
"contained",
"within",
"the",
"allowed",
"CIDR",
"prefix",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/rule_validation.go#L428-L462 |
163,724 | cilium/cilium | api/v1/health/models/node_status.go | Validate | func (m *NodeStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateEndpoint(formats); err != nil {
res = append(res, err)
}
if err := m.validateHost(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *NodeStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateEndpoint(formats); err != nil {
res = append(res, err)
}
if err := m.validateHost(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"NodeStatus",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateEndpoint",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateHost",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this node status | [
"Validate",
"validates",
"this",
"node",
"status"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/models/node_status.go#L30-L45 |
163,725 | cilium/cilium | api/v1/models/endpoint_configuration_status.go | Validate | func (m *EndpointConfigurationStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateError(formats); err != nil {
res = append(res, err)
}
if err := m.validateImmutable(formats); err != nil {
res = append(res, err)
}
if err := m.validateRealized(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *EndpointConfigurationStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateError(formats); err != nil {
res = append(res, err)
}
if err := m.validateImmutable(formats); err != nil {
res = append(res, err)
}
if err := m.validateRealized(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"EndpointConfigurationStatus",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateError",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateImmutable",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateRealized",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this endpoint configuration status | [
"Validate",
"validates",
"this",
"endpoint",
"configuration",
"status"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/endpoint_configuration_status.go#L30-L49 |
163,726 | cilium/cilium | api/v1/server/restapi/ipam/delete_ip_a_m_ip_responses.go | WithPayload | func (o *DeleteIPAMIPFailure) WithPayload(payload models.Error) *DeleteIPAMIPFailure {
o.Payload = payload
return o
} | go | func (o *DeleteIPAMIPFailure) WithPayload(payload models.Error) *DeleteIPAMIPFailure {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"DeleteIPAMIPFailure",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"DeleteIPAMIPFailure",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the delete Ip a m Ip failure response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"delete",
"Ip",
"a",
"m",
"Ip",
"failure",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/ipam/delete_ip_a_m_ip_responses.go#L110-L113 |
163,727 | cilium/cilium | pkg/monitor/api/types.go | DumpInfo | func (n *AgentNotify) DumpInfo() {
fmt.Printf(">> %s: %s\n", resolveAgentType(n.Type), n.Text)
} | go | func (n *AgentNotify) DumpInfo() {
fmt.Printf(">> %s: %s\n", resolveAgentType(n.Type), n.Text)
} | [
"func",
"(",
"n",
"*",
"AgentNotify",
")",
"DumpInfo",
"(",
")",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"resolveAgentType",
"(",
"n",
".",
"Type",
")",
",",
"n",
".",
"Text",
")",
"\n",
"}"
] | // DumpInfo dumps an agent notification | [
"DumpInfo",
"dumps",
"an",
"agent",
"notification"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/api/types.go#L141-L143 |
163,728 | cilium/cilium | pkg/monitor/api/types.go | PolicyUpdateRepr | func PolicyUpdateRepr(numRules int, labels []string, revision uint64) (string, error) {
notification := PolicyUpdateNotification{
Labels: labels,
Revision: revision,
RuleCount: numRules,
}
repr, err := json.Marshal(notification)
return string(repr), err
} | go | func PolicyUpdateRepr(numRules int, labels []string, revision uint64) (string, error) {
notification := PolicyUpdateNotification{
Labels: labels,
Revision: revision,
RuleCount: numRules,
}
repr, err := json.Marshal(notification)
return string(repr), err
} | [
"func",
"PolicyUpdateRepr",
"(",
"numRules",
"int",
",",
"labels",
"[",
"]",
"string",
",",
"revision",
"uint64",
")",
"(",
"string",
",",
"error",
")",
"{",
"notification",
":=",
"PolicyUpdateNotification",
"{",
"Labels",
":",
"labels",
",",
"Revision",
":",
"revision",
",",
"RuleCount",
":",
"numRules",
",",
"}",
"\n\n",
"repr",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"notification",
")",
"\n\n",
"return",
"string",
"(",
"repr",
")",
",",
"err",
"\n",
"}"
] | // PolicyUpdateRepr returns string representation of monitor notification | [
"PolicyUpdateRepr",
"returns",
"string",
"representation",
"of",
"monitor",
"notification"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/api/types.go#L162-L172 |
163,729 | cilium/cilium | pkg/monitor/api/types.go | PolicyDeleteRepr | func PolicyDeleteRepr(deleted int, labels []string, revision uint64) (string, error) {
notification := PolicyUpdateNotification{
Labels: labels,
Revision: revision,
RuleCount: deleted,
}
repr, err := json.Marshal(notification)
return string(repr), err
} | go | func PolicyDeleteRepr(deleted int, labels []string, revision uint64) (string, error) {
notification := PolicyUpdateNotification{
Labels: labels,
Revision: revision,
RuleCount: deleted,
}
repr, err := json.Marshal(notification)
return string(repr), err
} | [
"func",
"PolicyDeleteRepr",
"(",
"deleted",
"int",
",",
"labels",
"[",
"]",
"string",
",",
"revision",
"uint64",
")",
"(",
"string",
",",
"error",
")",
"{",
"notification",
":=",
"PolicyUpdateNotification",
"{",
"Labels",
":",
"labels",
",",
"Revision",
":",
"revision",
",",
"RuleCount",
":",
"deleted",
",",
"}",
"\n",
"repr",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"notification",
")",
"\n\n",
"return",
"string",
"(",
"repr",
")",
",",
"err",
"\n",
"}"
] | // PolicyDeleteRepr returns string representation of monitor notification | [
"PolicyDeleteRepr",
"returns",
"string",
"representation",
"of",
"monitor",
"notification"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/api/types.go#L175-L184 |
163,730 | cilium/cilium | pkg/monitor/api/types.go | EndpointRegenRepr | func EndpointRegenRepr(e notifications.RegenNotificationInfo, err error) (string, error) {
notification := EndpointRegenNotification{
ID: e.GetID(),
Labels: e.GetOpLabels(),
}
if err != nil {
notification.Error = err.Error()
}
repr, err := json.Marshal(notification)
return string(repr), err
} | go | func EndpointRegenRepr(e notifications.RegenNotificationInfo, err error) (string, error) {
notification := EndpointRegenNotification{
ID: e.GetID(),
Labels: e.GetOpLabels(),
}
if err != nil {
notification.Error = err.Error()
}
repr, err := json.Marshal(notification)
return string(repr), err
} | [
"func",
"EndpointRegenRepr",
"(",
"e",
"notifications",
".",
"RegenNotificationInfo",
",",
"err",
"error",
")",
"(",
"string",
",",
"error",
")",
"{",
"notification",
":=",
"EndpointRegenNotification",
"{",
"ID",
":",
"e",
".",
"GetID",
"(",
")",
",",
"Labels",
":",
"e",
".",
"GetOpLabels",
"(",
")",
",",
"}",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"notification",
".",
"Error",
"=",
"err",
".",
"Error",
"(",
")",
"\n",
"}",
"\n\n",
"repr",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"notification",
")",
"\n\n",
"return",
"string",
"(",
"repr",
")",
",",
"err",
"\n",
"}"
] | // EndpointRegenRepr returns string representation of monitor notification | [
"EndpointRegenRepr",
"returns",
"string",
"representation",
"of",
"monitor",
"notification"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/api/types.go#L194-L207 |
163,731 | cilium/cilium | pkg/monitor/api/types.go | TimeRepr | func TimeRepr(t time.Time) (string, error) {
notification := TimeNotification{
Time: t.String(),
}
repr, err := json.Marshal(notification)
return string(repr), err
} | go | func TimeRepr(t time.Time) (string, error) {
notification := TimeNotification{
Time: t.String(),
}
repr, err := json.Marshal(notification)
return string(repr), err
} | [
"func",
"TimeRepr",
"(",
"t",
"time",
".",
"Time",
")",
"(",
"string",
",",
"error",
")",
"{",
"notification",
":=",
"TimeNotification",
"{",
"Time",
":",
"t",
".",
"String",
"(",
")",
",",
"}",
"\n",
"repr",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"notification",
")",
"\n",
"return",
"string",
"(",
"repr",
")",
",",
"err",
"\n",
"}"
] | // TimeRepr returns string representation of monitor notification | [
"TimeRepr",
"returns",
"string",
"representation",
"of",
"monitor",
"notification"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/api/types.go#L215-L221 |
163,732 | cilium/cilium | pkg/envoy/xds/stream.go | NewMockStream | func NewMockStream(ctx context.Context, recvSize, sentSize int, recvTimeout, sentTimeout time.Duration) *MockStream {
return &MockStream{
ctx: ctx,
recv: make(chan *envoy_api_v2.DiscoveryRequest, recvSize),
sent: make(chan *envoy_api_v2.DiscoveryResponse, sentSize),
recvTimeout: recvTimeout,
sentTimeout: sentTimeout,
}
} | go | func NewMockStream(ctx context.Context, recvSize, sentSize int, recvTimeout, sentTimeout time.Duration) *MockStream {
return &MockStream{
ctx: ctx,
recv: make(chan *envoy_api_v2.DiscoveryRequest, recvSize),
sent: make(chan *envoy_api_v2.DiscoveryResponse, sentSize),
recvTimeout: recvTimeout,
sentTimeout: sentTimeout,
}
} | [
"func",
"NewMockStream",
"(",
"ctx",
"context",
".",
"Context",
",",
"recvSize",
",",
"sentSize",
"int",
",",
"recvTimeout",
",",
"sentTimeout",
"time",
".",
"Duration",
")",
"*",
"MockStream",
"{",
"return",
"&",
"MockStream",
"{",
"ctx",
":",
"ctx",
",",
"recv",
":",
"make",
"(",
"chan",
"*",
"envoy_api_v2",
".",
"DiscoveryRequest",
",",
"recvSize",
")",
",",
"sent",
":",
"make",
"(",
"chan",
"*",
"envoy_api_v2",
".",
"DiscoveryResponse",
",",
"sentSize",
")",
",",
"recvTimeout",
":",
"recvTimeout",
",",
"sentTimeout",
":",
"sentTimeout",
",",
"}",
"\n",
"}"
] | // NewMockStream creates a new mock Stream for testing. | [
"NewMockStream",
"creates",
"a",
"new",
"mock",
"Stream",
"for",
"testing",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/xds/stream.go#L45-L53 |
163,733 | cilium/cilium | pkg/endpoint/policy.go | LookupRedirectPort | func (e *Endpoint) LookupRedirectPort(l4Filter *policy.L4Filter) uint16 {
if !l4Filter.IsRedirect() {
return 0
}
proxyID := e.ProxyID(l4Filter)
return e.realizedRedirects[proxyID]
} | go | func (e *Endpoint) LookupRedirectPort(l4Filter *policy.L4Filter) uint16 {
if !l4Filter.IsRedirect() {
return 0
}
proxyID := e.ProxyID(l4Filter)
return e.realizedRedirects[proxyID]
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"LookupRedirectPort",
"(",
"l4Filter",
"*",
"policy",
".",
"L4Filter",
")",
"uint16",
"{",
"if",
"!",
"l4Filter",
".",
"IsRedirect",
"(",
")",
"{",
"return",
"0",
"\n",
"}",
"\n",
"proxyID",
":=",
"e",
".",
"ProxyID",
"(",
"l4Filter",
")",
"\n",
"return",
"e",
".",
"realizedRedirects",
"[",
"proxyID",
"]",
"\n",
"}"
] | // lookupRedirectPort returns the redirect L4 proxy port for the given L4
// policy map key, in host byte order. Returns 0 if not found or the
// filter doesn't require a redirect.
// Must be called with Endpoint.Mutex held. | [
"lookupRedirectPort",
"returns",
"the",
"redirect",
"L4",
"proxy",
"port",
"for",
"the",
"given",
"L4",
"policy",
"map",
"key",
"in",
"host",
"byte",
"order",
".",
"Returns",
"0",
"if",
"not",
"found",
"or",
"the",
"filter",
"doesn",
"t",
"require",
"a",
"redirect",
".",
"Must",
"be",
"called",
"with",
"Endpoint",
".",
"Mutex",
"held",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/policy.go#L58-L64 |
163,734 | cilium/cilium | pkg/endpoint/policy.go | updateNetworkPolicy | func (e *Endpoint) updateNetworkPolicy(owner Owner, proxyWaitGroup *completion.WaitGroup) (reterr error, revertFunc revert.RevertFunc) {
// Skip updating the NetworkPolicy if no identity has been computed for this
// endpoint.
// This breaks a circular dependency between configuring NetworkPolicies in
// sidecar Envoy proxies and those proxies needing network connectivity
// to get their initial configuration, which is required for them to ACK
// the NetworkPolicies.
if e.SecurityIdentity == nil {
return nil, nil
}
// Publish the updated policy to L7 proxies.
var desiredL4Policy *policy.L4Policy
if e.desiredPolicy != nil {
desiredL4Policy = e.desiredPolicy.L4Policy
}
return owner.UpdateNetworkPolicy(e, desiredL4Policy, *e.prevIdentityCache, e.desiredPolicy.DeniedIngressIdentities, e.desiredPolicy.DeniedEgressIdentities, proxyWaitGroup)
} | go | func (e *Endpoint) updateNetworkPolicy(owner Owner, proxyWaitGroup *completion.WaitGroup) (reterr error, revertFunc revert.RevertFunc) {
// Skip updating the NetworkPolicy if no identity has been computed for this
// endpoint.
// This breaks a circular dependency between configuring NetworkPolicies in
// sidecar Envoy proxies and those proxies needing network connectivity
// to get their initial configuration, which is required for them to ACK
// the NetworkPolicies.
if e.SecurityIdentity == nil {
return nil, nil
}
// Publish the updated policy to L7 proxies.
var desiredL4Policy *policy.L4Policy
if e.desiredPolicy != nil {
desiredL4Policy = e.desiredPolicy.L4Policy
}
return owner.UpdateNetworkPolicy(e, desiredL4Policy, *e.prevIdentityCache, e.desiredPolicy.DeniedIngressIdentities, e.desiredPolicy.DeniedEgressIdentities, proxyWaitGroup)
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"updateNetworkPolicy",
"(",
"owner",
"Owner",
",",
"proxyWaitGroup",
"*",
"completion",
".",
"WaitGroup",
")",
"(",
"reterr",
"error",
",",
"revertFunc",
"revert",
".",
"RevertFunc",
")",
"{",
"// Skip updating the NetworkPolicy if no identity has been computed for this",
"// endpoint.",
"// This breaks a circular dependency between configuring NetworkPolicies in",
"// sidecar Envoy proxies and those proxies needing network connectivity",
"// to get their initial configuration, which is required for them to ACK",
"// the NetworkPolicies.",
"if",
"e",
".",
"SecurityIdentity",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n\n",
"// Publish the updated policy to L7 proxies.",
"var",
"desiredL4Policy",
"*",
"policy",
".",
"L4Policy",
"\n",
"if",
"e",
".",
"desiredPolicy",
"!=",
"nil",
"{",
"desiredL4Policy",
"=",
"e",
".",
"desiredPolicy",
".",
"L4Policy",
"\n",
"}",
"\n",
"return",
"owner",
".",
"UpdateNetworkPolicy",
"(",
"e",
",",
"desiredL4Policy",
",",
"*",
"e",
".",
"prevIdentityCache",
",",
"e",
".",
"desiredPolicy",
".",
"DeniedIngressIdentities",
",",
"e",
".",
"desiredPolicy",
".",
"DeniedEgressIdentities",
",",
"proxyWaitGroup",
")",
"\n",
"}"
] | // Note that this function assumes that endpoint policy has already been generated!
// must be called with endpoint.Mutex held for reading | [
"Note",
"that",
"this",
"function",
"assumes",
"that",
"endpoint",
"policy",
"has",
"already",
"been",
"generated!",
"must",
"be",
"called",
"with",
"endpoint",
".",
"Mutex",
"held",
"for",
"reading"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/policy.go#L68-L85 |
163,735 | cilium/cilium | pkg/endpoint/policy.go | setNextPolicyRevision | func (e *Endpoint) setNextPolicyRevision(revision uint64) {
e.nextPolicyRevision = revision
e.UpdateLogger(map[string]interface{}{
logfields.DesiredPolicyRevision: e.nextPolicyRevision,
})
} | go | func (e *Endpoint) setNextPolicyRevision(revision uint64) {
e.nextPolicyRevision = revision
e.UpdateLogger(map[string]interface{}{
logfields.DesiredPolicyRevision: e.nextPolicyRevision,
})
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"setNextPolicyRevision",
"(",
"revision",
"uint64",
")",
"{",
"e",
".",
"nextPolicyRevision",
"=",
"revision",
"\n",
"e",
".",
"UpdateLogger",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"logfields",
".",
"DesiredPolicyRevision",
":",
"e",
".",
"nextPolicyRevision",
",",
"}",
")",
"\n",
"}"
] | // setNextPolicyRevision updates the desired policy revision field
// Must be called with the endpoint lock held for at least reading | [
"setNextPolicyRevision",
"updates",
"the",
"desired",
"policy",
"revision",
"field",
"Must",
"be",
"called",
"with",
"the",
"endpoint",
"lock",
"held",
"for",
"at",
"least",
"reading"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/policy.go#L89-L94 |
163,736 | cilium/cilium | pkg/endpoint/policy.go | updateAndOverrideEndpointOptions | func (e *Endpoint) updateAndOverrideEndpointOptions(opts option.OptionMap) (optsChanged bool) {
if opts == nil {
opts = make(option.OptionMap)
}
// Apply possible option changes before regenerating maps, as map regeneration
// depends on the conntrack options
if e.desiredPolicy != nil && e.desiredPolicy.L4Policy != nil {
if e.desiredPolicy.L4Policy.RequiresConntrack() {
opts[option.Conntrack] = option.OptionEnabled
}
}
optsChanged = e.applyOptsLocked(opts)
return
} | go | func (e *Endpoint) updateAndOverrideEndpointOptions(opts option.OptionMap) (optsChanged bool) {
if opts == nil {
opts = make(option.OptionMap)
}
// Apply possible option changes before regenerating maps, as map regeneration
// depends on the conntrack options
if e.desiredPolicy != nil && e.desiredPolicy.L4Policy != nil {
if e.desiredPolicy.L4Policy.RequiresConntrack() {
opts[option.Conntrack] = option.OptionEnabled
}
}
optsChanged = e.applyOptsLocked(opts)
return
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"updateAndOverrideEndpointOptions",
"(",
"opts",
"option",
".",
"OptionMap",
")",
"(",
"optsChanged",
"bool",
")",
"{",
"if",
"opts",
"==",
"nil",
"{",
"opts",
"=",
"make",
"(",
"option",
".",
"OptionMap",
")",
"\n",
"}",
"\n",
"// Apply possible option changes before regenerating maps, as map regeneration",
"// depends on the conntrack options",
"if",
"e",
".",
"desiredPolicy",
"!=",
"nil",
"&&",
"e",
".",
"desiredPolicy",
".",
"L4Policy",
"!=",
"nil",
"{",
"if",
"e",
".",
"desiredPolicy",
".",
"L4Policy",
".",
"RequiresConntrack",
"(",
")",
"{",
"opts",
"[",
"option",
".",
"Conntrack",
"]",
"=",
"option",
".",
"OptionEnabled",
"\n",
"}",
"\n",
"}",
"\n\n",
"optsChanged",
"=",
"e",
".",
"applyOptsLocked",
"(",
"opts",
")",
"\n",
"return",
"\n",
"}"
] | // updateAndOverrideEndpointOptions updates the boolean configuration options for the endpoint
// based off of policy configuration, daemon policy enforcement mode, and any
// configuration options provided in opts. Returns whether the options changed
// from prior endpoint configuration. Note that the policy which applies
// to the endpoint, as well as the daemon's policy enforcement, may override
// configuration changes which were made via the API that were provided in opts.
// Must be called with endpoint mutex held. | [
"updateAndOverrideEndpointOptions",
"updates",
"the",
"boolean",
"configuration",
"options",
"for",
"the",
"endpoint",
"based",
"off",
"of",
"policy",
"configuration",
"daemon",
"policy",
"enforcement",
"mode",
"and",
"any",
"configuration",
"options",
"provided",
"in",
"opts",
".",
"Returns",
"whether",
"the",
"options",
"changed",
"from",
"prior",
"endpoint",
"configuration",
".",
"Note",
"that",
"the",
"policy",
"which",
"applies",
"to",
"the",
"endpoint",
"as",
"well",
"as",
"the",
"daemon",
"s",
"policy",
"enforcement",
"may",
"override",
"configuration",
"changes",
"which",
"were",
"made",
"via",
"the",
"API",
"that",
"were",
"provided",
"in",
"opts",
".",
"Must",
"be",
"called",
"with",
"endpoint",
"mutex",
"held",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/policy.go#L234-L248 |
163,737 | cilium/cilium | pkg/endpoint/policy.go | updateRealizedState | func (e *Endpoint) updateRealizedState(stats *regenerationStatistics, origDir string, revision uint64, compilationExecuted bool) error {
// Update desired policy for endpoint because policy has now been realized
// in the datapath. PolicyMap state is not updated here, because that is
// performed in endpoint.syncPolicyMap().
stats.waitingForLock.Start()
err := e.LockAlive()
stats.waitingForLock.End(err == nil)
if err != nil {
return err
}
defer e.Unlock()
// Depending upon result of BPF regeneration (compilation executed),
// shift endpoint directories to match said BPF regeneration
// results.
err = e.synchronizeDirectories(origDir, compilationExecuted)
if err != nil {
return fmt.Errorf("error synchronizing endpoint BPF program directories: %s", err)
}
// Keep PolicyMap for this endpoint in sync with desired / realized state.
if !option.Config.DryMode {
e.syncPolicyMapController()
}
e.realizedBPFConfig = e.desiredBPFConfig
// Set realized state to desired state fields.
e.realizedPolicy.Realizes(e.desiredPolicy)
// Mark the endpoint to be running the policy revision it was
// compiled for
e.setPolicyRevision(revision)
return nil
} | go | func (e *Endpoint) updateRealizedState(stats *regenerationStatistics, origDir string, revision uint64, compilationExecuted bool) error {
// Update desired policy for endpoint because policy has now been realized
// in the datapath. PolicyMap state is not updated here, because that is
// performed in endpoint.syncPolicyMap().
stats.waitingForLock.Start()
err := e.LockAlive()
stats.waitingForLock.End(err == nil)
if err != nil {
return err
}
defer e.Unlock()
// Depending upon result of BPF regeneration (compilation executed),
// shift endpoint directories to match said BPF regeneration
// results.
err = e.synchronizeDirectories(origDir, compilationExecuted)
if err != nil {
return fmt.Errorf("error synchronizing endpoint BPF program directories: %s", err)
}
// Keep PolicyMap for this endpoint in sync with desired / realized state.
if !option.Config.DryMode {
e.syncPolicyMapController()
}
e.realizedBPFConfig = e.desiredBPFConfig
// Set realized state to desired state fields.
e.realizedPolicy.Realizes(e.desiredPolicy)
// Mark the endpoint to be running the policy revision it was
// compiled for
e.setPolicyRevision(revision)
return nil
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"updateRealizedState",
"(",
"stats",
"*",
"regenerationStatistics",
",",
"origDir",
"string",
",",
"revision",
"uint64",
",",
"compilationExecuted",
"bool",
")",
"error",
"{",
"// Update desired policy for endpoint because policy has now been realized",
"// in the datapath. PolicyMap state is not updated here, because that is",
"// performed in endpoint.syncPolicyMap().",
"stats",
".",
"waitingForLock",
".",
"Start",
"(",
")",
"\n",
"err",
":=",
"e",
".",
"LockAlive",
"(",
")",
"\n",
"stats",
".",
"waitingForLock",
".",
"End",
"(",
"err",
"==",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"defer",
"e",
".",
"Unlock",
"(",
")",
"\n\n",
"// Depending upon result of BPF regeneration (compilation executed),",
"// shift endpoint directories to match said BPF regeneration",
"// results.",
"err",
"=",
"e",
".",
"synchronizeDirectories",
"(",
"origDir",
",",
"compilationExecuted",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"// Keep PolicyMap for this endpoint in sync with desired / realized state.",
"if",
"!",
"option",
".",
"Config",
".",
"DryMode",
"{",
"e",
".",
"syncPolicyMapController",
"(",
")",
"\n",
"}",
"\n\n",
"e",
".",
"realizedBPFConfig",
"=",
"e",
".",
"desiredBPFConfig",
"\n\n",
"// Set realized state to desired state fields.",
"e",
".",
"realizedPolicy",
".",
"Realizes",
"(",
"e",
".",
"desiredPolicy",
")",
"\n\n",
"// Mark the endpoint to be running the policy revision it was",
"// compiled for",
"e",
".",
"setPolicyRevision",
"(",
"revision",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // updateRealizedState sets any realized state fields within the endpoint to
// be the desired state of the endpoint. This is only called after a successful
// regeneration of the endpoint. | [
"updateRealizedState",
"sets",
"any",
"realized",
"state",
"fields",
"within",
"the",
"endpoint",
"to",
"be",
"the",
"desired",
"state",
"of",
"the",
"endpoint",
".",
"This",
"is",
"only",
"called",
"after",
"a",
"successful",
"regeneration",
"of",
"the",
"endpoint",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/policy.go#L360-L396 |
163,738 | cilium/cilium | pkg/endpoint/policy.go | Regenerate | func (e *Endpoint) Regenerate(owner Owner, regenMetadata *ExternalRegenerationMetadata) <-chan bool {
done := make(chan bool, 1)
var (
ctx context.Context
cFunc context.CancelFunc
)
if regenMetadata.ParentContext != nil {
ctx, cFunc = context.WithCancel(regenMetadata.ParentContext)
} else {
ctx, cFunc = context.WithCancel(context.Background())
}
regenContext := regenMetadata.toRegenerationContext(ctx, cFunc)
epEvent := eventqueue.NewEvent(&EndpointRegenerationEvent{
owner: owner,
regenContext: regenContext,
ep: e,
})
// This may block if the Endpoint's EventQueue is full. This has to be done
// synchronously as some callers depend on the fact that the event is
// synchronously enqueued.
resChan := e.EventQueue.Enqueue(epEvent)
go func() {
// Free up resources with context.
defer cFunc()
var buildSuccess bool
var regenError error
select {
case result, ok := <-resChan:
if ok {
regenResult := result.(*EndpointRegenerationResult)
regenError = regenResult.err
buildSuccess = regenError == nil
} else {
// This may be unnecessary(?) since 'closing' of the results
// channel means that event has been cancelled?
e.getLogger().Debug("regeneration was cancelled")
}
}
done <- buildSuccess
close(done)
}()
return done
} | go | func (e *Endpoint) Regenerate(owner Owner, regenMetadata *ExternalRegenerationMetadata) <-chan bool {
done := make(chan bool, 1)
var (
ctx context.Context
cFunc context.CancelFunc
)
if regenMetadata.ParentContext != nil {
ctx, cFunc = context.WithCancel(regenMetadata.ParentContext)
} else {
ctx, cFunc = context.WithCancel(context.Background())
}
regenContext := regenMetadata.toRegenerationContext(ctx, cFunc)
epEvent := eventqueue.NewEvent(&EndpointRegenerationEvent{
owner: owner,
regenContext: regenContext,
ep: e,
})
// This may block if the Endpoint's EventQueue is full. This has to be done
// synchronously as some callers depend on the fact that the event is
// synchronously enqueued.
resChan := e.EventQueue.Enqueue(epEvent)
go func() {
// Free up resources with context.
defer cFunc()
var buildSuccess bool
var regenError error
select {
case result, ok := <-resChan:
if ok {
regenResult := result.(*EndpointRegenerationResult)
regenError = regenResult.err
buildSuccess = regenError == nil
} else {
// This may be unnecessary(?) since 'closing' of the results
// channel means that event has been cancelled?
e.getLogger().Debug("regeneration was cancelled")
}
}
done <- buildSuccess
close(done)
}()
return done
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"Regenerate",
"(",
"owner",
"Owner",
",",
"regenMetadata",
"*",
"ExternalRegenerationMetadata",
")",
"<-",
"chan",
"bool",
"{",
"done",
":=",
"make",
"(",
"chan",
"bool",
",",
"1",
")",
"\n\n",
"var",
"(",
"ctx",
"context",
".",
"Context",
"\n",
"cFunc",
"context",
".",
"CancelFunc",
"\n",
")",
"\n\n",
"if",
"regenMetadata",
".",
"ParentContext",
"!=",
"nil",
"{",
"ctx",
",",
"cFunc",
"=",
"context",
".",
"WithCancel",
"(",
"regenMetadata",
".",
"ParentContext",
")",
"\n",
"}",
"else",
"{",
"ctx",
",",
"cFunc",
"=",
"context",
".",
"WithCancel",
"(",
"context",
".",
"Background",
"(",
")",
")",
"\n",
"}",
"\n\n",
"regenContext",
":=",
"regenMetadata",
".",
"toRegenerationContext",
"(",
"ctx",
",",
"cFunc",
")",
"\n\n",
"epEvent",
":=",
"eventqueue",
".",
"NewEvent",
"(",
"&",
"EndpointRegenerationEvent",
"{",
"owner",
":",
"owner",
",",
"regenContext",
":",
"regenContext",
",",
"ep",
":",
"e",
",",
"}",
")",
"\n\n",
"// This may block if the Endpoint's EventQueue is full. This has to be done",
"// synchronously as some callers depend on the fact that the event is",
"// synchronously enqueued.",
"resChan",
":=",
"e",
".",
"EventQueue",
".",
"Enqueue",
"(",
"epEvent",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"// Free up resources with context.",
"defer",
"cFunc",
"(",
")",
"\n\n",
"var",
"buildSuccess",
"bool",
"\n",
"var",
"regenError",
"error",
"\n\n",
"select",
"{",
"case",
"result",
",",
"ok",
":=",
"<-",
"resChan",
":",
"if",
"ok",
"{",
"regenResult",
":=",
"result",
".",
"(",
"*",
"EndpointRegenerationResult",
")",
"\n",
"regenError",
"=",
"regenResult",
".",
"err",
"\n",
"buildSuccess",
"=",
"regenError",
"==",
"nil",
"\n",
"}",
"else",
"{",
"// This may be unnecessary(?) since 'closing' of the results",
"// channel means that event has been cancelled?",
"e",
".",
"getLogger",
"(",
")",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"done",
"<-",
"buildSuccess",
"\n",
"close",
"(",
"done",
")",
"\n",
"}",
"(",
")",
"\n\n",
"return",
"done",
"\n",
"}"
] | // Regenerate forces the regeneration of endpoint programs & policy
// Should only be called with e.state == StateWaitingToRegenerate or with
// e.state == StateWaitingForIdentity | [
"Regenerate",
"forces",
"the",
"regeneration",
"of",
"endpoint",
"programs",
"&",
"policy",
"Should",
"only",
"be",
"called",
"with",
"e",
".",
"state",
"==",
"StateWaitingToRegenerate",
"or",
"with",
"e",
".",
"state",
"==",
"StateWaitingForIdentity"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/policy.go#L441-L494 |
163,739 | cilium/cilium | pkg/endpoint/policy.go | runIPIdentitySync | func (e *Endpoint) runIPIdentitySync(endpointIP addressing.CiliumIP) {
if !endpointIP.IsSet() {
return
}
addressFamily := endpointIP.GetFamilyString()
e.controllers.UpdateController(fmt.Sprintf("sync-%s-identity-mapping (%d)", addressFamily, e.ID),
controller.ControllerParams{
DoFunc: func(ctx context.Context) error {
if err := e.RLockAlive(); err != nil {
return controller.NewExitReason("Endpoint disappeared")
}
if e.SecurityIdentity == nil {
e.RUnlock()
return nil
}
IP := endpointIP.IP()
ID := e.SecurityIdentity.ID
hostIP := node.GetExternalIPv4()
key := node.GetIPsecKeyIdentity()
metadata := e.FormatGlobalEndpointID()
// Release lock as we do not want to have long-lasting key-value
// store operations resulting in lock being held for a long time.
e.RUnlock()
if err := ipcache.UpsertIPToKVStore(ctx, IP, hostIP, ID, key, metadata); err != nil {
return fmt.Errorf("unable to add endpoint IP mapping '%s'->'%d': %s", IP.String(), ID, err)
}
return nil
},
StopFunc: func(ctx context.Context) error {
ip := endpointIP.String()
if err := ipcache.DeleteIPFromKVStore(ctx, ip); err != nil {
return fmt.Errorf("unable to delete endpoint IP '%s' from ipcache: %s", ip, err)
}
return nil
},
RunInterval: 5 * time.Minute,
},
)
} | go | func (e *Endpoint) runIPIdentitySync(endpointIP addressing.CiliumIP) {
if !endpointIP.IsSet() {
return
}
addressFamily := endpointIP.GetFamilyString()
e.controllers.UpdateController(fmt.Sprintf("sync-%s-identity-mapping (%d)", addressFamily, e.ID),
controller.ControllerParams{
DoFunc: func(ctx context.Context) error {
if err := e.RLockAlive(); err != nil {
return controller.NewExitReason("Endpoint disappeared")
}
if e.SecurityIdentity == nil {
e.RUnlock()
return nil
}
IP := endpointIP.IP()
ID := e.SecurityIdentity.ID
hostIP := node.GetExternalIPv4()
key := node.GetIPsecKeyIdentity()
metadata := e.FormatGlobalEndpointID()
// Release lock as we do not want to have long-lasting key-value
// store operations resulting in lock being held for a long time.
e.RUnlock()
if err := ipcache.UpsertIPToKVStore(ctx, IP, hostIP, ID, key, metadata); err != nil {
return fmt.Errorf("unable to add endpoint IP mapping '%s'->'%d': %s", IP.String(), ID, err)
}
return nil
},
StopFunc: func(ctx context.Context) error {
ip := endpointIP.String()
if err := ipcache.DeleteIPFromKVStore(ctx, ip); err != nil {
return fmt.Errorf("unable to delete endpoint IP '%s' from ipcache: %s", ip, err)
}
return nil
},
RunInterval: 5 * time.Minute,
},
)
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"runIPIdentitySync",
"(",
"endpointIP",
"addressing",
".",
"CiliumIP",
")",
"{",
"if",
"!",
"endpointIP",
".",
"IsSet",
"(",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"addressFamily",
":=",
"endpointIP",
".",
"GetFamilyString",
"(",
")",
"\n\n",
"e",
".",
"controllers",
".",
"UpdateController",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"addressFamily",
",",
"e",
".",
"ID",
")",
",",
"controller",
".",
"ControllerParams",
"{",
"DoFunc",
":",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"err",
":=",
"e",
".",
"RLockAlive",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"controller",
".",
"NewExitReason",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"e",
".",
"SecurityIdentity",
"==",
"nil",
"{",
"e",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"IP",
":=",
"endpointIP",
".",
"IP",
"(",
")",
"\n",
"ID",
":=",
"e",
".",
"SecurityIdentity",
".",
"ID",
"\n",
"hostIP",
":=",
"node",
".",
"GetExternalIPv4",
"(",
")",
"\n",
"key",
":=",
"node",
".",
"GetIPsecKeyIdentity",
"(",
")",
"\n",
"metadata",
":=",
"e",
".",
"FormatGlobalEndpointID",
"(",
")",
"\n\n",
"// Release lock as we do not want to have long-lasting key-value",
"// store operations resulting in lock being held for a long time.",
"e",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"err",
":=",
"ipcache",
".",
"UpsertIPToKVStore",
"(",
"ctx",
",",
"IP",
",",
"hostIP",
",",
"ID",
",",
"key",
",",
"metadata",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"IP",
".",
"String",
"(",
")",
",",
"ID",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
",",
"StopFunc",
":",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"ip",
":=",
"endpointIP",
".",
"String",
"(",
")",
"\n",
"if",
"err",
":=",
"ipcache",
".",
"DeleteIPFromKVStore",
"(",
"ctx",
",",
"ip",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ip",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
",",
"RunInterval",
":",
"5",
"*",
"time",
".",
"Minute",
",",
"}",
",",
")",
"\n",
"}"
] | // This synchronizes the key-value store with a mapping of the endpoint's IP
// with the numerical ID representing its security identity. | [
"This",
"synchronizes",
"the",
"key",
"-",
"value",
"store",
"with",
"a",
"mapping",
"of",
"the",
"endpoint",
"s",
"IP",
"with",
"the",
"numerical",
"ID",
"representing",
"its",
"security",
"identity",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/policy.go#L523-L568 |
163,740 | cilium/cilium | pkg/endpoint/policy.go | SetIdentity | func (e *Endpoint) SetIdentity(identity *identityPkg.Identity) {
// Set a boolean flag to indicate whether the endpoint has been injected by
// Istio with a Cilium-compatible sidecar proxy.
istioSidecarProxyLabel, found := identity.Labels[k8sConst.PolicyLabelIstioSidecarProxy]
e.hasSidecarProxy = found &&
istioSidecarProxyLabel.Source == labels.LabelSourceK8s &&
strings.ToLower(istioSidecarProxyLabel.Value) == "true"
oldIdentity := "no identity"
if e.SecurityIdentity != nil {
oldIdentity = e.SecurityIdentity.StringID()
}
// Current security identity for endpoint is its old identity - delete its
// reference from global identity manager, add add a reference to the new
// identity for the endpoint.
identitymanager.RemoveOldAddNew(e.SecurityIdentity, identity)
e.SecurityIdentity = identity
// Clear selectorPolicy. It will be determined at next regeneration.
e.selectorPolicy = nil
// Sets endpoint state to ready if was waiting for identity
if e.GetStateLocked() == StateWaitingForIdentity {
e.SetStateLocked(StateReady, "Set identity for this endpoint")
}
// Whenever the identity is updated, propagate change to key-value store
// of IP to identity mapping.
e.runIPIdentitySync(e.IPv4)
e.runIPIdentitySync(e.IPv6)
if oldIdentity != identity.StringID() {
e.getLogger().WithFields(logrus.Fields{
logfields.Identity: identity.StringID(),
logfields.OldIdentity: oldIdentity,
logfields.IdentityLabels: identity.Labels.String(),
}).Info("Identity of endpoint changed")
}
e.UpdateLogger(map[string]interface{}{
logfields.Identity: identity.StringID(),
})
} | go | func (e *Endpoint) SetIdentity(identity *identityPkg.Identity) {
// Set a boolean flag to indicate whether the endpoint has been injected by
// Istio with a Cilium-compatible sidecar proxy.
istioSidecarProxyLabel, found := identity.Labels[k8sConst.PolicyLabelIstioSidecarProxy]
e.hasSidecarProxy = found &&
istioSidecarProxyLabel.Source == labels.LabelSourceK8s &&
strings.ToLower(istioSidecarProxyLabel.Value) == "true"
oldIdentity := "no identity"
if e.SecurityIdentity != nil {
oldIdentity = e.SecurityIdentity.StringID()
}
// Current security identity for endpoint is its old identity - delete its
// reference from global identity manager, add add a reference to the new
// identity for the endpoint.
identitymanager.RemoveOldAddNew(e.SecurityIdentity, identity)
e.SecurityIdentity = identity
// Clear selectorPolicy. It will be determined at next regeneration.
e.selectorPolicy = nil
// Sets endpoint state to ready if was waiting for identity
if e.GetStateLocked() == StateWaitingForIdentity {
e.SetStateLocked(StateReady, "Set identity for this endpoint")
}
// Whenever the identity is updated, propagate change to key-value store
// of IP to identity mapping.
e.runIPIdentitySync(e.IPv4)
e.runIPIdentitySync(e.IPv6)
if oldIdentity != identity.StringID() {
e.getLogger().WithFields(logrus.Fields{
logfields.Identity: identity.StringID(),
logfields.OldIdentity: oldIdentity,
logfields.IdentityLabels: identity.Labels.String(),
}).Info("Identity of endpoint changed")
}
e.UpdateLogger(map[string]interface{}{
logfields.Identity: identity.StringID(),
})
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"SetIdentity",
"(",
"identity",
"*",
"identityPkg",
".",
"Identity",
")",
"{",
"// Set a boolean flag to indicate whether the endpoint has been injected by",
"// Istio with a Cilium-compatible sidecar proxy.",
"istioSidecarProxyLabel",
",",
"found",
":=",
"identity",
".",
"Labels",
"[",
"k8sConst",
".",
"PolicyLabelIstioSidecarProxy",
"]",
"\n",
"e",
".",
"hasSidecarProxy",
"=",
"found",
"&&",
"istioSidecarProxyLabel",
".",
"Source",
"==",
"labels",
".",
"LabelSourceK8s",
"&&",
"strings",
".",
"ToLower",
"(",
"istioSidecarProxyLabel",
".",
"Value",
")",
"==",
"\"",
"\"",
"\n\n",
"oldIdentity",
":=",
"\"",
"\"",
"\n",
"if",
"e",
".",
"SecurityIdentity",
"!=",
"nil",
"{",
"oldIdentity",
"=",
"e",
".",
"SecurityIdentity",
".",
"StringID",
"(",
")",
"\n",
"}",
"\n\n",
"// Current security identity for endpoint is its old identity - delete its",
"// reference from global identity manager, add add a reference to the new",
"// identity for the endpoint.",
"identitymanager",
".",
"RemoveOldAddNew",
"(",
"e",
".",
"SecurityIdentity",
",",
"identity",
")",
"\n",
"e",
".",
"SecurityIdentity",
"=",
"identity",
"\n\n",
"// Clear selectorPolicy. It will be determined at next regeneration.",
"e",
".",
"selectorPolicy",
"=",
"nil",
"\n\n",
"// Sets endpoint state to ready if was waiting for identity",
"if",
"e",
".",
"GetStateLocked",
"(",
")",
"==",
"StateWaitingForIdentity",
"{",
"e",
".",
"SetStateLocked",
"(",
"StateReady",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Whenever the identity is updated, propagate change to key-value store",
"// of IP to identity mapping.",
"e",
".",
"runIPIdentitySync",
"(",
"e",
".",
"IPv4",
")",
"\n",
"e",
".",
"runIPIdentitySync",
"(",
"e",
".",
"IPv6",
")",
"\n\n",
"if",
"oldIdentity",
"!=",
"identity",
".",
"StringID",
"(",
")",
"{",
"e",
".",
"getLogger",
"(",
")",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"logfields",
".",
"Identity",
":",
"identity",
".",
"StringID",
"(",
")",
",",
"logfields",
".",
"OldIdentity",
":",
"oldIdentity",
",",
"logfields",
".",
"IdentityLabels",
":",
"identity",
".",
"Labels",
".",
"String",
"(",
")",
",",
"}",
")",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"e",
".",
"UpdateLogger",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"logfields",
".",
"Identity",
":",
"identity",
".",
"StringID",
"(",
")",
",",
"}",
")",
"\n",
"}"
] | // SetIdentity resets endpoint's policy identity to 'id'.
// Caller triggers policy regeneration if needed.
// Called with e.Mutex Locked | [
"SetIdentity",
"resets",
"endpoint",
"s",
"policy",
"identity",
"to",
"id",
".",
"Caller",
"triggers",
"policy",
"regeneration",
"if",
"needed",
".",
"Called",
"with",
"e",
".",
"Mutex",
"Locked"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/policy.go#L573-L616 |
163,741 | cilium/cilium | pkg/endpoint/policy.go | GetCIDRPrefixLengths | func (e *Endpoint) GetCIDRPrefixLengths() (s6, s4 []int) {
if e.desiredPolicy == nil || e.desiredPolicy.CIDRPolicy == nil {
return policy.GetDefaultPrefixLengths()
}
return e.desiredPolicy.CIDRPolicy.ToBPFData()
} | go | func (e *Endpoint) GetCIDRPrefixLengths() (s6, s4 []int) {
if e.desiredPolicy == nil || e.desiredPolicy.CIDRPolicy == nil {
return policy.GetDefaultPrefixLengths()
}
return e.desiredPolicy.CIDRPolicy.ToBPFData()
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"GetCIDRPrefixLengths",
"(",
")",
"(",
"s6",
",",
"s4",
"[",
"]",
"int",
")",
"{",
"if",
"e",
".",
"desiredPolicy",
"==",
"nil",
"||",
"e",
".",
"desiredPolicy",
".",
"CIDRPolicy",
"==",
"nil",
"{",
"return",
"policy",
".",
"GetDefaultPrefixLengths",
"(",
")",
"\n",
"}",
"\n",
"return",
"e",
".",
"desiredPolicy",
".",
"CIDRPolicy",
".",
"ToBPFData",
"(",
")",
"\n",
"}"
] | // GetCIDRPrefixLengths returns the sorted list of unique prefix lengths used
// for CIDR policy or IPcache lookup from this endpoint. | [
"GetCIDRPrefixLengths",
"returns",
"the",
"sorted",
"list",
"of",
"unique",
"prefix",
"lengths",
"used",
"for",
"CIDR",
"policy",
"or",
"IPcache",
"lookup",
"from",
"this",
"endpoint",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/policy.go#L620-L625 |
163,742 | cilium/cilium | pkg/nodediscovery/nodediscovery.go | NewNodeDiscovery | func NewNodeDiscovery(manager *nodemanager.Manager, mtuConfig mtu.Configuration) *NodeDiscovery {
auxPrefixes := []*cidr.CIDR{}
if option.Config.IPv4ServiceRange != AutoCIDR {
serviceCIDR, err := cidr.ParseCIDR(option.Config.IPv4ServiceRange)
if err != nil {
log.WithError(err).WithField(logfields.V4Prefix, option.Config.IPv4ServiceRange).Fatal("Invalid IPv4 service prefix")
}
auxPrefixes = append(auxPrefixes, serviceCIDR)
}
if option.Config.IPv6ServiceRange != AutoCIDR {
serviceCIDR, err := cidr.ParseCIDR(option.Config.IPv6ServiceRange)
if err != nil {
log.WithError(err).WithField(logfields.V6Prefix, option.Config.IPv6ServiceRange).Fatal("Invalid IPv6 service prefix")
}
auxPrefixes = append(auxPrefixes, serviceCIDR)
}
return &NodeDiscovery{
Manager: manager,
LocalConfig: datapath.LocalNodeConfiguration{
MtuConfig: mtuConfig,
UseSingleClusterRoute: option.Config.UseSingleClusterRoute,
EnableIPv4: option.Config.EnableIPv4,
EnableIPv6: option.Config.EnableIPv6,
EnableEncapsulation: option.Config.Tunnel != option.TunnelDisabled,
EnableAutoDirectRouting: option.Config.EnableAutoDirectRouting,
EnableLocalNodeRoute: enableLocalNodeRoute(),
AuxiliaryPrefixes: auxPrefixes,
EnableIPSec: option.Config.EnableIPSec,
},
LocalNode: node.Node{
Source: node.FromLocalNode,
},
Registered: make(chan struct{}),
}
} | go | func NewNodeDiscovery(manager *nodemanager.Manager, mtuConfig mtu.Configuration) *NodeDiscovery {
auxPrefixes := []*cidr.CIDR{}
if option.Config.IPv4ServiceRange != AutoCIDR {
serviceCIDR, err := cidr.ParseCIDR(option.Config.IPv4ServiceRange)
if err != nil {
log.WithError(err).WithField(logfields.V4Prefix, option.Config.IPv4ServiceRange).Fatal("Invalid IPv4 service prefix")
}
auxPrefixes = append(auxPrefixes, serviceCIDR)
}
if option.Config.IPv6ServiceRange != AutoCIDR {
serviceCIDR, err := cidr.ParseCIDR(option.Config.IPv6ServiceRange)
if err != nil {
log.WithError(err).WithField(logfields.V6Prefix, option.Config.IPv6ServiceRange).Fatal("Invalid IPv6 service prefix")
}
auxPrefixes = append(auxPrefixes, serviceCIDR)
}
return &NodeDiscovery{
Manager: manager,
LocalConfig: datapath.LocalNodeConfiguration{
MtuConfig: mtuConfig,
UseSingleClusterRoute: option.Config.UseSingleClusterRoute,
EnableIPv4: option.Config.EnableIPv4,
EnableIPv6: option.Config.EnableIPv6,
EnableEncapsulation: option.Config.Tunnel != option.TunnelDisabled,
EnableAutoDirectRouting: option.Config.EnableAutoDirectRouting,
EnableLocalNodeRoute: enableLocalNodeRoute(),
AuxiliaryPrefixes: auxPrefixes,
EnableIPSec: option.Config.EnableIPSec,
},
LocalNode: node.Node{
Source: node.FromLocalNode,
},
Registered: make(chan struct{}),
}
} | [
"func",
"NewNodeDiscovery",
"(",
"manager",
"*",
"nodemanager",
".",
"Manager",
",",
"mtuConfig",
"mtu",
".",
"Configuration",
")",
"*",
"NodeDiscovery",
"{",
"auxPrefixes",
":=",
"[",
"]",
"*",
"cidr",
".",
"CIDR",
"{",
"}",
"\n\n",
"if",
"option",
".",
"Config",
".",
"IPv4ServiceRange",
"!=",
"AutoCIDR",
"{",
"serviceCIDR",
",",
"err",
":=",
"cidr",
".",
"ParseCIDR",
"(",
"option",
".",
"Config",
".",
"IPv4ServiceRange",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"WithField",
"(",
"logfields",
".",
"V4Prefix",
",",
"option",
".",
"Config",
".",
"IPv4ServiceRange",
")",
".",
"Fatal",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"auxPrefixes",
"=",
"append",
"(",
"auxPrefixes",
",",
"serviceCIDR",
")",
"\n",
"}",
"\n\n",
"if",
"option",
".",
"Config",
".",
"IPv6ServiceRange",
"!=",
"AutoCIDR",
"{",
"serviceCIDR",
",",
"err",
":=",
"cidr",
".",
"ParseCIDR",
"(",
"option",
".",
"Config",
".",
"IPv6ServiceRange",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"WithField",
"(",
"logfields",
".",
"V6Prefix",
",",
"option",
".",
"Config",
".",
"IPv6ServiceRange",
")",
".",
"Fatal",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"auxPrefixes",
"=",
"append",
"(",
"auxPrefixes",
",",
"serviceCIDR",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"NodeDiscovery",
"{",
"Manager",
":",
"manager",
",",
"LocalConfig",
":",
"datapath",
".",
"LocalNodeConfiguration",
"{",
"MtuConfig",
":",
"mtuConfig",
",",
"UseSingleClusterRoute",
":",
"option",
".",
"Config",
".",
"UseSingleClusterRoute",
",",
"EnableIPv4",
":",
"option",
".",
"Config",
".",
"EnableIPv4",
",",
"EnableIPv6",
":",
"option",
".",
"Config",
".",
"EnableIPv6",
",",
"EnableEncapsulation",
":",
"option",
".",
"Config",
".",
"Tunnel",
"!=",
"option",
".",
"TunnelDisabled",
",",
"EnableAutoDirectRouting",
":",
"option",
".",
"Config",
".",
"EnableAutoDirectRouting",
",",
"EnableLocalNodeRoute",
":",
"enableLocalNodeRoute",
"(",
")",
",",
"AuxiliaryPrefixes",
":",
"auxPrefixes",
",",
"EnableIPSec",
":",
"option",
".",
"Config",
".",
"EnableIPSec",
",",
"}",
",",
"LocalNode",
":",
"node",
".",
"Node",
"{",
"Source",
":",
"node",
".",
"FromLocalNode",
",",
"}",
",",
"Registered",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"}",
"\n",
"}"
] | // NewNodeDiscovery returns a pointer to new node discovery object | [
"NewNodeDiscovery",
"returns",
"a",
"pointer",
"to",
"new",
"node",
"discovery",
"object"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/nodediscovery/nodediscovery.go#L62-L101 |
163,743 | cilium/cilium | pkg/nodediscovery/nodediscovery.go | StartDiscovery | func (n *NodeDiscovery) StartDiscovery(nodeName string) {
n.LocalNode.Name = nodeName
n.LocalNode.Cluster = option.Config.ClusterName
n.LocalNode.IPAddresses = []node.Address{}
n.LocalNode.IPv4AllocCIDR = node.GetIPv4AllocRange()
n.LocalNode.IPv6AllocCIDR = node.GetIPv6AllocRange()
n.LocalNode.ClusterID = option.Config.ClusterID
n.LocalNode.EncryptionKey = node.GetIPsecKeyIdentity()
if node.GetExternalIPv4() != nil {
n.LocalNode.IPAddresses = append(n.LocalNode.IPAddresses, node.Address{
Type: addressing.NodeInternalIP,
IP: node.GetExternalIPv4(),
})
}
if node.GetIPv6() != nil {
n.LocalNode.IPAddresses = append(n.LocalNode.IPAddresses, node.Address{
Type: addressing.NodeInternalIP,
IP: node.GetIPv6(),
})
}
if node.GetInternalIPv4() != nil {
n.LocalNode.IPAddresses = append(n.LocalNode.IPAddresses, node.Address{
Type: addressing.NodeCiliumInternalIP,
IP: node.GetInternalIPv4(),
})
}
if node.GetIPv6Router() != nil {
n.LocalNode.IPAddresses = append(n.LocalNode.IPAddresses, node.Address{
Type: addressing.NodeCiliumInternalIP,
IP: node.GetIPv6Router(),
})
}
n.Manager.NodeUpdated(n.LocalNode)
go func() {
log.Info("Adding local node to cluster")
for {
if err := n.Registrar.RegisterNode(&n.LocalNode, n.Manager); err != nil {
log.WithError(err).Error("Unable to initialize local node. Retrying...")
time.Sleep(time.Second)
} else {
break
}
}
close(n.Registered)
}()
go func() {
select {
case <-n.Registered:
case <-time.NewTimer(defaults.NodeInitTimeout).C:
log.Fatalf("Unable to initialize local node due to timeout")
}
}()
go func() {
<-n.Registered
controller.NewManager().UpdateController("propagating local node change to kv-store",
controller.ControllerParams{
DoFunc: func(ctx context.Context) error {
err := n.Registrar.UpdateLocalKeySync(&n.LocalNode)
if err != nil {
log.WithError(err).Error("Unable to propagate local node change to kvstore")
}
return err
},
})
}()
} | go | func (n *NodeDiscovery) StartDiscovery(nodeName string) {
n.LocalNode.Name = nodeName
n.LocalNode.Cluster = option.Config.ClusterName
n.LocalNode.IPAddresses = []node.Address{}
n.LocalNode.IPv4AllocCIDR = node.GetIPv4AllocRange()
n.LocalNode.IPv6AllocCIDR = node.GetIPv6AllocRange()
n.LocalNode.ClusterID = option.Config.ClusterID
n.LocalNode.EncryptionKey = node.GetIPsecKeyIdentity()
if node.GetExternalIPv4() != nil {
n.LocalNode.IPAddresses = append(n.LocalNode.IPAddresses, node.Address{
Type: addressing.NodeInternalIP,
IP: node.GetExternalIPv4(),
})
}
if node.GetIPv6() != nil {
n.LocalNode.IPAddresses = append(n.LocalNode.IPAddresses, node.Address{
Type: addressing.NodeInternalIP,
IP: node.GetIPv6(),
})
}
if node.GetInternalIPv4() != nil {
n.LocalNode.IPAddresses = append(n.LocalNode.IPAddresses, node.Address{
Type: addressing.NodeCiliumInternalIP,
IP: node.GetInternalIPv4(),
})
}
if node.GetIPv6Router() != nil {
n.LocalNode.IPAddresses = append(n.LocalNode.IPAddresses, node.Address{
Type: addressing.NodeCiliumInternalIP,
IP: node.GetIPv6Router(),
})
}
n.Manager.NodeUpdated(n.LocalNode)
go func() {
log.Info("Adding local node to cluster")
for {
if err := n.Registrar.RegisterNode(&n.LocalNode, n.Manager); err != nil {
log.WithError(err).Error("Unable to initialize local node. Retrying...")
time.Sleep(time.Second)
} else {
break
}
}
close(n.Registered)
}()
go func() {
select {
case <-n.Registered:
case <-time.NewTimer(defaults.NodeInitTimeout).C:
log.Fatalf("Unable to initialize local node due to timeout")
}
}()
go func() {
<-n.Registered
controller.NewManager().UpdateController("propagating local node change to kv-store",
controller.ControllerParams{
DoFunc: func(ctx context.Context) error {
err := n.Registrar.UpdateLocalKeySync(&n.LocalNode)
if err != nil {
log.WithError(err).Error("Unable to propagate local node change to kvstore")
}
return err
},
})
}()
} | [
"func",
"(",
"n",
"*",
"NodeDiscovery",
")",
"StartDiscovery",
"(",
"nodeName",
"string",
")",
"{",
"n",
".",
"LocalNode",
".",
"Name",
"=",
"nodeName",
"\n",
"n",
".",
"LocalNode",
".",
"Cluster",
"=",
"option",
".",
"Config",
".",
"ClusterName",
"\n",
"n",
".",
"LocalNode",
".",
"IPAddresses",
"=",
"[",
"]",
"node",
".",
"Address",
"{",
"}",
"\n",
"n",
".",
"LocalNode",
".",
"IPv4AllocCIDR",
"=",
"node",
".",
"GetIPv4AllocRange",
"(",
")",
"\n",
"n",
".",
"LocalNode",
".",
"IPv6AllocCIDR",
"=",
"node",
".",
"GetIPv6AllocRange",
"(",
")",
"\n",
"n",
".",
"LocalNode",
".",
"ClusterID",
"=",
"option",
".",
"Config",
".",
"ClusterID",
"\n",
"n",
".",
"LocalNode",
".",
"EncryptionKey",
"=",
"node",
".",
"GetIPsecKeyIdentity",
"(",
")",
"\n\n",
"if",
"node",
".",
"GetExternalIPv4",
"(",
")",
"!=",
"nil",
"{",
"n",
".",
"LocalNode",
".",
"IPAddresses",
"=",
"append",
"(",
"n",
".",
"LocalNode",
".",
"IPAddresses",
",",
"node",
".",
"Address",
"{",
"Type",
":",
"addressing",
".",
"NodeInternalIP",
",",
"IP",
":",
"node",
".",
"GetExternalIPv4",
"(",
")",
",",
"}",
")",
"\n",
"}",
"\n\n",
"if",
"node",
".",
"GetIPv6",
"(",
")",
"!=",
"nil",
"{",
"n",
".",
"LocalNode",
".",
"IPAddresses",
"=",
"append",
"(",
"n",
".",
"LocalNode",
".",
"IPAddresses",
",",
"node",
".",
"Address",
"{",
"Type",
":",
"addressing",
".",
"NodeInternalIP",
",",
"IP",
":",
"node",
".",
"GetIPv6",
"(",
")",
",",
"}",
")",
"\n",
"}",
"\n\n",
"if",
"node",
".",
"GetInternalIPv4",
"(",
")",
"!=",
"nil",
"{",
"n",
".",
"LocalNode",
".",
"IPAddresses",
"=",
"append",
"(",
"n",
".",
"LocalNode",
".",
"IPAddresses",
",",
"node",
".",
"Address",
"{",
"Type",
":",
"addressing",
".",
"NodeCiliumInternalIP",
",",
"IP",
":",
"node",
".",
"GetInternalIPv4",
"(",
")",
",",
"}",
")",
"\n",
"}",
"\n\n",
"if",
"node",
".",
"GetIPv6Router",
"(",
")",
"!=",
"nil",
"{",
"n",
".",
"LocalNode",
".",
"IPAddresses",
"=",
"append",
"(",
"n",
".",
"LocalNode",
".",
"IPAddresses",
",",
"node",
".",
"Address",
"{",
"Type",
":",
"addressing",
".",
"NodeCiliumInternalIP",
",",
"IP",
":",
"node",
".",
"GetIPv6Router",
"(",
")",
",",
"}",
")",
"\n",
"}",
"\n\n",
"n",
".",
"Manager",
".",
"NodeUpdated",
"(",
"n",
".",
"LocalNode",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"for",
"{",
"if",
"err",
":=",
"n",
".",
"Registrar",
".",
"RegisterNode",
"(",
"&",
"n",
".",
"LocalNode",
",",
"n",
".",
"Manager",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"time",
".",
"Sleep",
"(",
"time",
".",
"Second",
")",
"\n",
"}",
"else",
"{",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"close",
"(",
"n",
".",
"Registered",
")",
"\n",
"}",
"(",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"select",
"{",
"case",
"<-",
"n",
".",
"Registered",
":",
"case",
"<-",
"time",
".",
"NewTimer",
"(",
"defaults",
".",
"NodeInitTimeout",
")",
".",
"C",
":",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"<-",
"n",
".",
"Registered",
"\n",
"controller",
".",
"NewManager",
"(",
")",
".",
"UpdateController",
"(",
"\"",
"\"",
",",
"controller",
".",
"ControllerParams",
"{",
"DoFunc",
":",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"err",
":=",
"n",
".",
"Registrar",
".",
"UpdateLocalKeySync",
"(",
"&",
"n",
".",
"LocalNode",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
",",
"}",
")",
"\n",
"}",
"(",
")",
"\n",
"}"
] | // start configures the local node and starts node discovery. This is called on
// agent startup to configure the local node based on the configuration options
// passed to the agent. nodeName is the name to be used in the local agent. | [
"start",
"configures",
"the",
"local",
"node",
"and",
"starts",
"node",
"discovery",
".",
"This",
"is",
"called",
"on",
"agent",
"startup",
"to",
"configure",
"the",
"local",
"node",
"based",
"on",
"the",
"configuration",
"options",
"passed",
"to",
"the",
"agent",
".",
"nodeName",
"is",
"the",
"name",
"to",
"be",
"used",
"in",
"the",
"local",
"agent",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/nodediscovery/nodediscovery.go#L106-L179 |
163,744 | cilium/cilium | pkg/logging/logging.go | InitializeDefaultLogger | func InitializeDefaultLogger() *logrus.Logger {
logger := logrus.New()
logger.Formatter = setupFormatter()
return logger
} | go | func InitializeDefaultLogger() *logrus.Logger {
logger := logrus.New()
logger.Formatter = setupFormatter()
return logger
} | [
"func",
"InitializeDefaultLogger",
"(",
")",
"*",
"logrus",
".",
"Logger",
"{",
"logger",
":=",
"logrus",
".",
"New",
"(",
")",
"\n",
"logger",
".",
"Formatter",
"=",
"setupFormatter",
"(",
")",
"\n",
"return",
"logger",
"\n",
"}"
] | // InitializeDefaultLogger returns a logrus Logger with a custom text formatter. | [
"InitializeDefaultLogger",
"returns",
"a",
"logrus",
"Logger",
"with",
"a",
"custom",
"text",
"formatter",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/logging/logging.go#L62-L66 |
163,745 | cilium/cilium | pkg/logging/logging.go | SetupLogging | func SetupLogging(loggers []string, logOpts map[string]string, tag string, debug bool) error {
// Set default logger to output to stdout if no loggers are provided.
if len(loggers) == 0 {
// TODO: switch to a per-logger version when we upgrade to logrus >1.0.3
logrus.SetOutput(os.Stdout)
}
SetLogLevel(DefaultLogLevel)
ToggleDebugLogs(debug)
// always suppress the default logger so libraries don't print things
logrus.SetLevel(logrus.PanicLevel)
// Iterate through all provided loggers and configure them according
// to user-provided settings.
for _, logger := range loggers {
switch logger {
case Syslog:
valuesToValidate := getLogDriverConfig(Syslog, logOpts)
err := validateOpts(Syslog, valuesToValidate, syslogOpts)
if err != nil {
return err
}
setupSyslog(valuesToValidate, tag, debug)
default:
return fmt.Errorf("provided log driver %q is not a supported log driver", logger)
}
}
return nil
} | go | func SetupLogging(loggers []string, logOpts map[string]string, tag string, debug bool) error {
// Set default logger to output to stdout if no loggers are provided.
if len(loggers) == 0 {
// TODO: switch to a per-logger version when we upgrade to logrus >1.0.3
logrus.SetOutput(os.Stdout)
}
SetLogLevel(DefaultLogLevel)
ToggleDebugLogs(debug)
// always suppress the default logger so libraries don't print things
logrus.SetLevel(logrus.PanicLevel)
// Iterate through all provided loggers and configure them according
// to user-provided settings.
for _, logger := range loggers {
switch logger {
case Syslog:
valuesToValidate := getLogDriverConfig(Syslog, logOpts)
err := validateOpts(Syslog, valuesToValidate, syslogOpts)
if err != nil {
return err
}
setupSyslog(valuesToValidate, tag, debug)
default:
return fmt.Errorf("provided log driver %q is not a supported log driver", logger)
}
}
return nil
} | [
"func",
"SetupLogging",
"(",
"loggers",
"[",
"]",
"string",
",",
"logOpts",
"map",
"[",
"string",
"]",
"string",
",",
"tag",
"string",
",",
"debug",
"bool",
")",
"error",
"{",
"// Set default logger to output to stdout if no loggers are provided.",
"if",
"len",
"(",
"loggers",
")",
"==",
"0",
"{",
"// TODO: switch to a per-logger version when we upgrade to logrus >1.0.3",
"logrus",
".",
"SetOutput",
"(",
"os",
".",
"Stdout",
")",
"\n",
"}",
"\n\n",
"SetLogLevel",
"(",
"DefaultLogLevel",
")",
"\n",
"ToggleDebugLogs",
"(",
"debug",
")",
"\n\n",
"// always suppress the default logger so libraries don't print things",
"logrus",
".",
"SetLevel",
"(",
"logrus",
".",
"PanicLevel",
")",
"\n\n",
"// Iterate through all provided loggers and configure them according",
"// to user-provided settings.",
"for",
"_",
",",
"logger",
":=",
"range",
"loggers",
"{",
"switch",
"logger",
"{",
"case",
"Syslog",
":",
"valuesToValidate",
":=",
"getLogDriverConfig",
"(",
"Syslog",
",",
"logOpts",
")",
"\n",
"err",
":=",
"validateOpts",
"(",
"Syslog",
",",
"valuesToValidate",
",",
"syslogOpts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"setupSyslog",
"(",
"valuesToValidate",
",",
"tag",
",",
"debug",
")",
"\n",
"default",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"logger",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // SetupLogging sets up each logging service provided in loggers and configures
// each logger with the provided logOpts. | [
"SetupLogging",
"sets",
"up",
"each",
"logging",
"service",
"provided",
"in",
"loggers",
"and",
"configures",
"each",
"logger",
"with",
"the",
"provided",
"logOpts",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/logging/logging.go#L70-L100 |
163,746 | cilium/cilium | pkg/logging/logging.go | setupSyslog | func setupSyslog(logOpts map[string]string, tag string, debug bool) {
logLevel, ok := logOpts[SLevel]
if !ok {
if debug {
logLevel = "debug"
} else {
logLevel = "info"
}
}
//Validate provided log level.
level, err := logrus.ParseLevel(logLevel)
if err != nil {
DefaultLogger.Fatal(err)
}
DefaultLogger.SetLevel(level)
// Create syslog hook.
h, err := logrus_syslog.NewSyslogHook("", "", syslogLevelMap[level], tag)
if err != nil {
DefaultLogger.Fatal(err)
}
// TODO: switch to a per-logger version when we upgrade to logrus >1.0.3
logrus.AddHook(h)
} | go | func setupSyslog(logOpts map[string]string, tag string, debug bool) {
logLevel, ok := logOpts[SLevel]
if !ok {
if debug {
logLevel = "debug"
} else {
logLevel = "info"
}
}
//Validate provided log level.
level, err := logrus.ParseLevel(logLevel)
if err != nil {
DefaultLogger.Fatal(err)
}
DefaultLogger.SetLevel(level)
// Create syslog hook.
h, err := logrus_syslog.NewSyslogHook("", "", syslogLevelMap[level], tag)
if err != nil {
DefaultLogger.Fatal(err)
}
// TODO: switch to a per-logger version when we upgrade to logrus >1.0.3
logrus.AddHook(h)
} | [
"func",
"setupSyslog",
"(",
"logOpts",
"map",
"[",
"string",
"]",
"string",
",",
"tag",
"string",
",",
"debug",
"bool",
")",
"{",
"logLevel",
",",
"ok",
":=",
"logOpts",
"[",
"SLevel",
"]",
"\n",
"if",
"!",
"ok",
"{",
"if",
"debug",
"{",
"logLevel",
"=",
"\"",
"\"",
"\n",
"}",
"else",
"{",
"logLevel",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"}",
"\n\n",
"//Validate provided log level.",
"level",
",",
"err",
":=",
"logrus",
".",
"ParseLevel",
"(",
"logLevel",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"DefaultLogger",
".",
"Fatal",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"DefaultLogger",
".",
"SetLevel",
"(",
"level",
")",
"\n",
"// Create syslog hook.",
"h",
",",
"err",
":=",
"logrus_syslog",
".",
"NewSyslogHook",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"syslogLevelMap",
"[",
"level",
"]",
",",
"tag",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"DefaultLogger",
".",
"Fatal",
"(",
"err",
")",
"\n",
"}",
"\n",
"// TODO: switch to a per-logger version when we upgrade to logrus >1.0.3",
"logrus",
".",
"AddHook",
"(",
"h",
")",
"\n",
"}"
] | // setupSyslog sets up and configures syslog with the provided options in
// logOpts. If some options are not provided, sensible defaults are used. | [
"setupSyslog",
"sets",
"up",
"and",
"configures",
"syslog",
"with",
"the",
"provided",
"options",
"in",
"logOpts",
".",
"If",
"some",
"options",
"are",
"not",
"provided",
"sensible",
"defaults",
"are",
"used",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/logging/logging.go#L124-L148 |
163,747 | cilium/cilium | pkg/logging/logging.go | setupFormatter | func setupFormatter() logrus.Formatter {
fileFormat := new(logrus.TextFormatter)
fileFormat.DisableTimestamp = true
fileFormat.DisableColors = true
switch os.Getenv("INITSYSTEM") {
case "SYSTEMD":
fileFormat.FullTimestamp = true
default:
fileFormat.TimestampFormat = time.RFC3339
}
// TODO: switch to a per-logger version when we upgrade to logrus >1.0.3
return fileFormat
} | go | func setupFormatter() logrus.Formatter {
fileFormat := new(logrus.TextFormatter)
fileFormat.DisableTimestamp = true
fileFormat.DisableColors = true
switch os.Getenv("INITSYSTEM") {
case "SYSTEMD":
fileFormat.FullTimestamp = true
default:
fileFormat.TimestampFormat = time.RFC3339
}
// TODO: switch to a per-logger version when we upgrade to logrus >1.0.3
return fileFormat
} | [
"func",
"setupFormatter",
"(",
")",
"logrus",
".",
"Formatter",
"{",
"fileFormat",
":=",
"new",
"(",
"logrus",
".",
"TextFormatter",
")",
"\n",
"fileFormat",
".",
"DisableTimestamp",
"=",
"true",
"\n",
"fileFormat",
".",
"DisableColors",
"=",
"true",
"\n",
"switch",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"{",
"case",
"\"",
"\"",
":",
"fileFormat",
".",
"FullTimestamp",
"=",
"true",
"\n",
"default",
":",
"fileFormat",
".",
"TimestampFormat",
"=",
"time",
".",
"RFC3339",
"\n",
"}",
"\n\n",
"// TODO: switch to a per-logger version when we upgrade to logrus >1.0.3",
"return",
"fileFormat",
"\n",
"}"
] | // setupFormatter sets up the text formatting for logs output by logrus. | [
"setupFormatter",
"sets",
"up",
"the",
"text",
"formatting",
"for",
"logs",
"output",
"by",
"logrus",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/logging/logging.go#L151-L164 |
163,748 | cilium/cilium | pkg/logging/logging.go | validateOpts | func validateOpts(logDriver string, logOpts map[string]string, supportedOpts map[string]bool) error {
for k := range logOpts {
if !supportedOpts[k] {
return fmt.Errorf("provided configuration value %q is not supported as a logging option for log driver %s", k, logDriver)
}
}
return nil
} | go | func validateOpts(logDriver string, logOpts map[string]string, supportedOpts map[string]bool) error {
for k := range logOpts {
if !supportedOpts[k] {
return fmt.Errorf("provided configuration value %q is not supported as a logging option for log driver %s", k, logDriver)
}
}
return nil
} | [
"func",
"validateOpts",
"(",
"logDriver",
"string",
",",
"logOpts",
"map",
"[",
"string",
"]",
"string",
",",
"supportedOpts",
"map",
"[",
"string",
"]",
"bool",
")",
"error",
"{",
"for",
"k",
":=",
"range",
"logOpts",
"{",
"if",
"!",
"supportedOpts",
"[",
"k",
"]",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"k",
",",
"logDriver",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // validateOpts iterates through all of the keys in logOpts, and errors out if
// the key in logOpts is not a key in supportedOpts. | [
"validateOpts",
"iterates",
"through",
"all",
"of",
"the",
"keys",
"in",
"logOpts",
"and",
"errors",
"out",
"if",
"the",
"key",
"in",
"logOpts",
"is",
"not",
"a",
"key",
"in",
"supportedOpts",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/logging/logging.go#L168-L175 |
163,749 | cilium/cilium | pkg/logging/logging.go | getLogDriverConfig | func getLogDriverConfig(logDriver string, logOpts map[string]string) map[string]string {
keysToValidate := make(map[string]string)
for k, v := range logOpts {
ok, err := regexp.MatchString(logDriver+".*", k)
if err != nil {
DefaultLogger.Fatal(err)
}
if ok {
keysToValidate[k] = v
}
}
return keysToValidate
} | go | func getLogDriverConfig(logDriver string, logOpts map[string]string) map[string]string {
keysToValidate := make(map[string]string)
for k, v := range logOpts {
ok, err := regexp.MatchString(logDriver+".*", k)
if err != nil {
DefaultLogger.Fatal(err)
}
if ok {
keysToValidate[k] = v
}
}
return keysToValidate
} | [
"func",
"getLogDriverConfig",
"(",
"logDriver",
"string",
",",
"logOpts",
"map",
"[",
"string",
"]",
"string",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"keysToValidate",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"logOpts",
"{",
"ok",
",",
"err",
":=",
"regexp",
".",
"MatchString",
"(",
"logDriver",
"+",
"\"",
"\"",
",",
"k",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"DefaultLogger",
".",
"Fatal",
"(",
"err",
")",
"\n",
"}",
"\n",
"if",
"ok",
"{",
"keysToValidate",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"keysToValidate",
"\n",
"}"
] | // getLogDriverConfig returns a map containing the key-value pairs that start
// with string logDriver from map logOpts. | [
"getLogDriverConfig",
"returns",
"a",
"map",
"containing",
"the",
"key",
"-",
"value",
"pairs",
"that",
"start",
"with",
"string",
"logDriver",
"from",
"map",
"logOpts",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/logging/logging.go#L179-L191 |
163,750 | cilium/cilium | pkg/logging/logging.go | MultiLine | func MultiLine(logFn func(args ...interface{}), output string) {
scanner := bufio.NewScanner(bytes.NewReader([]byte(output)))
for scanner.Scan() {
logFn(scanner.Text())
}
} | go | func MultiLine(logFn func(args ...interface{}), output string) {
scanner := bufio.NewScanner(bytes.NewReader([]byte(output)))
for scanner.Scan() {
logFn(scanner.Text())
}
} | [
"func",
"MultiLine",
"(",
"logFn",
"func",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
",",
"output",
"string",
")",
"{",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"bytes",
".",
"NewReader",
"(",
"[",
"]",
"byte",
"(",
"output",
")",
")",
")",
"\n",
"for",
"scanner",
".",
"Scan",
"(",
")",
"{",
"logFn",
"(",
"scanner",
".",
"Text",
"(",
")",
")",
"\n",
"}",
"\n",
"}"
] | // MultiLine breaks a multi line text into individual log entries and calls the
// logging function to log each entry | [
"MultiLine",
"breaks",
"a",
"multi",
"line",
"text",
"into",
"individual",
"log",
"entries",
"and",
"calls",
"the",
"logging",
"function",
"to",
"log",
"each",
"entry"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/logging/logging.go#L195-L200 |
163,751 | cilium/cilium | pkg/logging/logging.go | CanLogAt | func CanLogAt(logger *logrus.Logger, level logrus.Level) bool {
return GetLevel(logger) >= level
} | go | func CanLogAt(logger *logrus.Logger, level logrus.Level) bool {
return GetLevel(logger) >= level
} | [
"func",
"CanLogAt",
"(",
"logger",
"*",
"logrus",
".",
"Logger",
",",
"level",
"logrus",
".",
"Level",
")",
"bool",
"{",
"return",
"GetLevel",
"(",
"logger",
")",
">=",
"level",
"\n",
"}"
] | // CanLogAt returns whether a log message at the given level would be
// logged by the given logger. | [
"CanLogAt",
"returns",
"whether",
"a",
"log",
"message",
"at",
"the",
"given",
"level",
"would",
"be",
"logged",
"by",
"the",
"given",
"logger",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/logging/logging.go#L204-L206 |
163,752 | cilium/cilium | pkg/logging/logging.go | GetLevel | func GetLevel(logger *logrus.Logger) logrus.Level {
return logrus.Level(atomic.LoadUint32((*uint32)(&logger.Level)))
} | go | func GetLevel(logger *logrus.Logger) logrus.Level {
return logrus.Level(atomic.LoadUint32((*uint32)(&logger.Level)))
} | [
"func",
"GetLevel",
"(",
"logger",
"*",
"logrus",
".",
"Logger",
")",
"logrus",
".",
"Level",
"{",
"return",
"logrus",
".",
"Level",
"(",
"atomic",
".",
"LoadUint32",
"(",
"(",
"*",
"uint32",
")",
"(",
"&",
"logger",
".",
"Level",
")",
")",
")",
"\n",
"}"
] | // GetLevel returns the log level of the given logger. | [
"GetLevel",
"returns",
"the",
"log",
"level",
"of",
"the",
"given",
"logger",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/logging/logging.go#L209-L211 |
163,753 | cilium/cilium | api/v1/server/restapi/policy/get_fqdn_cache_responses.go | WithPayload | func (o *GetFqdnCacheOK) WithPayload(payload []*models.DNSLookup) *GetFqdnCacheOK {
o.Payload = payload
return o
} | go | func (o *GetFqdnCacheOK) WithPayload(payload []*models.DNSLookup) *GetFqdnCacheOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetFqdnCacheOK",
")",
"WithPayload",
"(",
"payload",
"[",
"]",
"*",
"models",
".",
"DNSLookup",
")",
"*",
"GetFqdnCacheOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get fqdn cache o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"fqdn",
"cache",
"o",
"k",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/get_fqdn_cache_responses.go#L38-L41 |
163,754 | cilium/cilium | api/v1/server/restapi/policy/get_fqdn_cache_responses.go | WithPayload | func (o *GetFqdnCacheBadRequest) WithPayload(payload models.Error) *GetFqdnCacheBadRequest {
o.Payload = payload
return o
} | go | func (o *GetFqdnCacheBadRequest) WithPayload(payload models.Error) *GetFqdnCacheBadRequest {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetFqdnCacheBadRequest",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"GetFqdnCacheBadRequest",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get fqdn cache bad request response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"fqdn",
"cache",
"bad",
"request",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/get_fqdn_cache_responses.go#L85-L88 |
163,755 | cilium/cilium | api/v1/health/models/status_response.go | Validate | func (m *StatusResponse) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCilium(formats); err != nil {
res = append(res, err)
}
if err := m.validateCluster(formats); err != nil {
res = append(res, err)
}
if err := m.validateContainerRuntime(formats); err != nil {
res = append(res, err)
}
if err := m.validateControllers(formats); err != nil {
res = append(res, err)
}
if err := m.validateIPAM(formats); err != nil {
res = append(res, err)
}
if err := m.validateKubernetes(formats); err != nil {
res = append(res, err)
}
if err := m.validateKvstore(formats); err != nil {
res = append(res, err)
}
if err := m.validateNodeMonitor(formats); err != nil {
res = append(res, err)
}
if err := m.validateProxy(formats); err != nil {
res = append(res, err)
}
if err := m.validateStale(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *StatusResponse) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCilium(formats); err != nil {
res = append(res, err)
}
if err := m.validateCluster(formats); err != nil {
res = append(res, err)
}
if err := m.validateContainerRuntime(formats); err != nil {
res = append(res, err)
}
if err := m.validateControllers(formats); err != nil {
res = append(res, err)
}
if err := m.validateIPAM(formats); err != nil {
res = append(res, err)
}
if err := m.validateKubernetes(formats); err != nil {
res = append(res, err)
}
if err := m.validateKvstore(formats); err != nil {
res = append(res, err)
}
if err := m.validateNodeMonitor(formats); err != nil {
res = append(res, err)
}
if err := m.validateProxy(formats); err != nil {
res = append(res, err)
}
if err := m.validateStale(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"StatusResponse",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateCilium",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateCluster",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateContainerRuntime",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateControllers",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateIPAM",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateKubernetes",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateKvstore",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateNodeMonitor",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateProxy",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateStale",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this status response | [
"Validate",
"validates",
"this",
"status",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/models/status_response.go#L55-L102 |
163,756 | cilium/cilium | api/v1/health/models/status_response.go | Validate | func (m *StatusResponseClusterNodesItems0PrimaryAddress) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateIPV4(formats); err != nil {
res = append(res, err)
}
if err := m.validateIPV6(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *StatusResponseClusterNodesItems0PrimaryAddress) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateIPV4(formats); err != nil {
res = append(res, err)
}
if err := m.validateIPV6(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"StatusResponseClusterNodesItems0PrimaryAddress",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateIPV4",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateIPV6",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this status response cluster nodes items0 primary address | [
"Validate",
"validates",
"this",
"status",
"response",
"cluster",
"nodes",
"items0",
"primary",
"address"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/models/status_response.go#L882-L897 |
163,757 | cilium/cilium | api/v1/health/models/status_response.go | Validate | func (m *StatusResponseControllersItems0Configuration) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateErrorRetryBase(formats); err != nil {
res = append(res, err)
}
if err := m.validateInterval(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *StatusResponseControllersItems0Configuration) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateErrorRetryBase(formats); err != nil {
res = append(res, err)
}
if err := m.validateInterval(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"StatusResponseControllersItems0Configuration",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateErrorRetryBase",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateInterval",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this status response controllers items0 configuration | [
"Validate",
"validates",
"this",
"status",
"response",
"controllers",
"items0",
"configuration"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/models/status_response.go#L1290-L1305 |
163,758 | cilium/cilium | api/v1/health/models/status_response.go | Validate | func (m *StatusResponseControllersItems0Status) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateLastFailureTimestamp(formats); err != nil {
res = append(res, err)
}
if err := m.validateLastSuccessTimestamp(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *StatusResponseControllersItems0Status) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateLastFailureTimestamp(formats); err != nil {
res = append(res, err)
}
if err := m.validateLastSuccessTimestamp(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"StatusResponseControllersItems0Status",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateLastFailureTimestamp",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateLastSuccessTimestamp",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this status response controllers items0 status | [
"Validate",
"validates",
"this",
"status",
"response",
"controllers",
"items0",
"status"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/models/status_response.go#L1377-L1392 |
163,759 | cilium/cilium | api/v1/health/models/status_response.go | Validate | func (m *StatusResponseKubernetes) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateState(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *StatusResponseKubernetes) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateState(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"StatusResponseKubernetes",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateState",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this status response kubernetes | [
"Validate",
"validates",
"this",
"status",
"response",
"kubernetes"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/models/status_response.go#L1492-L1503 |
163,760 | cilium/cilium | api/v1/client/endpoint/get_endpoint_id_parameters.go | WithTimeout | func (o *GetEndpointIDParams) WithTimeout(timeout time.Duration) *GetEndpointIDParams {
o.SetTimeout(timeout)
return o
} | go | func (o *GetEndpointIDParams) WithTimeout(timeout time.Duration) *GetEndpointIDParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointIDParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"GetEndpointIDParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the get endpoint ID params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"get",
"endpoint",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_parameters.go#L88-L91 |
163,761 | cilium/cilium | api/v1/client/endpoint/get_endpoint_id_parameters.go | WithContext | func (o *GetEndpointIDParams) WithContext(ctx context.Context) *GetEndpointIDParams {
o.SetContext(ctx)
return o
} | go | func (o *GetEndpointIDParams) WithContext(ctx context.Context) *GetEndpointIDParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointIDParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"GetEndpointIDParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the get endpoint ID params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"get",
"endpoint",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_parameters.go#L99-L102 |
163,762 | cilium/cilium | api/v1/client/endpoint/get_endpoint_id_parameters.go | WithHTTPClient | func (o *GetEndpointIDParams) WithHTTPClient(client *http.Client) *GetEndpointIDParams {
o.SetHTTPClient(client)
return o
} | go | func (o *GetEndpointIDParams) WithHTTPClient(client *http.Client) *GetEndpointIDParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointIDParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"GetEndpointIDParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the get endpoint ID params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"get",
"endpoint",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_parameters.go#L110-L113 |
163,763 | cilium/cilium | api/v1/client/endpoint/get_endpoint_id_parameters.go | WithID | func (o *GetEndpointIDParams) WithID(id string) *GetEndpointIDParams {
o.SetID(id)
return o
} | go | func (o *GetEndpointIDParams) WithID(id string) *GetEndpointIDParams {
o.SetID(id)
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointIDParams",
")",
"WithID",
"(",
"id",
"string",
")",
"*",
"GetEndpointIDParams",
"{",
"o",
".",
"SetID",
"(",
"id",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithID adds the id to the get endpoint ID params | [
"WithID",
"adds",
"the",
"id",
"to",
"the",
"get",
"endpoint",
"ID",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_parameters.go#L121-L124 |
163,764 | cilium/cilium | api/v1/client/service/get_service_parameters.go | WithTimeout | func (o *GetServiceParams) WithTimeout(timeout time.Duration) *GetServiceParams {
o.SetTimeout(timeout)
return o
} | go | func (o *GetServiceParams) WithTimeout(timeout time.Duration) *GetServiceParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"GetServiceParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"GetServiceParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the get service params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"get",
"service",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/get_service_parameters.go#L69-L72 |
163,765 | cilium/cilium | api/v1/client/service/get_service_parameters.go | WithContext | func (o *GetServiceParams) WithContext(ctx context.Context) *GetServiceParams {
o.SetContext(ctx)
return o
} | go | func (o *GetServiceParams) WithContext(ctx context.Context) *GetServiceParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"GetServiceParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"GetServiceParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the get service params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"get",
"service",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/get_service_parameters.go#L80-L83 |
163,766 | cilium/cilium | api/v1/client/service/get_service_parameters.go | WithHTTPClient | func (o *GetServiceParams) WithHTTPClient(client *http.Client) *GetServiceParams {
o.SetHTTPClient(client)
return o
} | go | func (o *GetServiceParams) WithHTTPClient(client *http.Client) *GetServiceParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"GetServiceParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"GetServiceParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the get service params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"get",
"service",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/service/get_service_parameters.go#L91-L94 |
163,767 | cilium/cilium | api/v1/server/restapi/policy/put_policy_responses.go | WithPayload | func (o *PutPolicyOK) WithPayload(payload *models.Policy) *PutPolicyOK {
o.Payload = payload
return o
} | go | func (o *PutPolicyOK) WithPayload(payload *models.Policy) *PutPolicyOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"PutPolicyOK",
")",
"WithPayload",
"(",
"payload",
"*",
"models",
".",
"Policy",
")",
"*",
"PutPolicyOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the put policy o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"put",
"policy",
"o",
"k",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/put_policy_responses.go#L38-L41 |
163,768 | cilium/cilium | api/v1/server/restapi/policy/put_policy_responses.go | WithPayload | func (o *PutPolicyInvalidPolicy) WithPayload(payload models.Error) *PutPolicyInvalidPolicy {
o.Payload = payload
return o
} | go | func (o *PutPolicyInvalidPolicy) WithPayload(payload models.Error) *PutPolicyInvalidPolicy {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"PutPolicyInvalidPolicy",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"PutPolicyInvalidPolicy",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the put policy invalid policy response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"put",
"policy",
"invalid",
"policy",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/put_policy_responses.go#L82-L85 |
163,769 | cilium/cilium | api/v1/server/restapi/policy/put_policy_responses.go | WithPayload | func (o *PutPolicyInvalidPath) WithPayload(payload models.Error) *PutPolicyInvalidPath {
o.Payload = payload
return o
} | go | func (o *PutPolicyInvalidPath) WithPayload(payload models.Error) *PutPolicyInvalidPath {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"PutPolicyInvalidPath",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"PutPolicyInvalidPath",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the put policy invalid path response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"put",
"policy",
"invalid",
"path",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/put_policy_responses.go#L124-L127 |
163,770 | cilium/cilium | api/v1/server/restapi/policy/put_policy_responses.go | WithPayload | func (o *PutPolicyFailure) WithPayload(payload models.Error) *PutPolicyFailure {
o.Payload = payload
return o
} | go | func (o *PutPolicyFailure) WithPayload(payload models.Error) *PutPolicyFailure {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"PutPolicyFailure",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"PutPolicyFailure",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the put policy failure response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"put",
"policy",
"failure",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/put_policy_responses.go#L166-L169 |
163,771 | cilium/cilium | api/v1/server/restapi/policy/get_fqdn_cache_parameters.go | bindMatchpattern | func (o *GetFqdnCacheParams) bindMatchpattern(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
return nil
}
o.Matchpattern = &raw
return nil
} | go | func (o *GetFqdnCacheParams) bindMatchpattern(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
return nil
}
o.Matchpattern = &raw
return nil
} | [
"func",
"(",
"o",
"*",
"GetFqdnCacheParams",
")",
"bindMatchpattern",
"(",
"rawData",
"[",
"]",
"string",
",",
"hasKey",
"bool",
",",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"raw",
"string",
"\n",
"if",
"len",
"(",
"rawData",
")",
">",
"0",
"{",
"raw",
"=",
"rawData",
"[",
"len",
"(",
"rawData",
")",
"-",
"1",
"]",
"\n",
"}",
"\n\n",
"// Required: false",
"// AllowEmptyValue: false",
"if",
"raw",
"==",
"\"",
"\"",
"{",
"// empty values pass all other validations",
"return",
"nil",
"\n",
"}",
"\n\n",
"o",
".",
"Matchpattern",
"=",
"&",
"raw",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // bindMatchpattern binds and validates parameter Matchpattern from query. | [
"bindMatchpattern",
"binds",
"and",
"validates",
"parameter",
"Matchpattern",
"from",
"query",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/get_fqdn_cache_parameters.go#L90-L105 |
163,772 | cilium/cilium | pkg/maps/eppolicymap/eppolicymap.go | newEndpointKey | func newEndpointKey(ip net.IP) *EndpointKey {
return &EndpointKey{
EndpointKey: bpf.NewEndpointKey(ip),
}
} | go | func newEndpointKey(ip net.IP) *EndpointKey {
return &EndpointKey{
EndpointKey: bpf.NewEndpointKey(ip),
}
} | [
"func",
"newEndpointKey",
"(",
"ip",
"net",
".",
"IP",
")",
"*",
"EndpointKey",
"{",
"return",
"&",
"EndpointKey",
"{",
"EndpointKey",
":",
"bpf",
".",
"NewEndpointKey",
"(",
"ip",
")",
",",
"}",
"\n",
"}"
] | // newEndpointKey return a new key from the IP address. | [
"newEndpointKey",
"return",
"a",
"new",
"key",
"from",
"the",
"IP",
"address",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/eppolicymap/eppolicymap.go#L101-L105 |
163,773 | cilium/cilium | pkg/maps/eppolicymap/eppolicymap.go | WriteEndpoint | func WriteEndpoint(keys []*lxcmap.EndpointKey, pm *policymap.PolicyMap) error {
return writeEndpoint(keys, pm.GetFd())
} | go | func WriteEndpoint(keys []*lxcmap.EndpointKey, pm *policymap.PolicyMap) error {
return writeEndpoint(keys, pm.GetFd())
} | [
"func",
"WriteEndpoint",
"(",
"keys",
"[",
"]",
"*",
"lxcmap",
".",
"EndpointKey",
",",
"pm",
"*",
"policymap",
".",
"PolicyMap",
")",
"error",
"{",
"return",
"writeEndpoint",
"(",
"keys",
",",
"pm",
".",
"GetFd",
"(",
")",
")",
"\n",
"}"
] | // WriteEndpoint writes the policy map file descriptor into the map so that
// the datapath side can do a lookup from EndpointKey->PolicyMap. Locking is
// handled in the usual way via Map lock. If sockops is disabled this will be
// a nop. | [
"WriteEndpoint",
"writes",
"the",
"policy",
"map",
"file",
"descriptor",
"into",
"the",
"map",
"so",
"that",
"the",
"datapath",
"side",
"can",
"do",
"a",
"lookup",
"from",
"EndpointKey",
"-",
">",
"PolicyMap",
".",
"Locking",
"is",
"handled",
"in",
"the",
"usual",
"way",
"via",
"Map",
"lock",
".",
"If",
"sockops",
"is",
"disabled",
"this",
"will",
"be",
"a",
"nop",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/eppolicymap/eppolicymap.go#L131-L133 |
163,774 | cilium/cilium | api/v1/models/daemon_configuration_status.go | Validate | func (m *DaemonConfigurationStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAddressing(formats); err != nil {
res = append(res, err)
}
if err := m.validateDatapathMode(formats); err != nil {
res = append(res, err)
}
if err := m.validateImmutable(formats); err != nil {
res = append(res, err)
}
if err := m.validateIpvlanConfiguration(formats); err != nil {
res = append(res, err)
}
if err := m.validateKvstoreConfiguration(formats); err != nil {
res = append(res, err)
}
if err := m.validateNodeMonitor(formats); err != nil {
res = append(res, err)
}
if err := m.validateRealized(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *DaemonConfigurationStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAddressing(formats); err != nil {
res = append(res, err)
}
if err := m.validateDatapathMode(formats); err != nil {
res = append(res, err)
}
if err := m.validateImmutable(formats); err != nil {
res = append(res, err)
}
if err := m.validateIpvlanConfiguration(formats); err != nil {
res = append(res, err)
}
if err := m.validateKvstoreConfiguration(formats); err != nil {
res = append(res, err)
}
if err := m.validateNodeMonitor(formats); err != nil {
res = append(res, err)
}
if err := m.validateRealized(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"DaemonConfigurationStatus",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateAddressing",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateDatapathMode",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateImmutable",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateIpvlanConfiguration",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateKvstoreConfiguration",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateNodeMonitor",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateRealized",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this daemon configuration status | [
"Validate",
"validates",
"this",
"daemon",
"configuration",
"status"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/daemon_configuration_status.go#L57-L92 |
163,775 | cilium/cilium | api/v1/models/endpoint_networking.go | Validate | func (m *EndpointNetworking) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAddressing(formats); err != nil {
res = append(res, err)
}
if err := m.validateHostAddressing(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *EndpointNetworking) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAddressing(formats); err != nil {
res = append(res, err)
}
if err := m.validateHostAddressing(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"EndpointNetworking",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateAddressing",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateHostAddressing",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this endpoint networking | [
"Validate",
"validates",
"this",
"endpoint",
"networking"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/endpoint_networking.go#L41-L56 |
163,776 | cilium/cilium | api/v1/server/restapi/metrics/get_metrics_responses.go | WithPayload | func (o *GetMetricsOK) WithPayload(payload []*models.Metric) *GetMetricsOK {
o.Payload = payload
return o
} | go | func (o *GetMetricsOK) WithPayload(payload []*models.Metric) *GetMetricsOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetMetricsOK",
")",
"WithPayload",
"(",
"payload",
"[",
"]",
"*",
"models",
".",
"Metric",
")",
"*",
"GetMetricsOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get metrics o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"metrics",
"o",
"k",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/metrics/get_metrics_responses.go#L38-L41 |
163,777 | cilium/cilium | pkg/labels/array.go | Sort | func (ls LabelArray) Sort() LabelArray {
sort.Slice(ls, func(i, j int) bool {
return ls[i].Key < ls[j].Key
})
return ls
} | go | func (ls LabelArray) Sort() LabelArray {
sort.Slice(ls, func(i, j int) bool {
return ls[i].Key < ls[j].Key
})
return ls
} | [
"func",
"(",
"ls",
"LabelArray",
")",
"Sort",
"(",
")",
"LabelArray",
"{",
"sort",
".",
"Slice",
"(",
"ls",
",",
"func",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"ls",
"[",
"i",
"]",
".",
"Key",
"<",
"ls",
"[",
"j",
"]",
".",
"Key",
"\n",
"}",
")",
"\n",
"return",
"ls",
"\n",
"}"
] | // Sort is an internal utility to return all LabelArrays in sorted
// order, when the source material may be unsorted. 'ls' is sorted
// in-place, but also returns the sorted array for convenience. | [
"Sort",
"is",
"an",
"internal",
"utility",
"to",
"return",
"all",
"LabelArrays",
"in",
"sorted",
"order",
"when",
"the",
"source",
"material",
"may",
"be",
"unsorted",
".",
"ls",
"is",
"sorted",
"in",
"-",
"place",
"but",
"also",
"returns",
"the",
"sorted",
"array",
"for",
"convenience",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/array.go#L28-L33 |
163,778 | cilium/cilium | pkg/labels/array.go | ParseLabelArray | func ParseLabelArray(labels ...string) LabelArray {
array := make(LabelArray, len(labels))
for i := range labels {
array[i] = ParseLabel(labels[i])
}
return array.Sort()
} | go | func ParseLabelArray(labels ...string) LabelArray {
array := make(LabelArray, len(labels))
for i := range labels {
array[i] = ParseLabel(labels[i])
}
return array.Sort()
} | [
"func",
"ParseLabelArray",
"(",
"labels",
"...",
"string",
")",
"LabelArray",
"{",
"array",
":=",
"make",
"(",
"LabelArray",
",",
"len",
"(",
"labels",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"labels",
"{",
"array",
"[",
"i",
"]",
"=",
"ParseLabel",
"(",
"labels",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"return",
"array",
".",
"Sort",
"(",
")",
"\n",
"}"
] | // ParseLabelArray parses a list of labels and returns a LabelArray | [
"ParseLabelArray",
"parses",
"a",
"list",
"of",
"labels",
"and",
"returns",
"a",
"LabelArray"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/array.go#L36-L42 |
163,779 | cilium/cilium | pkg/labels/array.go | ParseSelectLabelArray | func ParseSelectLabelArray(labels ...string) LabelArray {
array := make(LabelArray, len(labels))
for i := range labels {
array[i] = ParseSelectLabel(labels[i])
}
return array.Sort()
} | go | func ParseSelectLabelArray(labels ...string) LabelArray {
array := make(LabelArray, len(labels))
for i := range labels {
array[i] = ParseSelectLabel(labels[i])
}
return array.Sort()
} | [
"func",
"ParseSelectLabelArray",
"(",
"labels",
"...",
"string",
")",
"LabelArray",
"{",
"array",
":=",
"make",
"(",
"LabelArray",
",",
"len",
"(",
"labels",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"labels",
"{",
"array",
"[",
"i",
"]",
"=",
"ParseSelectLabel",
"(",
"labels",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"return",
"array",
".",
"Sort",
"(",
")",
"\n",
"}"
] | // ParseSelectLabelArray parses a list of select labels and returns a LabelArray | [
"ParseSelectLabelArray",
"parses",
"a",
"list",
"of",
"select",
"labels",
"and",
"returns",
"a",
"LabelArray"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/array.go#L45-L51 |
163,780 | cilium/cilium | pkg/labels/array.go | ParseLabelArrayFromArray | func ParseLabelArrayFromArray(base []string) LabelArray {
array := make(LabelArray, len(base))
for i := range base {
array[i] = ParseLabel(base[i])
}
return array.Sort()
} | go | func ParseLabelArrayFromArray(base []string) LabelArray {
array := make(LabelArray, len(base))
for i := range base {
array[i] = ParseLabel(base[i])
}
return array.Sort()
} | [
"func",
"ParseLabelArrayFromArray",
"(",
"base",
"[",
"]",
"string",
")",
"LabelArray",
"{",
"array",
":=",
"make",
"(",
"LabelArray",
",",
"len",
"(",
"base",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"base",
"{",
"array",
"[",
"i",
"]",
"=",
"ParseLabel",
"(",
"base",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"return",
"array",
".",
"Sort",
"(",
")",
"\n",
"}"
] | // ParseLabelArrayFromArray converts an array of strings as labels and returns a LabelArray | [
"ParseLabelArrayFromArray",
"converts",
"an",
"array",
"of",
"strings",
"as",
"labels",
"and",
"returns",
"a",
"LabelArray"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/array.go#L54-L60 |
163,781 | cilium/cilium | pkg/labels/array.go | ParseSelectLabelArrayFromArray | func ParseSelectLabelArrayFromArray(base []string) LabelArray {
array := make(LabelArray, len(base))
for i := range base {
array[i] = ParseSelectLabel(base[i])
}
return array.Sort()
} | go | func ParseSelectLabelArrayFromArray(base []string) LabelArray {
array := make(LabelArray, len(base))
for i := range base {
array[i] = ParseSelectLabel(base[i])
}
return array.Sort()
} | [
"func",
"ParseSelectLabelArrayFromArray",
"(",
"base",
"[",
"]",
"string",
")",
"LabelArray",
"{",
"array",
":=",
"make",
"(",
"LabelArray",
",",
"len",
"(",
"base",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"base",
"{",
"array",
"[",
"i",
"]",
"=",
"ParseSelectLabel",
"(",
"base",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"return",
"array",
".",
"Sort",
"(",
")",
"\n",
"}"
] | // ParseSelectLabelArrayFromArray converts an array of strings as select labels and returns a LabelArray | [
"ParseSelectLabelArrayFromArray",
"converts",
"an",
"array",
"of",
"strings",
"as",
"select",
"labels",
"and",
"returns",
"a",
"LabelArray"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/array.go#L76-L82 |
163,782 | cilium/cilium | pkg/labels/array.go | Labels | func (ls LabelArray) Labels() Labels {
lbls := Labels{}
for _, l := range ls {
lbls[l.Key] = l
}
return lbls
} | go | func (ls LabelArray) Labels() Labels {
lbls := Labels{}
for _, l := range ls {
lbls[l.Key] = l
}
return lbls
} | [
"func",
"(",
"ls",
"LabelArray",
")",
"Labels",
"(",
")",
"Labels",
"{",
"lbls",
":=",
"Labels",
"{",
"}",
"\n",
"for",
"_",
",",
"l",
":=",
"range",
"ls",
"{",
"lbls",
"[",
"l",
".",
"Key",
"]",
"=",
"l",
"\n",
"}",
"\n",
"return",
"lbls",
"\n",
"}"
] | // Labels returns the LabelArray as Labels | [
"Labels",
"returns",
"the",
"LabelArray",
"as",
"Labels"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/array.go#L85-L91 |
163,783 | cilium/cilium | pkg/labels/array.go | Lacks | func (ls LabelArray) Lacks(needed LabelArray) LabelArray {
missing := LabelArray{}
nextLabel:
for i := range needed {
for l := range ls {
if needed[i].Matches(&ls[l]) {
continue nextLabel
}
}
missing = append(missing, needed[i])
}
return missing
} | go | func (ls LabelArray) Lacks(needed LabelArray) LabelArray {
missing := LabelArray{}
nextLabel:
for i := range needed {
for l := range ls {
if needed[i].Matches(&ls[l]) {
continue nextLabel
}
}
missing = append(missing, needed[i])
}
return missing
} | [
"func",
"(",
"ls",
"LabelArray",
")",
"Lacks",
"(",
"needed",
"LabelArray",
")",
"LabelArray",
"{",
"missing",
":=",
"LabelArray",
"{",
"}",
"\n",
"nextLabel",
":",
"for",
"i",
":=",
"range",
"needed",
"{",
"for",
"l",
":=",
"range",
"ls",
"{",
"if",
"needed",
"[",
"i",
"]",
".",
"Matches",
"(",
"&",
"ls",
"[",
"l",
"]",
")",
"{",
"continue",
"nextLabel",
"\n",
"}",
"\n",
"}",
"\n\n",
"missing",
"=",
"append",
"(",
"missing",
",",
"needed",
"[",
"i",
"]",
")",
"\n",
"}",
"\n\n",
"return",
"missing",
"\n",
"}"
] | // Lacks is identical to Contains but returns all missing labels | [
"Lacks",
"is",
"identical",
"to",
"Contains",
"but",
"returns",
"all",
"missing",
"labels"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/array.go#L111-L125 |
163,784 | cilium/cilium | pkg/labels/array.go | DeepCopy | func (ls LabelArray) DeepCopy() LabelArray {
if ls == nil {
return nil
}
o := make(LabelArray, len(ls), len(ls))
copy(o, ls)
return o
} | go | func (ls LabelArray) DeepCopy() LabelArray {
if ls == nil {
return nil
}
o := make(LabelArray, len(ls), len(ls))
copy(o, ls)
return o
} | [
"func",
"(",
"ls",
"LabelArray",
")",
"DeepCopy",
"(",
")",
"LabelArray",
"{",
"if",
"ls",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"o",
":=",
"make",
"(",
"LabelArray",
",",
"len",
"(",
"ls",
")",
",",
"len",
"(",
"ls",
")",
")",
"\n",
"copy",
"(",
"o",
",",
"ls",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // DeepCopy returns a deep copy of the labels. | [
"DeepCopy",
"returns",
"a",
"deep",
"copy",
"of",
"the",
"labels",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/array.go#L170-L178 |
163,785 | cilium/cilium | pkg/labels/array.go | GetModel | func (ls LabelArray) GetModel() []string {
res := []string{}
for l := range ls {
res = append(res, ls[l].String())
}
return res
} | go | func (ls LabelArray) GetModel() []string {
res := []string{}
for l := range ls {
res = append(res, ls[l].String())
}
return res
} | [
"func",
"(",
"ls",
"LabelArray",
")",
"GetModel",
"(",
")",
"[",
"]",
"string",
"{",
"res",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"l",
":=",
"range",
"ls",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"ls",
"[",
"l",
"]",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"res",
"\n",
"}"
] | // GetModel returns the LabelArray as a string array with fully-qualified labels.
// The output is parseable by ParseLabelArrayFromArray | [
"GetModel",
"returns",
"the",
"LabelArray",
"as",
"a",
"string",
"array",
"with",
"fully",
"-",
"qualified",
"labels",
".",
"The",
"output",
"is",
"parseable",
"by",
"ParseLabelArrayFromArray"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/array.go#L182-L188 |
163,786 | cilium/cilium | pkg/monitor/format/format.go | NewMonitorFormatter | func NewMonitorFormatter(verbosity Verbosity) *MonitorFormatter {
return &MonitorFormatter{
Hex: false,
EventTypes: monitorAPI.MessageTypeFilter{},
FromSource: Uint16Flags{},
ToDst: Uint16Flags{},
Related: Uint16Flags{},
Verbose: false,
JSONOutput: false,
Verbosity: verbosity,
}
} | go | func NewMonitorFormatter(verbosity Verbosity) *MonitorFormatter {
return &MonitorFormatter{
Hex: false,
EventTypes: monitorAPI.MessageTypeFilter{},
FromSource: Uint16Flags{},
ToDst: Uint16Flags{},
Related: Uint16Flags{},
Verbose: false,
JSONOutput: false,
Verbosity: verbosity,
}
} | [
"func",
"NewMonitorFormatter",
"(",
"verbosity",
"Verbosity",
")",
"*",
"MonitorFormatter",
"{",
"return",
"&",
"MonitorFormatter",
"{",
"Hex",
":",
"false",
",",
"EventTypes",
":",
"monitorAPI",
".",
"MessageTypeFilter",
"{",
"}",
",",
"FromSource",
":",
"Uint16Flags",
"{",
"}",
",",
"ToDst",
":",
"Uint16Flags",
"{",
"}",
",",
"Related",
":",
"Uint16Flags",
"{",
"}",
",",
"Verbose",
":",
"false",
",",
"JSONOutput",
":",
"false",
",",
"Verbosity",
":",
"verbosity",
",",
"}",
"\n",
"}"
] | // NewMonitorFormatter returns a new formatter with default configuration. | [
"NewMonitorFormatter",
"returns",
"a",
"new",
"formatter",
"with",
"default",
"configuration",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/format/format.go#L65-L76 |
163,787 | cilium/cilium | pkg/monitor/format/format.go | dropEvents | func (m *MonitorFormatter) dropEvents(prefix string, data []byte) {
dn := monitor.DropNotify{}
if err := binary.Read(bytes.NewReader(data), byteorder.Native, &dn); err != nil {
fmt.Printf("Error while parsing drop notification message: %s\n", err)
}
if m.match(monitorAPI.MessageTypeDrop, dn.Source, uint16(dn.DstID)) {
switch m.Verbosity {
case INFO:
dn.DumpInfo(data)
case JSON:
dn.DumpJSON(data, prefix)
default:
fmt.Println(msgSeparator)
dn.DumpVerbose(!m.Hex, data, prefix)
}
}
} | go | func (m *MonitorFormatter) dropEvents(prefix string, data []byte) {
dn := monitor.DropNotify{}
if err := binary.Read(bytes.NewReader(data), byteorder.Native, &dn); err != nil {
fmt.Printf("Error while parsing drop notification message: %s\n", err)
}
if m.match(monitorAPI.MessageTypeDrop, dn.Source, uint16(dn.DstID)) {
switch m.Verbosity {
case INFO:
dn.DumpInfo(data)
case JSON:
dn.DumpJSON(data, prefix)
default:
fmt.Println(msgSeparator)
dn.DumpVerbose(!m.Hex, data, prefix)
}
}
} | [
"func",
"(",
"m",
"*",
"MonitorFormatter",
")",
"dropEvents",
"(",
"prefix",
"string",
",",
"data",
"[",
"]",
"byte",
")",
"{",
"dn",
":=",
"monitor",
".",
"DropNotify",
"{",
"}",
"\n\n",
"if",
"err",
":=",
"binary",
".",
"Read",
"(",
"bytes",
".",
"NewReader",
"(",
"data",
")",
",",
"byteorder",
".",
"Native",
",",
"&",
"dn",
")",
";",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"m",
".",
"match",
"(",
"monitorAPI",
".",
"MessageTypeDrop",
",",
"dn",
".",
"Source",
",",
"uint16",
"(",
"dn",
".",
"DstID",
")",
")",
"{",
"switch",
"m",
".",
"Verbosity",
"{",
"case",
"INFO",
":",
"dn",
".",
"DumpInfo",
"(",
"data",
")",
"\n",
"case",
"JSON",
":",
"dn",
".",
"DumpJSON",
"(",
"data",
",",
"prefix",
")",
"\n",
"default",
":",
"fmt",
".",
"Println",
"(",
"msgSeparator",
")",
"\n",
"dn",
".",
"DumpVerbose",
"(",
"!",
"m",
".",
"Hex",
",",
"data",
",",
"prefix",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // dropEvents prints out all the received drop notifications. | [
"dropEvents",
"prints",
"out",
"all",
"the",
"received",
"drop",
"notifications",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/format/format.go#L97-L114 |
163,788 | cilium/cilium | pkg/monitor/format/format.go | traceEvents | func (m *MonitorFormatter) traceEvents(prefix string, data []byte) {
tn := monitor.TraceNotify{}
if err := binary.Read(bytes.NewReader(data), byteorder.Native, &tn); err != nil {
fmt.Printf("Error while parsing trace notification message: %s\n", err)
}
if m.match(monitorAPI.MessageTypeTrace, tn.Source, tn.DstID) {
switch m.Verbosity {
case INFO:
tn.DumpInfo(data)
case JSON:
tn.DumpJSON(data, prefix)
default:
fmt.Println(msgSeparator)
tn.DumpVerbose(!m.Hex, data, prefix)
}
}
} | go | func (m *MonitorFormatter) traceEvents(prefix string, data []byte) {
tn := monitor.TraceNotify{}
if err := binary.Read(bytes.NewReader(data), byteorder.Native, &tn); err != nil {
fmt.Printf("Error while parsing trace notification message: %s\n", err)
}
if m.match(monitorAPI.MessageTypeTrace, tn.Source, tn.DstID) {
switch m.Verbosity {
case INFO:
tn.DumpInfo(data)
case JSON:
tn.DumpJSON(data, prefix)
default:
fmt.Println(msgSeparator)
tn.DumpVerbose(!m.Hex, data, prefix)
}
}
} | [
"func",
"(",
"m",
"*",
"MonitorFormatter",
")",
"traceEvents",
"(",
"prefix",
"string",
",",
"data",
"[",
"]",
"byte",
")",
"{",
"tn",
":=",
"monitor",
".",
"TraceNotify",
"{",
"}",
"\n\n",
"if",
"err",
":=",
"binary",
".",
"Read",
"(",
"bytes",
".",
"NewReader",
"(",
"data",
")",
",",
"byteorder",
".",
"Native",
",",
"&",
"tn",
")",
";",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"m",
".",
"match",
"(",
"monitorAPI",
".",
"MessageTypeTrace",
",",
"tn",
".",
"Source",
",",
"tn",
".",
"DstID",
")",
"{",
"switch",
"m",
".",
"Verbosity",
"{",
"case",
"INFO",
":",
"tn",
".",
"DumpInfo",
"(",
"data",
")",
"\n",
"case",
"JSON",
":",
"tn",
".",
"DumpJSON",
"(",
"data",
",",
"prefix",
")",
"\n",
"default",
":",
"fmt",
".",
"Println",
"(",
"msgSeparator",
")",
"\n",
"tn",
".",
"DumpVerbose",
"(",
"!",
"m",
".",
"Hex",
",",
"data",
",",
"prefix",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // traceEvents prints out all the received trace notifications. | [
"traceEvents",
"prints",
"out",
"all",
"the",
"received",
"trace",
"notifications",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/format/format.go#L117-L134 |
163,789 | cilium/cilium | pkg/monitor/format/format.go | debugEvents | func (m *MonitorFormatter) debugEvents(prefix string, data []byte) {
dm := monitor.DebugMsg{}
if err := binary.Read(bytes.NewReader(data), byteorder.Native, &dm); err != nil {
fmt.Printf("Error while parsing debug message: %s\n", err)
}
if m.match(monitorAPI.MessageTypeDebug, dm.Source, 0) {
switch m.Verbosity {
case INFO:
dm.DumpInfo(data)
case JSON:
dm.DumpJSON(prefix)
default:
dm.Dump(prefix)
}
}
} | go | func (m *MonitorFormatter) debugEvents(prefix string, data []byte) {
dm := monitor.DebugMsg{}
if err := binary.Read(bytes.NewReader(data), byteorder.Native, &dm); err != nil {
fmt.Printf("Error while parsing debug message: %s\n", err)
}
if m.match(monitorAPI.MessageTypeDebug, dm.Source, 0) {
switch m.Verbosity {
case INFO:
dm.DumpInfo(data)
case JSON:
dm.DumpJSON(prefix)
default:
dm.Dump(prefix)
}
}
} | [
"func",
"(",
"m",
"*",
"MonitorFormatter",
")",
"debugEvents",
"(",
"prefix",
"string",
",",
"data",
"[",
"]",
"byte",
")",
"{",
"dm",
":=",
"monitor",
".",
"DebugMsg",
"{",
"}",
"\n\n",
"if",
"err",
":=",
"binary",
".",
"Read",
"(",
"bytes",
".",
"NewReader",
"(",
"data",
")",
",",
"byteorder",
".",
"Native",
",",
"&",
"dm",
")",
";",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"m",
".",
"match",
"(",
"monitorAPI",
".",
"MessageTypeDebug",
",",
"dm",
".",
"Source",
",",
"0",
")",
"{",
"switch",
"m",
".",
"Verbosity",
"{",
"case",
"INFO",
":",
"dm",
".",
"DumpInfo",
"(",
"data",
")",
"\n",
"case",
"JSON",
":",
"dm",
".",
"DumpJSON",
"(",
"prefix",
")",
"\n",
"default",
":",
"dm",
".",
"Dump",
"(",
"prefix",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // debugEvents prints out all the debug messages. | [
"debugEvents",
"prints",
"out",
"all",
"the",
"debug",
"messages",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/format/format.go#L137-L153 |
163,790 | cilium/cilium | pkg/monitor/format/format.go | captureEvents | func (m *MonitorFormatter) captureEvents(prefix string, data []byte) {
dc := monitor.DebugCapture{}
if err := binary.Read(bytes.NewReader(data), byteorder.Native, &dc); err != nil {
fmt.Printf("Error while parsing debug capture message: %s\n", err)
}
if m.match(monitorAPI.MessageTypeCapture, dc.Source, 0) {
switch m.Verbosity {
case INFO:
dc.DumpInfo(data)
case JSON:
dc.DumpJSON(data, prefix)
default:
fmt.Println(msgSeparator)
dc.DumpVerbose(!m.Hex, data, prefix)
}
}
} | go | func (m *MonitorFormatter) captureEvents(prefix string, data []byte) {
dc := monitor.DebugCapture{}
if err := binary.Read(bytes.NewReader(data), byteorder.Native, &dc); err != nil {
fmt.Printf("Error while parsing debug capture message: %s\n", err)
}
if m.match(monitorAPI.MessageTypeCapture, dc.Source, 0) {
switch m.Verbosity {
case INFO:
dc.DumpInfo(data)
case JSON:
dc.DumpJSON(data, prefix)
default:
fmt.Println(msgSeparator)
dc.DumpVerbose(!m.Hex, data, prefix)
}
}
} | [
"func",
"(",
"m",
"*",
"MonitorFormatter",
")",
"captureEvents",
"(",
"prefix",
"string",
",",
"data",
"[",
"]",
"byte",
")",
"{",
"dc",
":=",
"monitor",
".",
"DebugCapture",
"{",
"}",
"\n\n",
"if",
"err",
":=",
"binary",
".",
"Read",
"(",
"bytes",
".",
"NewReader",
"(",
"data",
")",
",",
"byteorder",
".",
"Native",
",",
"&",
"dc",
")",
";",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"m",
".",
"match",
"(",
"monitorAPI",
".",
"MessageTypeCapture",
",",
"dc",
".",
"Source",
",",
"0",
")",
"{",
"switch",
"m",
".",
"Verbosity",
"{",
"case",
"INFO",
":",
"dc",
".",
"DumpInfo",
"(",
"data",
")",
"\n",
"case",
"JSON",
":",
"dc",
".",
"DumpJSON",
"(",
"data",
",",
"prefix",
")",
"\n",
"default",
":",
"fmt",
".",
"Println",
"(",
"msgSeparator",
")",
"\n",
"dc",
".",
"DumpVerbose",
"(",
"!",
"m",
".",
"Hex",
",",
"data",
",",
"prefix",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // captureEvents prints out all the capture messages. | [
"captureEvents",
"prints",
"out",
"all",
"the",
"capture",
"messages",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/format/format.go#L156-L173 |
163,791 | cilium/cilium | pkg/monitor/format/format.go | logRecordEvents | func (m *MonitorFormatter) logRecordEvents(prefix string, data []byte) {
buf := bytes.NewBuffer(data[1:])
dec := gob.NewDecoder(buf)
lr := monitor.LogRecordNotify{}
if err := dec.Decode(&lr); err != nil {
fmt.Printf("Error while decoding LogRecord notification message: %s\n", err)
}
if m.match(monitorAPI.MessageTypeAccessLog, uint16(lr.SourceEndpoint.ID), uint16(lr.DestinationEndpoint.ID)) {
if m.Verbosity == JSON {
lr.DumpJSON()
} else {
lr.DumpInfo()
}
}
} | go | func (m *MonitorFormatter) logRecordEvents(prefix string, data []byte) {
buf := bytes.NewBuffer(data[1:])
dec := gob.NewDecoder(buf)
lr := monitor.LogRecordNotify{}
if err := dec.Decode(&lr); err != nil {
fmt.Printf("Error while decoding LogRecord notification message: %s\n", err)
}
if m.match(monitorAPI.MessageTypeAccessLog, uint16(lr.SourceEndpoint.ID), uint16(lr.DestinationEndpoint.ID)) {
if m.Verbosity == JSON {
lr.DumpJSON()
} else {
lr.DumpInfo()
}
}
} | [
"func",
"(",
"m",
"*",
"MonitorFormatter",
")",
"logRecordEvents",
"(",
"prefix",
"string",
",",
"data",
"[",
"]",
"byte",
")",
"{",
"buf",
":=",
"bytes",
".",
"NewBuffer",
"(",
"data",
"[",
"1",
":",
"]",
")",
"\n",
"dec",
":=",
"gob",
".",
"NewDecoder",
"(",
"buf",
")",
"\n\n",
"lr",
":=",
"monitor",
".",
"LogRecordNotify",
"{",
"}",
"\n",
"if",
"err",
":=",
"dec",
".",
"Decode",
"(",
"&",
"lr",
")",
";",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"m",
".",
"match",
"(",
"monitorAPI",
".",
"MessageTypeAccessLog",
",",
"uint16",
"(",
"lr",
".",
"SourceEndpoint",
".",
"ID",
")",
",",
"uint16",
"(",
"lr",
".",
"DestinationEndpoint",
".",
"ID",
")",
")",
"{",
"if",
"m",
".",
"Verbosity",
"==",
"JSON",
"{",
"lr",
".",
"DumpJSON",
"(",
")",
"\n",
"}",
"else",
"{",
"lr",
".",
"DumpInfo",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // logRecordEvents prints out LogRecord events | [
"logRecordEvents",
"prints",
"out",
"LogRecord",
"events"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/format/format.go#L176-L192 |
163,792 | cilium/cilium | pkg/monitor/format/format.go | agentEvents | func (m *MonitorFormatter) agentEvents(prefix string, data []byte) {
buf := bytes.NewBuffer(data[1:])
dec := gob.NewDecoder(buf)
an := monitorAPI.AgentNotify{}
if err := dec.Decode(&an); err != nil {
fmt.Printf("Error while decoding agent notification message: %s\n", err)
}
if m.match(monitorAPI.MessageTypeAgent, 0, 0) {
if m.Verbosity == JSON {
an.DumpJSON()
} else {
an.DumpInfo()
}
}
} | go | func (m *MonitorFormatter) agentEvents(prefix string, data []byte) {
buf := bytes.NewBuffer(data[1:])
dec := gob.NewDecoder(buf)
an := monitorAPI.AgentNotify{}
if err := dec.Decode(&an); err != nil {
fmt.Printf("Error while decoding agent notification message: %s\n", err)
}
if m.match(monitorAPI.MessageTypeAgent, 0, 0) {
if m.Verbosity == JSON {
an.DumpJSON()
} else {
an.DumpInfo()
}
}
} | [
"func",
"(",
"m",
"*",
"MonitorFormatter",
")",
"agentEvents",
"(",
"prefix",
"string",
",",
"data",
"[",
"]",
"byte",
")",
"{",
"buf",
":=",
"bytes",
".",
"NewBuffer",
"(",
"data",
"[",
"1",
":",
"]",
")",
"\n",
"dec",
":=",
"gob",
".",
"NewDecoder",
"(",
"buf",
")",
"\n\n",
"an",
":=",
"monitorAPI",
".",
"AgentNotify",
"{",
"}",
"\n",
"if",
"err",
":=",
"dec",
".",
"Decode",
"(",
"&",
"an",
")",
";",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"m",
".",
"match",
"(",
"monitorAPI",
".",
"MessageTypeAgent",
",",
"0",
",",
"0",
")",
"{",
"if",
"m",
".",
"Verbosity",
"==",
"JSON",
"{",
"an",
".",
"DumpJSON",
"(",
")",
"\n",
"}",
"else",
"{",
"an",
".",
"DumpInfo",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // agentEvents prints out agent events | [
"agentEvents",
"prints",
"out",
"agent",
"events"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/format/format.go#L195-L211 |
163,793 | cilium/cilium | pkg/monitor/format/format.go | FormatSample | func (m *MonitorFormatter) FormatSample(data []byte, cpu int) {
prefix := fmt.Sprintf("CPU %02d:", cpu)
messageType := data[0]
switch messageType {
case monitorAPI.MessageTypeDrop:
m.dropEvents(prefix, data)
case monitorAPI.MessageTypeDebug:
m.debugEvents(prefix, data)
case monitorAPI.MessageTypeCapture:
m.captureEvents(prefix, data)
case monitorAPI.MessageTypeTrace:
m.traceEvents(prefix, data)
case monitorAPI.MessageTypeAccessLog:
m.logRecordEvents(prefix, data)
case monitorAPI.MessageTypeAgent:
m.agentEvents(prefix, data)
default:
fmt.Printf("%s Unknown event: %+v\n", prefix, data)
}
} | go | func (m *MonitorFormatter) FormatSample(data []byte, cpu int) {
prefix := fmt.Sprintf("CPU %02d:", cpu)
messageType := data[0]
switch messageType {
case monitorAPI.MessageTypeDrop:
m.dropEvents(prefix, data)
case monitorAPI.MessageTypeDebug:
m.debugEvents(prefix, data)
case monitorAPI.MessageTypeCapture:
m.captureEvents(prefix, data)
case monitorAPI.MessageTypeTrace:
m.traceEvents(prefix, data)
case monitorAPI.MessageTypeAccessLog:
m.logRecordEvents(prefix, data)
case monitorAPI.MessageTypeAgent:
m.agentEvents(prefix, data)
default:
fmt.Printf("%s Unknown event: %+v\n", prefix, data)
}
} | [
"func",
"(",
"m",
"*",
"MonitorFormatter",
")",
"FormatSample",
"(",
"data",
"[",
"]",
"byte",
",",
"cpu",
"int",
")",
"{",
"prefix",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"cpu",
")",
"\n",
"messageType",
":=",
"data",
"[",
"0",
"]",
"\n\n",
"switch",
"messageType",
"{",
"case",
"monitorAPI",
".",
"MessageTypeDrop",
":",
"m",
".",
"dropEvents",
"(",
"prefix",
",",
"data",
")",
"\n",
"case",
"monitorAPI",
".",
"MessageTypeDebug",
":",
"m",
".",
"debugEvents",
"(",
"prefix",
",",
"data",
")",
"\n",
"case",
"monitorAPI",
".",
"MessageTypeCapture",
":",
"m",
".",
"captureEvents",
"(",
"prefix",
",",
"data",
")",
"\n",
"case",
"monitorAPI",
".",
"MessageTypeTrace",
":",
"m",
".",
"traceEvents",
"(",
"prefix",
",",
"data",
")",
"\n",
"case",
"monitorAPI",
".",
"MessageTypeAccessLog",
":",
"m",
".",
"logRecordEvents",
"(",
"prefix",
",",
"data",
")",
"\n",
"case",
"monitorAPI",
".",
"MessageTypeAgent",
":",
"m",
".",
"agentEvents",
"(",
"prefix",
",",
"data",
")",
"\n",
"default",
":",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"prefix",
",",
"data",
")",
"\n",
"}",
"\n",
"}"
] | // FormatSample prints an event from the provided raw data slice to stdout.
//
// For most monitor event types, 'data' corresponds to the 'data' field in
// bpf.PerfEventSample. Exceptions are MessageTypeAccessLog and
// MessageTypeAgent. | [
"FormatSample",
"prints",
"an",
"event",
"from",
"the",
"provided",
"raw",
"data",
"slice",
"to",
"stdout",
".",
"For",
"most",
"monitor",
"event",
"types",
"data",
"corresponds",
"to",
"the",
"data",
"field",
"in",
"bpf",
".",
"PerfEventSample",
".",
"Exceptions",
"are",
"MessageTypeAccessLog",
"and",
"MessageTypeAgent",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/format/format.go#L218-L238 |
163,794 | cilium/cilium | pkg/monitor/format/format.go | FormatEvent | func (m *MonitorFormatter) FormatEvent(pl *payload.Payload) bool {
switch pl.Type {
case payload.EventSample:
m.FormatSample(pl.Data, pl.CPU)
case payload.RecordLost:
LostEvent(pl.Lost, pl.CPU)
default:
return false
}
return true
} | go | func (m *MonitorFormatter) FormatEvent(pl *payload.Payload) bool {
switch pl.Type {
case payload.EventSample:
m.FormatSample(pl.Data, pl.CPU)
case payload.RecordLost:
LostEvent(pl.Lost, pl.CPU)
default:
return false
}
return true
} | [
"func",
"(",
"m",
"*",
"MonitorFormatter",
")",
"FormatEvent",
"(",
"pl",
"*",
"payload",
".",
"Payload",
")",
"bool",
"{",
"switch",
"pl",
".",
"Type",
"{",
"case",
"payload",
".",
"EventSample",
":",
"m",
".",
"FormatSample",
"(",
"pl",
".",
"Data",
",",
"pl",
".",
"CPU",
")",
"\n",
"case",
"payload",
".",
"RecordLost",
":",
"LostEvent",
"(",
"pl",
".",
"Lost",
",",
"pl",
".",
"CPU",
")",
"\n",
"default",
":",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"true",
"\n",
"}"
] | // FormatEvent formats an event from the specified payload to stdout.
//
// Returns true if the event was successfully printed, false otherwise. | [
"FormatEvent",
"formats",
"an",
"event",
"from",
"the",
"specified",
"payload",
"to",
"stdout",
".",
"Returns",
"true",
"if",
"the",
"event",
"was",
"successfully",
"printed",
"false",
"otherwise",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/format/format.go#L248-L259 |
163,795 | cilium/cilium | pkg/policy/groups/helpers.go | createDerivativeCNP | func createDerivativeCNP(cnp *cilium_v2.CiliumNetworkPolicy) (*cilium_v2.CiliumNetworkPolicy, error) {
// CNP informer may provide a CNP object without APIVersion or Kind.
// Setting manually to make sure that the derivative policy works ok.
derivativeCNP := &cilium_v2.CiliumNetworkPolicy{
ObjectMeta: v1.ObjectMeta{
Name: getDerivativeName(cnp),
Namespace: cnp.ObjectMeta.Namespace,
OwnerReferences: []v1.OwnerReference{{
APIVersion: cilium_v2.SchemeGroupVersion.String(),
Kind: cilium_v2.CNPKindDefinition,
Name: cnp.ObjectMeta.Name,
UID: cnp.ObjectMeta.UID,
BlockOwnerDeletion: &blockOwnerDeletionPtr,
}},
Labels: map[string]string{
parentCNP: string(cnp.ObjectMeta.UID),
cnpKindKey: cnpKindName,
},
},
}
rules, err := cnp.Parse()
if err != nil {
return nil, fmt.Errorf("Cannot parse policies: %s", err)
}
derivativeCNP.Specs = make(api.Rules, len(rules))
for i, rule := range rules {
if rule.RequiresDerivative() {
derivativeCNP.Specs[i] = denyEgressRule()
}
}
for i, rule := range rules {
if !rule.RequiresDerivative() {
derivativeCNP.Specs[i] = rule
continue
}
newRule, err := rule.CreateDerivative()
if err != nil {
return derivativeCNP, err
}
derivativeCNP.Specs[i] = newRule
}
return derivativeCNP, nil
} | go | func createDerivativeCNP(cnp *cilium_v2.CiliumNetworkPolicy) (*cilium_v2.CiliumNetworkPolicy, error) {
// CNP informer may provide a CNP object without APIVersion or Kind.
// Setting manually to make sure that the derivative policy works ok.
derivativeCNP := &cilium_v2.CiliumNetworkPolicy{
ObjectMeta: v1.ObjectMeta{
Name: getDerivativeName(cnp),
Namespace: cnp.ObjectMeta.Namespace,
OwnerReferences: []v1.OwnerReference{{
APIVersion: cilium_v2.SchemeGroupVersion.String(),
Kind: cilium_v2.CNPKindDefinition,
Name: cnp.ObjectMeta.Name,
UID: cnp.ObjectMeta.UID,
BlockOwnerDeletion: &blockOwnerDeletionPtr,
}},
Labels: map[string]string{
parentCNP: string(cnp.ObjectMeta.UID),
cnpKindKey: cnpKindName,
},
},
}
rules, err := cnp.Parse()
if err != nil {
return nil, fmt.Errorf("Cannot parse policies: %s", err)
}
derivativeCNP.Specs = make(api.Rules, len(rules))
for i, rule := range rules {
if rule.RequiresDerivative() {
derivativeCNP.Specs[i] = denyEgressRule()
}
}
for i, rule := range rules {
if !rule.RequiresDerivative() {
derivativeCNP.Specs[i] = rule
continue
}
newRule, err := rule.CreateDerivative()
if err != nil {
return derivativeCNP, err
}
derivativeCNP.Specs[i] = newRule
}
return derivativeCNP, nil
} | [
"func",
"createDerivativeCNP",
"(",
"cnp",
"*",
"cilium_v2",
".",
"CiliumNetworkPolicy",
")",
"(",
"*",
"cilium_v2",
".",
"CiliumNetworkPolicy",
",",
"error",
")",
"{",
"// CNP informer may provide a CNP object without APIVersion or Kind.",
"// Setting manually to make sure that the derivative policy works ok.",
"derivativeCNP",
":=",
"&",
"cilium_v2",
".",
"CiliumNetworkPolicy",
"{",
"ObjectMeta",
":",
"v1",
".",
"ObjectMeta",
"{",
"Name",
":",
"getDerivativeName",
"(",
"cnp",
")",
",",
"Namespace",
":",
"cnp",
".",
"ObjectMeta",
".",
"Namespace",
",",
"OwnerReferences",
":",
"[",
"]",
"v1",
".",
"OwnerReference",
"{",
"{",
"APIVersion",
":",
"cilium_v2",
".",
"SchemeGroupVersion",
".",
"String",
"(",
")",
",",
"Kind",
":",
"cilium_v2",
".",
"CNPKindDefinition",
",",
"Name",
":",
"cnp",
".",
"ObjectMeta",
".",
"Name",
",",
"UID",
":",
"cnp",
".",
"ObjectMeta",
".",
"UID",
",",
"BlockOwnerDeletion",
":",
"&",
"blockOwnerDeletionPtr",
",",
"}",
"}",
",",
"Labels",
":",
"map",
"[",
"string",
"]",
"string",
"{",
"parentCNP",
":",
"string",
"(",
"cnp",
".",
"ObjectMeta",
".",
"UID",
")",
",",
"cnpKindKey",
":",
"cnpKindName",
",",
"}",
",",
"}",
",",
"}",
"\n\n",
"rules",
",",
"err",
":=",
"cnp",
".",
"Parse",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"derivativeCNP",
".",
"Specs",
"=",
"make",
"(",
"api",
".",
"Rules",
",",
"len",
"(",
"rules",
")",
")",
"\n",
"for",
"i",
",",
"rule",
":=",
"range",
"rules",
"{",
"if",
"rule",
".",
"RequiresDerivative",
"(",
")",
"{",
"derivativeCNP",
".",
"Specs",
"[",
"i",
"]",
"=",
"denyEgressRule",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"i",
",",
"rule",
":=",
"range",
"rules",
"{",
"if",
"!",
"rule",
".",
"RequiresDerivative",
"(",
")",
"{",
"derivativeCNP",
".",
"Specs",
"[",
"i",
"]",
"=",
"rule",
"\n",
"continue",
"\n",
"}",
"\n",
"newRule",
",",
"err",
":=",
"rule",
".",
"CreateDerivative",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"derivativeCNP",
",",
"err",
"\n",
"}",
"\n",
"derivativeCNP",
".",
"Specs",
"[",
"i",
"]",
"=",
"newRule",
"\n",
"}",
"\n",
"return",
"derivativeCNP",
",",
"nil",
"\n",
"}"
] | // createDerivativeCNP will return a new CNP based on the given rule. | [
"createDerivativeCNP",
"will",
"return",
"a",
"new",
"CNP",
"based",
"on",
"the",
"given",
"rule",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/groups/helpers.go#L45-L90 |
163,796 | cilium/cilium | api/v1/server/restapi/ipam/post_ip_a_m.go | NewPostIPAM | func NewPostIPAM(ctx *middleware.Context, handler PostIPAMHandler) *PostIPAM {
return &PostIPAM{Context: ctx, Handler: handler}
} | go | func NewPostIPAM(ctx *middleware.Context, handler PostIPAMHandler) *PostIPAM {
return &PostIPAM{Context: ctx, Handler: handler}
} | [
"func",
"NewPostIPAM",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"PostIPAMHandler",
")",
"*",
"PostIPAM",
"{",
"return",
"&",
"PostIPAM",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewPostIPAM creates a new http.Handler for the post IP a m operation | [
"NewPostIPAM",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"post",
"IP",
"a",
"m",
"operation"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/ipam/post_ip_a_m.go#L28-L30 |
163,797 | cilium/cilium | pkg/labels/model/model.go | NewOplabelsFromModel | func NewOplabelsFromModel(base *models.LabelConfigurationStatus) *labels.OpLabels {
if base == nil {
return nil
}
return &labels.OpLabels{
Custom: labels.NewLabelsFromModel(base.Realized.User),
Disabled: labels.NewLabelsFromModel(base.Disabled),
OrchestrationIdentity: labels.NewLabelsFromModel(base.SecurityRelevant),
OrchestrationInfo: labels.NewLabelsFromModel(base.Derived),
}
} | go | func NewOplabelsFromModel(base *models.LabelConfigurationStatus) *labels.OpLabels {
if base == nil {
return nil
}
return &labels.OpLabels{
Custom: labels.NewLabelsFromModel(base.Realized.User),
Disabled: labels.NewLabelsFromModel(base.Disabled),
OrchestrationIdentity: labels.NewLabelsFromModel(base.SecurityRelevant),
OrchestrationInfo: labels.NewLabelsFromModel(base.Derived),
}
} | [
"func",
"NewOplabelsFromModel",
"(",
"base",
"*",
"models",
".",
"LabelConfigurationStatus",
")",
"*",
"labels",
".",
"OpLabels",
"{",
"if",
"base",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"&",
"labels",
".",
"OpLabels",
"{",
"Custom",
":",
"labels",
".",
"NewLabelsFromModel",
"(",
"base",
".",
"Realized",
".",
"User",
")",
",",
"Disabled",
":",
"labels",
".",
"NewLabelsFromModel",
"(",
"base",
".",
"Disabled",
")",
",",
"OrchestrationIdentity",
":",
"labels",
".",
"NewLabelsFromModel",
"(",
"base",
".",
"SecurityRelevant",
")",
",",
"OrchestrationInfo",
":",
"labels",
".",
"NewLabelsFromModel",
"(",
"base",
".",
"Derived",
")",
",",
"}",
"\n",
"}"
] | // NewOplabelsFromModel creates new label from the model. | [
"NewOplabelsFromModel",
"creates",
"new",
"label",
"from",
"the",
"model",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/model/model.go#L23-L34 |
163,798 | cilium/cilium | pkg/identity/identity.go | GetLabelsSHA256 | func (id *Identity) GetLabelsSHA256() string {
if id.LabelsSHA256 == "" {
id.LabelsSHA256 = id.Labels.SHA256Sum()
}
return id.LabelsSHA256
} | go | func (id *Identity) GetLabelsSHA256() string {
if id.LabelsSHA256 == "" {
id.LabelsSHA256 = id.Labels.SHA256Sum()
}
return id.LabelsSHA256
} | [
"func",
"(",
"id",
"*",
"Identity",
")",
"GetLabelsSHA256",
"(",
")",
"string",
"{",
"if",
"id",
".",
"LabelsSHA256",
"==",
"\"",
"\"",
"{",
"id",
".",
"LabelsSHA256",
"=",
"id",
".",
"Labels",
".",
"SHA256Sum",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"id",
".",
"LabelsSHA256",
"\n",
"}"
] | // GetLabelsSHA256 returns the SHA256 of the labels associated with the
// identity. The SHA is calculated if not already cached. | [
"GetLabelsSHA256",
"returns",
"the",
"SHA256",
"of",
"the",
"labels",
"associated",
"with",
"the",
"identity",
".",
"The",
"SHA",
"is",
"calculated",
"if",
"not",
"already",
"cached",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/identity.go#L99-L105 |
163,799 | cilium/cilium | pkg/identity/identity.go | NewIdentityFromLabelArray | func NewIdentityFromLabelArray(id NumericIdentity, lblArray labels.LabelArray) *Identity {
var lbls labels.Labels
if lblArray != nil {
lbls = lblArray.Labels()
}
return &Identity{ID: id, Labels: lbls, LabelArray: lblArray}
} | go | func NewIdentityFromLabelArray(id NumericIdentity, lblArray labels.LabelArray) *Identity {
var lbls labels.Labels
if lblArray != nil {
lbls = lblArray.Labels()
}
return &Identity{ID: id, Labels: lbls, LabelArray: lblArray}
} | [
"func",
"NewIdentityFromLabelArray",
"(",
"id",
"NumericIdentity",
",",
"lblArray",
"labels",
".",
"LabelArray",
")",
"*",
"Identity",
"{",
"var",
"lbls",
"labels",
".",
"Labels",
"\n\n",
"if",
"lblArray",
"!=",
"nil",
"{",
"lbls",
"=",
"lblArray",
".",
"Labels",
"(",
")",
"\n",
"}",
"\n",
"return",
"&",
"Identity",
"{",
"ID",
":",
"id",
",",
"Labels",
":",
"lbls",
",",
"LabelArray",
":",
"lblArray",
"}",
"\n",
"}"
] | // NewIdentityFromLabelArray creates a new identity | [
"NewIdentityFromLabelArray",
"creates",
"a",
"new",
"identity"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/identity.go#L149-L156 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.