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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
163,900 | cilium/cilium | api/v1/models/daemon_configuration_spec.go | Validate | func (m *DaemonConfigurationSpec) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateOptions(formats); err != nil {
res = append(res, err)
}
if err := m.validatePolicyEnforcement(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *DaemonConfigurationSpec) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateOptions(formats); err != nil {
res = append(res, err)
}
if err := m.validatePolicyEnforcement(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"DaemonConfigurationSpec",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateOptions",
"(",
"formats",
")",
";",
"err",
"... | // Validate validates this daemon configuration spec | [
"Validate",
"validates",
"this",
"daemon",
"configuration",
"spec"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/daemon_configuration_spec.go#L31-L46 |
163,901 | cilium/cilium | pkg/datapath/loader/netlink.go | replaceDatapath | func replaceDatapath(ctx context.Context, ifName string, objPath string, progSec string) error {
err := replaceQdisc(ifName)
if err != nil {
return fmt.Errorf("Failed to replace Qdisc for %s: %s", ifName, err)
}
// FIXME: Replace cilium-map-migrate with Golang map migration
cmd := exec.CommandContext(ctx, "cilium-map-migrate", "-s", objPath)
cmd.Env = bpf.Environment()
if _, err = cmd.CombinedOutput(log, true); err != nil {
return err
}
defer func() {
var retCode string
if err == nil {
retCode = "0"
} else {
retCode = "1"
}
args := []string{"-e", objPath, "-r", retCode}
cmd := exec.CommandContext(ctx, "cilium-map-migrate", args...)
cmd.Env = bpf.Environment()
_, _ = cmd.CombinedOutput(log, true) // ignore errors
}()
// FIXME: replace exec with native call
args := []string{"filter", "replace", "dev", ifName, "ingress",
"prio", "1", "handle", "1", "bpf", "da", "obj", objPath,
"sec", progSec,
}
cmd = exec.CommandContext(ctx, "tc", args...).WithFilters(libbpfFixupMsg)
_, err = cmd.CombinedOutput(log, true)
if err != nil {
return fmt.Errorf("Failed to load tc filter: %s", err)
}
return nil
} | go | func replaceDatapath(ctx context.Context, ifName string, objPath string, progSec string) error {
err := replaceQdisc(ifName)
if err != nil {
return fmt.Errorf("Failed to replace Qdisc for %s: %s", ifName, err)
}
// FIXME: Replace cilium-map-migrate with Golang map migration
cmd := exec.CommandContext(ctx, "cilium-map-migrate", "-s", objPath)
cmd.Env = bpf.Environment()
if _, err = cmd.CombinedOutput(log, true); err != nil {
return err
}
defer func() {
var retCode string
if err == nil {
retCode = "0"
} else {
retCode = "1"
}
args := []string{"-e", objPath, "-r", retCode}
cmd := exec.CommandContext(ctx, "cilium-map-migrate", args...)
cmd.Env = bpf.Environment()
_, _ = cmd.CombinedOutput(log, true) // ignore errors
}()
// FIXME: replace exec with native call
args := []string{"filter", "replace", "dev", ifName, "ingress",
"prio", "1", "handle", "1", "bpf", "da", "obj", objPath,
"sec", progSec,
}
cmd = exec.CommandContext(ctx, "tc", args...).WithFilters(libbpfFixupMsg)
_, err = cmd.CombinedOutput(log, true)
if err != nil {
return fmt.Errorf("Failed to load tc filter: %s", err)
}
return nil
} | [
"func",
"replaceDatapath",
"(",
"ctx",
"context",
".",
"Context",
",",
"ifName",
"string",
",",
"objPath",
"string",
",",
"progSec",
"string",
")",
"error",
"{",
"err",
":=",
"replaceQdisc",
"(",
"ifName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retur... | // replaceDatapath the qdisc and BPF program for a endpoint | [
"replaceDatapath",
"the",
"qdisc",
"and",
"BPF",
"program",
"for",
"a",
"endpoint"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/netlink.go#L57-L94 |
163,902 | cilium/cilium | pkg/datapath/loader/netlink.go | DeleteDatapath | func DeleteDatapath(ctx context.Context, ifName, direction string) error {
args := []string{"filter", "delete", "dev", ifName, direction, "pref", "1", "handle", "1", "bpf"}
cmd := exec.CommandContext(ctx, "tc", args...).WithFilters(libbpfFixupMsg)
_, err := cmd.CombinedOutput(log, true)
if err != nil {
return fmt.Errorf("Failed to remove tc filter: %s", err)
}
return nil
} | go | func DeleteDatapath(ctx context.Context, ifName, direction string) error {
args := []string{"filter", "delete", "dev", ifName, direction, "pref", "1", "handle", "1", "bpf"}
cmd := exec.CommandContext(ctx, "tc", args...).WithFilters(libbpfFixupMsg)
_, err := cmd.CombinedOutput(log, true)
if err != nil {
return fmt.Errorf("Failed to remove tc filter: %s", err)
}
return nil
} | [
"func",
"DeleteDatapath",
"(",
"ctx",
"context",
".",
"Context",
",",
"ifName",
",",
"direction",
"string",
")",
"error",
"{",
"args",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"ifName",
",",
"direction",
",",
... | // DeleteDatapath filter from the given ifName | [
"DeleteDatapath",
"filter",
"from",
"the",
"given",
"ifName"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/netlink.go#L134-L143 |
163,903 | cilium/cilium | pkg/policy/api/kafka.go | CheckAPIKeyRole | func (kr *PortRuleKafka) CheckAPIKeyRole(kind int16) bool {
// wildcard expression
if len(kr.apiKeyInt) == 0 {
return true
}
// Check kind
for _, apiKey := range kr.apiKeyInt {
if apiKey == kind {
return true
}
}
return false
} | go | func (kr *PortRuleKafka) CheckAPIKeyRole(kind int16) bool {
// wildcard expression
if len(kr.apiKeyInt) == 0 {
return true
}
// Check kind
for _, apiKey := range kr.apiKeyInt {
if apiKey == kind {
return true
}
}
return false
} | [
"func",
"(",
"kr",
"*",
"PortRuleKafka",
")",
"CheckAPIKeyRole",
"(",
"kind",
"int16",
")",
"bool",
"{",
"// wildcard expression",
"if",
"len",
"(",
"kr",
".",
"apiKeyInt",
")",
"==",
"0",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"// Check kind",
"for",
... | // CheckAPIKeyRole checks the apiKey value in the request, and returns true if
// it is allowed else false | [
"CheckAPIKeyRole",
"checks",
"the",
"apiKey",
"value",
"in",
"the",
"request",
"and",
"returns",
"true",
"if",
"it",
"is",
"allowed",
"else",
"false"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/kafka.go#L248-L261 |
163,904 | cilium/cilium | pkg/policy/api/kafka.go | GetAPIVersion | func (kr *PortRuleKafka) GetAPIVersion() (int16, bool) {
if kr.apiVersionInt == nil {
return 0, true
}
return *kr.apiVersionInt, false
} | go | func (kr *PortRuleKafka) GetAPIVersion() (int16, bool) {
if kr.apiVersionInt == nil {
return 0, true
}
return *kr.apiVersionInt, false
} | [
"func",
"(",
"kr",
"*",
"PortRuleKafka",
")",
"GetAPIVersion",
"(",
")",
"(",
"int16",
",",
"bool",
")",
"{",
"if",
"kr",
".",
"apiVersionInt",
"==",
"nil",
"{",
"return",
"0",
",",
"true",
"\n",
"}",
"\n\n",
"return",
"*",
"kr",
".",
"apiVersionInt"... | // GetAPIVersion returns the APIVersion as integer or the bool set to true if
// any API version is allowed | [
"GetAPIVersion",
"returns",
"the",
"APIVersion",
"as",
"integer",
"or",
"the",
"bool",
"set",
"to",
"true",
"if",
"any",
"API",
"version",
"is",
"allowed"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/kafka.go#L265-L271 |
163,905 | cilium/cilium | pkg/policy/api/kafka.go | MapRoleToAPIKey | func (kr *PortRuleKafka) MapRoleToAPIKey() error {
// Expand the kr.apiKeyInt array based on the Role.
// For produce role, we need to add mandatory apiKeys produce, metadata and
// apiversions. While for consume, we need to add mandatory apiKeys like
// fetch, offsets, offsetcommit, offsetfetch, apiversions, metadata,
// findcoordinator, joingroup, heartbeat,
// leavegroup and syncgroup.
switch strings.ToLower(kr.Role) {
case ProduceRole:
kr.apiKeyInt = KafkaRole{ProduceKey, MetadataKey, APIVersionsKey}
return nil
case ConsumeRole:
kr.apiKeyInt = KafkaRole{FetchKey, OffsetsKey, MetadataKey,
OffsetCommitKey, OffsetFetchKey, FindCoordinatorKey,
JoinGroupKey, HeartbeatKey, LeaveGroupKey, SyncgroupKey, APIVersionsKey}
return nil
default:
return fmt.Errorf("Invalid Kafka Role %s", kr.Role)
}
} | go | func (kr *PortRuleKafka) MapRoleToAPIKey() error {
// Expand the kr.apiKeyInt array based on the Role.
// For produce role, we need to add mandatory apiKeys produce, metadata and
// apiversions. While for consume, we need to add mandatory apiKeys like
// fetch, offsets, offsetcommit, offsetfetch, apiversions, metadata,
// findcoordinator, joingroup, heartbeat,
// leavegroup and syncgroup.
switch strings.ToLower(kr.Role) {
case ProduceRole:
kr.apiKeyInt = KafkaRole{ProduceKey, MetadataKey, APIVersionsKey}
return nil
case ConsumeRole:
kr.apiKeyInt = KafkaRole{FetchKey, OffsetsKey, MetadataKey,
OffsetCommitKey, OffsetFetchKey, FindCoordinatorKey,
JoinGroupKey, HeartbeatKey, LeaveGroupKey, SyncgroupKey, APIVersionsKey}
return nil
default:
return fmt.Errorf("Invalid Kafka Role %s", kr.Role)
}
} | [
"func",
"(",
"kr",
"*",
"PortRuleKafka",
")",
"MapRoleToAPIKey",
"(",
")",
"error",
"{",
"// Expand the kr.apiKeyInt array based on the Role.",
"// For produce role, we need to add mandatory apiKeys produce, metadata and",
"// apiversions. While for consume, we need to add mandatory apiKey... | // MapRoleToAPIKey maps the Role to the low level set of APIKeys for that role | [
"MapRoleToAPIKey",
"maps",
"the",
"Role",
"to",
"the",
"low",
"level",
"set",
"of",
"APIKeys",
"for",
"that",
"role"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/kafka.go#L274-L293 |
163,906 | cilium/cilium | api/v1/server/restapi/endpoint/get_endpoint_id_log_responses.go | WithPayload | func (o *GetEndpointIDLogOK) WithPayload(payload models.EndpointStatusLog) *GetEndpointIDLogOK {
o.Payload = payload
return o
} | go | func (o *GetEndpointIDLogOK) WithPayload(payload models.EndpointStatusLog) *GetEndpointIDLogOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointIDLogOK",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"EndpointStatusLog",
")",
"*",
"GetEndpointIDLogOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get endpoint Id log o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"endpoint",
"Id",
"log",
"o",
"k",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/endpoint/get_endpoint_id_log_responses.go#L38-L41 |
163,907 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/types.go | GetPolicyStatus | func (r *CiliumNetworkPolicy) GetPolicyStatus(nodeName string) CiliumNetworkPolicyNodeStatus {
if r.Status.Nodes == nil {
return CiliumNetworkPolicyNodeStatus{}
}
return r.Status.Nodes[nodeName]
} | go | func (r *CiliumNetworkPolicy) GetPolicyStatus(nodeName string) CiliumNetworkPolicyNodeStatus {
if r.Status.Nodes == nil {
return CiliumNetworkPolicyNodeStatus{}
}
return r.Status.Nodes[nodeName]
} | [
"func",
"(",
"r",
"*",
"CiliumNetworkPolicy",
")",
"GetPolicyStatus",
"(",
"nodeName",
"string",
")",
"CiliumNetworkPolicyNodeStatus",
"{",
"if",
"r",
".",
"Status",
".",
"Nodes",
"==",
"nil",
"{",
"return",
"CiliumNetworkPolicyNodeStatus",
"{",
"}",
"\n",
"}",
... | // GetPolicyStatus returns the CiliumNetworkPolicyNodeStatus corresponding to
// nodeName in the provided CiliumNetworkPolicy. If Nodes within the rule's
// Status is nil, returns an empty CiliumNetworkPolicyNodeStatus. | [
"GetPolicyStatus",
"returns",
"the",
"CiliumNetworkPolicyNodeStatus",
"corresponding",
"to",
"nodeName",
"in",
"the",
"provided",
"CiliumNetworkPolicy",
".",
"If",
"Nodes",
"within",
"the",
"rule",
"s",
"Status",
"is",
"nil",
"returns",
"an",
"empty",
"CiliumNetworkPo... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/types.go#L145-L150 |
163,908 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/types.go | SetPolicyStatus | func (r *CiliumNetworkPolicy) SetPolicyStatus(nodeName string, cnpns CiliumNetworkPolicyNodeStatus) {
if r.Status.Nodes == nil {
r.Status.Nodes = map[string]CiliumNetworkPolicyNodeStatus{}
}
r.Status.Nodes[nodeName] = cnpns
} | go | func (r *CiliumNetworkPolicy) SetPolicyStatus(nodeName string, cnpns CiliumNetworkPolicyNodeStatus) {
if r.Status.Nodes == nil {
r.Status.Nodes = map[string]CiliumNetworkPolicyNodeStatus{}
}
r.Status.Nodes[nodeName] = cnpns
} | [
"func",
"(",
"r",
"*",
"CiliumNetworkPolicy",
")",
"SetPolicyStatus",
"(",
"nodeName",
"string",
",",
"cnpns",
"CiliumNetworkPolicyNodeStatus",
")",
"{",
"if",
"r",
".",
"Status",
".",
"Nodes",
"==",
"nil",
"{",
"r",
".",
"Status",
".",
"Nodes",
"=",
"map"... | // SetPolicyStatus sets the given policy status for the given nodes' map | [
"SetPolicyStatus",
"sets",
"the",
"given",
"policy",
"status",
"for",
"the",
"given",
"nodes",
"map"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/types.go#L153-L158 |
163,909 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/types.go | SetDerivedPolicyStatus | func (r *CiliumNetworkPolicy) SetDerivedPolicyStatus(derivativePolicyName string, status CiliumNetworkPolicyNodeStatus) {
if r.Status.DerivativePolicies == nil {
r.Status.DerivativePolicies = map[string]CiliumNetworkPolicyNodeStatus{}
}
r.Status.DerivativePolicies[derivativePolicyName] = status
} | go | func (r *CiliumNetworkPolicy) SetDerivedPolicyStatus(derivativePolicyName string, status CiliumNetworkPolicyNodeStatus) {
if r.Status.DerivativePolicies == nil {
r.Status.DerivativePolicies = map[string]CiliumNetworkPolicyNodeStatus{}
}
r.Status.DerivativePolicies[derivativePolicyName] = status
} | [
"func",
"(",
"r",
"*",
"CiliumNetworkPolicy",
")",
"SetDerivedPolicyStatus",
"(",
"derivativePolicyName",
"string",
",",
"status",
"CiliumNetworkPolicyNodeStatus",
")",
"{",
"if",
"r",
".",
"Status",
".",
"DerivativePolicies",
"==",
"nil",
"{",
"r",
".",
"Status",... | // SetDerivedPolicyStatus set the derivative policy status for the given
// derivative policy name. | [
"SetDerivedPolicyStatus",
"set",
"the",
"derivative",
"policy",
"status",
"for",
"the",
"given",
"derivative",
"policy",
"name",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/types.go#L162-L167 |
163,910 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/types.go | SpecEquals | func (r *CiliumNetworkPolicy) SpecEquals(o *CiliumNetworkPolicy) bool {
if o == nil {
return r == nil
}
return reflect.DeepEqual(r.Spec, o.Spec) &&
reflect.DeepEqual(r.Specs, o.Specs)
} | go | func (r *CiliumNetworkPolicy) SpecEquals(o *CiliumNetworkPolicy) bool {
if o == nil {
return r == nil
}
return reflect.DeepEqual(r.Spec, o.Spec) &&
reflect.DeepEqual(r.Specs, o.Specs)
} | [
"func",
"(",
"r",
"*",
"CiliumNetworkPolicy",
")",
"SpecEquals",
"(",
"o",
"*",
"CiliumNetworkPolicy",
")",
"bool",
"{",
"if",
"o",
"==",
"nil",
"{",
"return",
"r",
"==",
"nil",
"\n",
"}",
"\n",
"return",
"reflect",
".",
"DeepEqual",
"(",
"r",
".",
"... | // SpecEquals returns true if the spec and specs metadata is the sa | [
"SpecEquals",
"returns",
"true",
"if",
"the",
"spec",
"and",
"specs",
"metadata",
"is",
"the",
"sa"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/types.go#L170-L176 |
163,911 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/types.go | Parse | func (r *CiliumNetworkPolicy) Parse() (api.Rules, error) {
if r.ObjectMeta.Name == "" {
return nil, fmt.Errorf("CiliumNetworkPolicy must have name")
}
namespace := k8sUtils.ExtractNamespace(&r.ObjectMeta)
name := r.ObjectMeta.Name
uid := r.ObjectMeta.UID
retRules := api.Rules{}
if r.Spec != nil {
if err := r.Spec.Sanitize(); err != nil {
return nil, fmt.Errorf("Invalid CiliumNetworkPolicy spec: %s", err)
}
cr := k8sCiliumUtils.ParseToCiliumRule(namespace, name, uid, r.Spec)
retRules = append(retRules, cr)
}
if r.Specs != nil {
for _, rule := range r.Specs {
if err := rule.Sanitize(); err != nil {
return nil, fmt.Errorf("Invalid CiliumNetworkPolicy specs: %s", err)
}
cr := k8sCiliumUtils.ParseToCiliumRule(namespace, name, uid, rule)
retRules = append(retRules, cr)
}
}
return retRules, nil
} | go | func (r *CiliumNetworkPolicy) Parse() (api.Rules, error) {
if r.ObjectMeta.Name == "" {
return nil, fmt.Errorf("CiliumNetworkPolicy must have name")
}
namespace := k8sUtils.ExtractNamespace(&r.ObjectMeta)
name := r.ObjectMeta.Name
uid := r.ObjectMeta.UID
retRules := api.Rules{}
if r.Spec != nil {
if err := r.Spec.Sanitize(); err != nil {
return nil, fmt.Errorf("Invalid CiliumNetworkPolicy spec: %s", err)
}
cr := k8sCiliumUtils.ParseToCiliumRule(namespace, name, uid, r.Spec)
retRules = append(retRules, cr)
}
if r.Specs != nil {
for _, rule := range r.Specs {
if err := rule.Sanitize(); err != nil {
return nil, fmt.Errorf("Invalid CiliumNetworkPolicy specs: %s", err)
}
cr := k8sCiliumUtils.ParseToCiliumRule(namespace, name, uid, rule)
retRules = append(retRules, cr)
}
}
return retRules, nil
} | [
"func",
"(",
"r",
"*",
"CiliumNetworkPolicy",
")",
"Parse",
"(",
")",
"(",
"api",
".",
"Rules",
",",
"error",
")",
"{",
"if",
"r",
".",
"ObjectMeta",
".",
"Name",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",... | // Parse parses a CiliumNetworkPolicy and returns a list of cilium policy
// rules. | [
"Parse",
"parses",
"a",
"CiliumNetworkPolicy",
"and",
"returns",
"a",
"list",
"of",
"cilium",
"policy",
"rules",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/types.go#L190-L221 |
163,912 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/types.go | GetControllerName | func (r *CiliumNetworkPolicy) GetControllerName() string {
name := k8sUtils.GetObjNamespaceName(&r.ObjectMeta)
return fmt.Sprintf("%s (v2 %s)", k8sConst.CtrlPrefixPolicyStatus, name)
} | go | func (r *CiliumNetworkPolicy) GetControllerName() string {
name := k8sUtils.GetObjNamespaceName(&r.ObjectMeta)
return fmt.Sprintf("%s (v2 %s)", k8sConst.CtrlPrefixPolicyStatus, name)
} | [
"func",
"(",
"r",
"*",
"CiliumNetworkPolicy",
")",
"GetControllerName",
"(",
")",
"string",
"{",
"name",
":=",
"k8sUtils",
".",
"GetObjNamespaceName",
"(",
"&",
"r",
".",
"ObjectMeta",
")",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"k8... | // GetControllerName returns the unique name for the controller manager. | [
"GetControllerName",
"returns",
"the",
"unique",
"name",
"for",
"the",
"controller",
"manager",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/types.go#L224-L227 |
163,913 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/types.go | GetIdentityLabels | func (r *CiliumNetworkPolicy) GetIdentityLabels() labels.LabelArray {
namespace := k8sUtils.ExtractNamespace(&r.ObjectMeta)
name := r.ObjectMeta.Name
uid := r.ObjectMeta.UID
return k8sCiliumUtils.GetPolicyLabels(namespace, name, uid,
k8sCiliumUtils.ResourceTypeCiliumNetworkPolicy)
} | go | func (r *CiliumNetworkPolicy) GetIdentityLabels() labels.LabelArray {
namespace := k8sUtils.ExtractNamespace(&r.ObjectMeta)
name := r.ObjectMeta.Name
uid := r.ObjectMeta.UID
return k8sCiliumUtils.GetPolicyLabels(namespace, name, uid,
k8sCiliumUtils.ResourceTypeCiliumNetworkPolicy)
} | [
"func",
"(",
"r",
"*",
"CiliumNetworkPolicy",
")",
"GetIdentityLabels",
"(",
")",
"labels",
".",
"LabelArray",
"{",
"namespace",
":=",
"k8sUtils",
".",
"ExtractNamespace",
"(",
"&",
"r",
".",
"ObjectMeta",
")",
"\n",
"name",
":=",
"r",
".",
"ObjectMeta",
"... | // GetIdentityLabels returns all rule labels in the CiliumNetworkPolicy. | [
"GetIdentityLabels",
"returns",
"all",
"rule",
"labels",
"in",
"the",
"CiliumNetworkPolicy",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/types.go#L230-L236 |
163,914 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/types.go | RequiresDerivative | func (r *CiliumNetworkPolicy) RequiresDerivative() bool {
if r.Spec != nil {
if r.Spec.RequiresDerivative() {
return true
}
}
if r.Specs != nil {
for _, rule := range r.Specs {
if rule.RequiresDerivative() {
return true
}
}
}
return false
} | go | func (r *CiliumNetworkPolicy) RequiresDerivative() bool {
if r.Spec != nil {
if r.Spec.RequiresDerivative() {
return true
}
}
if r.Specs != nil {
for _, rule := range r.Specs {
if rule.RequiresDerivative() {
return true
}
}
}
return false
} | [
"func",
"(",
"r",
"*",
"CiliumNetworkPolicy",
")",
"RequiresDerivative",
"(",
")",
"bool",
"{",
"if",
"r",
".",
"Spec",
"!=",
"nil",
"{",
"if",
"r",
".",
"Spec",
".",
"RequiresDerivative",
"(",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
... | // RequiresDerivative return true if the CNP has any rule that will create a new
// derivative rule. | [
"RequiresDerivative",
"return",
"true",
"if",
"the",
"CNP",
"has",
"any",
"rule",
"that",
"will",
"create",
"a",
"new",
"derivative",
"rule",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/types.go#L240-L254 |
163,915 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/types.go | Sort | func (c ControllerList) Sort() {
sort.Slice(c, func(i, j int) bool { return c[i].Name < c[j].Name })
} | go | func (c ControllerList) Sort() {
sort.Slice(c, func(i, j int) bool { return c[i].Name < c[j].Name })
} | [
"func",
"(",
"c",
"ControllerList",
")",
"Sort",
"(",
")",
"{",
"sort",
".",
"Slice",
"(",
"c",
",",
"func",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"c",
"[",
"i",
"]",
".",
"Name",
"<",
"c",
"[",
"j",
"]",
".",
"Name",
"}",
... | // Sort sorts the ControllerList by controller name | [
"Sort",
"sorts",
"the",
"ControllerList",
"by",
"controller",
"name"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/types.go#L340-L342 |
163,916 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/types.go | Sort | func (a AllowedIdentityList) Sort() {
sort.Slice(a, func(i, j int) bool {
if a[i].Identity < a[j].Identity {
return true
} else if a[i].Identity == a[j].Identity {
if a[i].DestPort < a[j].DestPort {
return true
} else if a[i].DestPort == a[j].DestPort {
return a[i].Protocol < a[j].Protocol
}
}
return false
})
} | go | func (a AllowedIdentityList) Sort() {
sort.Slice(a, func(i, j int) bool {
if a[i].Identity < a[j].Identity {
return true
} else if a[i].Identity == a[j].Identity {
if a[i].DestPort < a[j].DestPort {
return true
} else if a[i].DestPort == a[j].DestPort {
return a[i].Protocol < a[j].Protocol
}
}
return false
})
} | [
"func",
"(",
"a",
"AllowedIdentityList",
")",
"Sort",
"(",
")",
"{",
"sort",
".",
"Slice",
"(",
"a",
",",
"func",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"if",
"a",
"[",
"i",
"]",
".",
"Identity",
"<",
"a",
"[",
"j",
"]",
".",
"Identity"... | // Sort sorts a list AllowedIdentityTuple by numeric identity, port and protocol | [
"Sort",
"sorts",
"a",
"list",
"AllowedIdentityTuple",
"by",
"numeric",
"identity",
"port",
"and",
"protocol"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/types.go#L403-L416 |
163,917 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/types.go | Sort | func (a AddressPairList) Sort() {
sort.Slice(a, func(i, j int) bool {
if a[i].IPV4 < a[j].IPV4 {
return true
} else if a[i].IPV4 == a[j].IPV4 {
return a[i].IPV6 < a[j].IPV6
}
return false
})
} | go | func (a AddressPairList) Sort() {
sort.Slice(a, func(i, j int) bool {
if a[i].IPV4 < a[j].IPV4 {
return true
} else if a[i].IPV4 == a[j].IPV4 {
return a[i].IPV6 < a[j].IPV6
}
return false
})
} | [
"func",
"(",
"a",
"AddressPairList",
")",
"Sort",
"(",
")",
"{",
"sort",
".",
"Slice",
"(",
"a",
",",
"func",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"if",
"a",
"[",
"i",
"]",
".",
"IPV4",
"<",
"a",
"[",
"j",
"]",
".",
"IPV4",
"{",
"... | // Sort sorts an AddressPairList by IPv4 and IPv6 address | [
"Sort",
"sorts",
"an",
"AddressPairList",
"by",
"IPv4",
"and",
"IPv6",
"address"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/types.go#L473-L482 |
163,918 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/types.go | DeepCopyInto | func (m *EndpointStatus) DeepCopyInto(out *EndpointStatus) {
*out = *m
b, err := (*EndpointStatus)(m).MarshalBinary()
if err != nil {
log.WithError(err).Error("Cannot marshal EndpointStatus during EndpointStatus deepcopy")
return
}
err = (*EndpointStatus)(out).UnmarshalBinary(b)
if err != nil {
log.WithError(err).Error("Cannot unmarshal EndpointStatus during EndpointStatus deepcopy")
return
}
} | go | func (m *EndpointStatus) DeepCopyInto(out *EndpointStatus) {
*out = *m
b, err := (*EndpointStatus)(m).MarshalBinary()
if err != nil {
log.WithError(err).Error("Cannot marshal EndpointStatus during EndpointStatus deepcopy")
return
}
err = (*EndpointStatus)(out).UnmarshalBinary(b)
if err != nil {
log.WithError(err).Error("Cannot unmarshal EndpointStatus during EndpointStatus deepcopy")
return
}
} | [
"func",
"(",
"m",
"*",
"EndpointStatus",
")",
"DeepCopyInto",
"(",
"out",
"*",
"EndpointStatus",
")",
"{",
"*",
"out",
"=",
"*",
"m",
"\n",
"b",
",",
"err",
":=",
"(",
"*",
"EndpointStatus",
")",
"(",
"m",
")",
".",
"MarshalBinary",
"(",
")",
"\n",... | // DeepCopyInto is an inefficient hack to allow reusing models.Endpoint in the
// CiliumEndpoint CRD. | [
"DeepCopyInto",
"is",
"an",
"inefficient",
"hack",
"to",
"allow",
"reusing",
"models",
".",
"Endpoint",
"in",
"the",
"CiliumEndpoint",
"CRD",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/types.go#L507-L519 |
163,919 | cilium/cilium | pkg/endpoint/cache.go | createEpInfoCache | func (e *Endpoint) createEpInfoCache(epdir string) *epInfoCache {
cidr6, cidr4 := e.GetCIDRPrefixLengths()
ep := &epInfoCache{
revision: e.nextPolicyRevision,
keys: e.GetBPFKeys(),
epdir: epdir,
id: e.GetID(),
ifName: e.IfName,
ipvlan: e.HasIpvlanDataPath(),
identity: e.GetIdentity(),
mac: e.GetNodeMAC(),
ipv4: e.IPv4Address(),
ipv6: e.IPv6Address(),
conntrackLocal: e.ConntrackLocalLocked(),
cidr4PrefixLengths: cidr4,
cidr6PrefixLengths: cidr6,
options: e.Options.DeepCopy(),
endpoint: e,
}
var err error
ep.value, err = e.GetBPFValue()
if err != nil {
log.WithField(logfields.EndpointID, e.ID).WithError(err).Error("getBPFValue failed")
return nil
}
return ep
} | go | func (e *Endpoint) createEpInfoCache(epdir string) *epInfoCache {
cidr6, cidr4 := e.GetCIDRPrefixLengths()
ep := &epInfoCache{
revision: e.nextPolicyRevision,
keys: e.GetBPFKeys(),
epdir: epdir,
id: e.GetID(),
ifName: e.IfName,
ipvlan: e.HasIpvlanDataPath(),
identity: e.GetIdentity(),
mac: e.GetNodeMAC(),
ipv4: e.IPv4Address(),
ipv6: e.IPv6Address(),
conntrackLocal: e.ConntrackLocalLocked(),
cidr4PrefixLengths: cidr4,
cidr6PrefixLengths: cidr6,
options: e.Options.DeepCopy(),
endpoint: e,
}
var err error
ep.value, err = e.GetBPFValue()
if err != nil {
log.WithField(logfields.EndpointID, e.ID).WithError(err).Error("getBPFValue failed")
return nil
}
return ep
} | [
"func",
"(",
"e",
"*",
"Endpoint",
")",
"createEpInfoCache",
"(",
"epdir",
"string",
")",
"*",
"epInfoCache",
"{",
"cidr6",
",",
"cidr4",
":=",
"e",
".",
"GetCIDRPrefixLengths",
"(",
")",
"\n\n",
"ep",
":=",
"&",
"epInfoCache",
"{",
"revision",
":",
"e",... | // Must be called when endpoint is still locked. | [
"Must",
"be",
"called",
"when",
"endpoint",
"is",
"still",
"locked",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/cache.go#L68-L99 |
163,920 | cilium/cilium | pkg/endpoint/cache.go | Logger | func (ep *epInfoCache) Logger(subsystem string) *logrus.Entry {
return ep.endpoint.Logger(subsystem)
} | go | func (ep *epInfoCache) Logger(subsystem string) *logrus.Entry {
return ep.endpoint.Logger(subsystem)
} | [
"func",
"(",
"ep",
"*",
"epInfoCache",
")",
"Logger",
"(",
"subsystem",
"string",
")",
"*",
"logrus",
".",
"Entry",
"{",
"return",
"ep",
".",
"endpoint",
".",
"Logger",
"(",
"subsystem",
")",
"\n",
"}"
] | // Logger returns the logger for the endpoint that is being cached. | [
"Logger",
"returns",
"the",
"logger",
"for",
"the",
"endpoint",
"that",
"is",
"being",
"cached",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/cache.go#L128-L130 |
163,921 | cilium/cilium | proxylib/proxylib/instance.go | OpenInstance | func OpenInstance(nodeID string, xdsPath string, newPolicyClient func(path, nodeID string, updater PolicyUpdater) PolicyClient,
accessLogPath string, newAccessLogger func(accessLogPath string) AccessLogger) uint64 {
mutex.Lock()
defer mutex.Unlock()
// Check if have an instance with these params already
for id, old := range instances {
oldXdsPath := ""
if old.policyClient != nil {
oldXdsPath = old.policyClient.Path()
}
oldAccessLogPath := ""
if old.accessLogger != nil {
oldAccessLogPath = old.accessLogger.Path()
}
if (nodeID == "" || old.nodeID == nodeID) && xdsPath == oldXdsPath && accessLogPath == oldAccessLogPath {
old.openCount++
log.Infof("Opened existing library instance %d, open count: %d", id, old.openCount)
return id
}
}
ins := NewInstance(nodeID, newAccessLogger(accessLogPath))
// policy client needs the instance so we set it after instance has been created
ins.policyClient = newPolicyClient(xdsPath, ins.nodeID, ins)
instances[instanceId] = ins
log.Infof("Opened new library instance %d", instanceId)
return instanceId
} | go | func OpenInstance(nodeID string, xdsPath string, newPolicyClient func(path, nodeID string, updater PolicyUpdater) PolicyClient,
accessLogPath string, newAccessLogger func(accessLogPath string) AccessLogger) uint64 {
mutex.Lock()
defer mutex.Unlock()
// Check if have an instance with these params already
for id, old := range instances {
oldXdsPath := ""
if old.policyClient != nil {
oldXdsPath = old.policyClient.Path()
}
oldAccessLogPath := ""
if old.accessLogger != nil {
oldAccessLogPath = old.accessLogger.Path()
}
if (nodeID == "" || old.nodeID == nodeID) && xdsPath == oldXdsPath && accessLogPath == oldAccessLogPath {
old.openCount++
log.Infof("Opened existing library instance %d, open count: %d", id, old.openCount)
return id
}
}
ins := NewInstance(nodeID, newAccessLogger(accessLogPath))
// policy client needs the instance so we set it after instance has been created
ins.policyClient = newPolicyClient(xdsPath, ins.nodeID, ins)
instances[instanceId] = ins
log.Infof("Opened new library instance %d", instanceId)
return instanceId
} | [
"func",
"OpenInstance",
"(",
"nodeID",
"string",
",",
"xdsPath",
"string",
",",
"newPolicyClient",
"func",
"(",
"path",
",",
"nodeID",
"string",
",",
"updater",
"PolicyUpdater",
")",
"PolicyClient",
",",
"accessLogPath",
"string",
",",
"newAccessLogger",
"func",
... | // OpenInstance creates a new instance or finds an existing one with equivalent parameters.
// returns the instance id. | [
"OpenInstance",
"creates",
"a",
"new",
"instance",
"or",
"finds",
"an",
"existing",
"one",
"with",
"equivalent",
"parameters",
".",
"returns",
"the",
"instance",
"id",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/proxylib/proxylib/instance.go#L85-L116 |
163,922 | cilium/cilium | proxylib/proxylib/instance.go | CloseInstance | func CloseInstance(id uint64) uint64 {
mutex.Lock()
defer mutex.Unlock()
count := uint64(0)
if ins, ok := instances[id]; ok {
ins.openCount--
count = ins.openCount
if count <= 0 {
if ins.policyClient != nil {
ins.policyClient.Close()
}
if ins.accessLogger != nil {
ins.accessLogger.Close()
}
delete(instances, id)
}
log.Infof("CloseInstance(%d): Remaining open count: %d", id, count)
} else {
log.Infof("CloseInstance(%d): Not found (closed already?)", id)
}
return count
} | go | func CloseInstance(id uint64) uint64 {
mutex.Lock()
defer mutex.Unlock()
count := uint64(0)
if ins, ok := instances[id]; ok {
ins.openCount--
count = ins.openCount
if count <= 0 {
if ins.policyClient != nil {
ins.policyClient.Close()
}
if ins.accessLogger != nil {
ins.accessLogger.Close()
}
delete(instances, id)
}
log.Infof("CloseInstance(%d): Remaining open count: %d", id, count)
} else {
log.Infof("CloseInstance(%d): Not found (closed already?)", id)
}
return count
} | [
"func",
"CloseInstance",
"(",
"id",
"uint64",
")",
"uint64",
"{",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"count",
":=",
"uint64",
"(",
"0",
")",
"\n",
"if",
"ins",
",",
"ok",
":=",
"instances",
"[",... | // Close returns the new open count | [
"Close",
"returns",
"the",
"new",
"open",
"count"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/proxylib/proxylib/instance.go#L125-L147 |
163,923 | cilium/cilium | proxylib/proxylib/instance.go | PolicyUpdate | func (ins *Instance) PolicyUpdate(resp *envoy_api_v2.DiscoveryResponse) (err error) {
defer func() {
if r := recover(); r != nil {
var ok bool
if err, ok = r.(error); !ok {
err = fmt.Errorf("NPDS: Panic: %v", r)
}
}
}()
log.Debugf("NPDS: Updating policy from %v", resp)
oldMap := ins.getPolicyMap()
newMap := newPolicyMap()
for _, any := range resp.Resources {
if any.TypeUrl != resp.TypeUrl {
return fmt.Errorf("NPDS: Mismatching TypeUrls: %s != %s", any.TypeUrl, resp.TypeUrl)
}
var config cilium.NetworkPolicy
if err = proto.Unmarshal(any.Value, &config); err != nil {
return fmt.Errorf("NPDS: Policy unmarshal error: %v", err)
}
policyName := config.GetName()
// Locate the old version, if any
oldPolicy, found := oldMap[policyName]
if found {
// Check if the new policy is the same as the old one
if proto.Equal(&config, &oldPolicy.protobuf) {
log.Debugf("NPDS: New policy for %s is equal to the old one, no need to change", policyName)
newMap[policyName] = oldPolicy
continue
}
}
// Validate new config
if err = config.Validate(); err != nil {
return fmt.Errorf("NPDS: Policy validation error for %s: %v", policyName, err)
}
// Create new PolicyInstance, may panic
newMap[policyName] = newPolicyInstance(&config)
}
// Store the new policy map
ins.setPolicyMap(newMap)
log.Debugf("NPDS: Policy Update completed for instance %d: %v", ins.id, newMap)
return
} | go | func (ins *Instance) PolicyUpdate(resp *envoy_api_v2.DiscoveryResponse) (err error) {
defer func() {
if r := recover(); r != nil {
var ok bool
if err, ok = r.(error); !ok {
err = fmt.Errorf("NPDS: Panic: %v", r)
}
}
}()
log.Debugf("NPDS: Updating policy from %v", resp)
oldMap := ins.getPolicyMap()
newMap := newPolicyMap()
for _, any := range resp.Resources {
if any.TypeUrl != resp.TypeUrl {
return fmt.Errorf("NPDS: Mismatching TypeUrls: %s != %s", any.TypeUrl, resp.TypeUrl)
}
var config cilium.NetworkPolicy
if err = proto.Unmarshal(any.Value, &config); err != nil {
return fmt.Errorf("NPDS: Policy unmarshal error: %v", err)
}
policyName := config.GetName()
// Locate the old version, if any
oldPolicy, found := oldMap[policyName]
if found {
// Check if the new policy is the same as the old one
if proto.Equal(&config, &oldPolicy.protobuf) {
log.Debugf("NPDS: New policy for %s is equal to the old one, no need to change", policyName)
newMap[policyName] = oldPolicy
continue
}
}
// Validate new config
if err = config.Validate(); err != nil {
return fmt.Errorf("NPDS: Policy validation error for %s: %v", policyName, err)
}
// Create new PolicyInstance, may panic
newMap[policyName] = newPolicyInstance(&config)
}
// Store the new policy map
ins.setPolicyMap(newMap)
log.Debugf("NPDS: Policy Update completed for instance %d: %v", ins.id, newMap)
return
} | [
"func",
"(",
"ins",
"*",
"Instance",
")",
"PolicyUpdate",
"(",
"resp",
"*",
"envoy_api_v2",
".",
"DiscoveryResponse",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"r",
":=",
"recover",
"(",
")",
";",
"r",
"!=",
"nil",
"... | // Update the PolicyMap from a protobuf. PolicyMap is only ever changed if the whole update is successful. | [
"Update",
"the",
"PolicyMap",
"from",
"a",
"protobuf",
".",
"PolicyMap",
"is",
"only",
"ever",
"changed",
"if",
"the",
"whole",
"update",
"is",
"successful",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/proxylib/proxylib/instance.go#L168-L219 |
163,924 | cilium/cilium | pkg/health/client/client.go | GetHostPrimaryAddress | func GetHostPrimaryAddress(node *models.NodeStatus) *models.PathStatus {
if node.Host == nil {
return nil
}
return node.Host.PrimaryAddress
} | go | func GetHostPrimaryAddress(node *models.NodeStatus) *models.PathStatus {
if node.Host == nil {
return nil
}
return node.Host.PrimaryAddress
} | [
"func",
"GetHostPrimaryAddress",
"(",
"node",
"*",
"models",
".",
"NodeStatus",
")",
"*",
"models",
".",
"PathStatus",
"{",
"if",
"node",
".",
"Host",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"node",
".",
"Host",
".",
"PrimaryAddre... | // GetHostPrimaryAddress returns the PrimaryAddress for the Host within node.
// If node.Host is nil, returns nil. | [
"GetHostPrimaryAddress",
"returns",
"the",
"PrimaryAddress",
"for",
"the",
"Host",
"within",
"node",
".",
"If",
"node",
".",
"Host",
"is",
"nil",
"returns",
"nil",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/health/client/client.go#L183-L189 |
163,925 | cilium/cilium | pkg/health/client/client.go | FormatHealthStatusResponse | func FormatHealthStatusResponse(w io.Writer, sr *models.HealthStatusResponse, printAll, succinct, verbose bool, maxLines int) {
var (
healthy int
localhost *models.NodeStatus
)
for _, node := range sr.Nodes {
if nodeIsHealthy(node) {
healthy++
}
if nodeIsLocalhost(node, sr.Local) {
localhost = node
}
}
if succinct {
fmt.Fprintf(w, "Cluster health:\t%d/%d reachable\t(%s)\n",
healthy, len(sr.Nodes), sr.Timestamp)
if printAll || healthy < len(sr.Nodes) {
fmt.Fprintf(w, " Name\tIP\tReachable\tEndpoints reachable\n")
}
} else {
fmt.Fprintf(w, "Probe time:\t%s\n", sr.Timestamp)
fmt.Fprintf(w, "Nodes:\n")
}
if localhost != nil {
formatNodeStatus(w, localhost, printAll, succinct, verbose, true)
maxLines--
}
nodes := sr.Nodes
sort.Slice(nodes, func(i, j int) bool {
return strings.Compare(nodes[i].Name, nodes[j].Name) < 0
})
for n, node := range nodes {
if maxLines > 0 && n > maxLines {
break
}
if node == localhost {
continue
}
formatNodeStatus(w, node, printAll, succinct, verbose, false)
}
if maxLines > 0 && len(sr.Nodes)-healthy > maxLines {
fmt.Fprintf(w, " ...")
}
} | go | func FormatHealthStatusResponse(w io.Writer, sr *models.HealthStatusResponse, printAll, succinct, verbose bool, maxLines int) {
var (
healthy int
localhost *models.NodeStatus
)
for _, node := range sr.Nodes {
if nodeIsHealthy(node) {
healthy++
}
if nodeIsLocalhost(node, sr.Local) {
localhost = node
}
}
if succinct {
fmt.Fprintf(w, "Cluster health:\t%d/%d reachable\t(%s)\n",
healthy, len(sr.Nodes), sr.Timestamp)
if printAll || healthy < len(sr.Nodes) {
fmt.Fprintf(w, " Name\tIP\tReachable\tEndpoints reachable\n")
}
} else {
fmt.Fprintf(w, "Probe time:\t%s\n", sr.Timestamp)
fmt.Fprintf(w, "Nodes:\n")
}
if localhost != nil {
formatNodeStatus(w, localhost, printAll, succinct, verbose, true)
maxLines--
}
nodes := sr.Nodes
sort.Slice(nodes, func(i, j int) bool {
return strings.Compare(nodes[i].Name, nodes[j].Name) < 0
})
for n, node := range nodes {
if maxLines > 0 && n > maxLines {
break
}
if node == localhost {
continue
}
formatNodeStatus(w, node, printAll, succinct, verbose, false)
}
if maxLines > 0 && len(sr.Nodes)-healthy > maxLines {
fmt.Fprintf(w, " ...")
}
} | [
"func",
"FormatHealthStatusResponse",
"(",
"w",
"io",
".",
"Writer",
",",
"sr",
"*",
"models",
".",
"HealthStatusResponse",
",",
"printAll",
",",
"succinct",
",",
"verbose",
"bool",
",",
"maxLines",
"int",
")",
"{",
"var",
"(",
"healthy",
"int",
"\n",
"loc... | // FormatHealthStatusResponse writes a HealthStatusResponse as a string to the
// writer.
//
// 'printAll', if true, causes all nodes to be printed regardless of status
// 'succinct', if true, causes node health to be output as one line per node
// 'verbose', if true, overrides 'succinct' and prints all information
// 'maxLines', if nonzero, determines the maximum number of lines to print | [
"FormatHealthStatusResponse",
"writes",
"a",
"HealthStatusResponse",
"as",
"a",
"string",
"to",
"the",
"writer",
".",
"printAll",
"if",
"true",
"causes",
"all",
"nodes",
"to",
"be",
"printed",
"regardless",
"of",
"status",
"succinct",
"if",
"true",
"causes",
"no... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/health/client/client.go#L223-L268 |
163,926 | cilium/cilium | monitor/monitor_main.go | Execute | func Execute() {
if err := rootCmd.Execute(); err != nil {
log.WithError(err).Error("Monitor failed")
os.Exit(-1)
}
} | go | func Execute() {
if err := rootCmd.Execute(); err != nil {
log.WithError(err).Error("Monitor failed")
os.Exit(-1)
}
} | [
"func",
"Execute",
"(",
")",
"{",
"if",
"err",
":=",
"rootCmd",
".",
"Execute",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"os",
".",
"Exit",
"(",
"-",
"1",
")",... | // Execute is an entry point for node monitor | [
"Execute",
"is",
"an",
"entry",
"point",
"for",
"node",
"monitor"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/monitor/monitor_main.go#L65-L70 |
163,927 | cilium/cilium | monitor/monitor_main.go | buildServerOrExit | func buildServerOrExit(path string) net.Listener {
scopedLog := log.WithField(logfields.Path, path)
os.Remove(path)
server, err := net.Listen("unix", path)
if err != nil {
scopedLog.WithError(err).Fatal("Cannot listen on socket")
}
if os.Getuid() == 0 {
err := api.SetDefaultPermissions(path)
if err != nil {
scopedLog.WithError(err).Fatal("Cannot set default permissions on socket")
}
}
return server
} | go | func buildServerOrExit(path string) net.Listener {
scopedLog := log.WithField(logfields.Path, path)
os.Remove(path)
server, err := net.Listen("unix", path)
if err != nil {
scopedLog.WithError(err).Fatal("Cannot listen on socket")
}
if os.Getuid() == 0 {
err := api.SetDefaultPermissions(path)
if err != nil {
scopedLog.WithError(err).Fatal("Cannot set default permissions on socket")
}
}
return server
} | [
"func",
"buildServerOrExit",
"(",
"path",
"string",
")",
"net",
".",
"Listener",
"{",
"scopedLog",
":=",
"log",
".",
"WithField",
"(",
"logfields",
".",
"Path",
",",
"path",
")",
"\n\n",
"os",
".",
"Remove",
"(",
"path",
")",
"\n",
"server",
",",
"err"... | // buildServerOrExit opens a listener socket at path. It exits with logging on
// all errors. | [
"buildServerOrExit",
"opens",
"a",
"listener",
"socket",
"at",
"path",
".",
"It",
"exits",
"with",
"logging",
"on",
"all",
"errors",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/monitor/monitor_main.go#L74-L91 |
163,928 | cilium/cilium | api/v1/models/endpoint_change_request.go | Validate | func (m *EndpointChangeRequest) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAddressing(formats); err != nil {
res = append(res, err)
}
if err := m.validateLabels(formats); err != nil {
res = append(res, err)
}
if err := m.validateState(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | func (m *EndpointChangeRequest) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAddressing(formats); err != nil {
res = append(res, err)
}
if err := m.validateLabels(formats); err != nil {
res = append(res, err)
}
if err := m.validateState(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | [
"func",
"(",
"m",
"*",
"EndpointChangeRequest",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateAddressing",
"(",
"formats",
")",
";",
"err",
... | // Validate validates this endpoint change request | [
"Validate",
"validates",
"this",
"endpoint",
"change",
"request"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/endpoint_change_request.go#L78-L97 |
163,929 | cilium/cilium | api/v1/client/policy/put_policy_parameters.go | WithTimeout | func (o *PutPolicyParams) WithTimeout(timeout time.Duration) *PutPolicyParams {
o.SetTimeout(timeout)
return o
} | go | func (o *PutPolicyParams) WithTimeout(timeout time.Duration) *PutPolicyParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"PutPolicyParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"PutPolicyParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the put policy params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"put",
"policy",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/put_policy_parameters.go#L76-L79 |
163,930 | cilium/cilium | api/v1/client/policy/put_policy_parameters.go | WithContext | func (o *PutPolicyParams) WithContext(ctx context.Context) *PutPolicyParams {
o.SetContext(ctx)
return o
} | go | func (o *PutPolicyParams) WithContext(ctx context.Context) *PutPolicyParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"PutPolicyParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"PutPolicyParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the put policy params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"put",
"policy",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/put_policy_parameters.go#L87-L90 |
163,931 | cilium/cilium | api/v1/client/policy/put_policy_parameters.go | WithHTTPClient | func (o *PutPolicyParams) WithHTTPClient(client *http.Client) *PutPolicyParams {
o.SetHTTPClient(client)
return o
} | go | func (o *PutPolicyParams) WithHTTPClient(client *http.Client) *PutPolicyParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"PutPolicyParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"PutPolicyParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the put policy params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"put",
"policy",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/put_policy_parameters.go#L98-L101 |
163,932 | cilium/cilium | api/v1/client/policy/put_policy_parameters.go | WithPolicy | func (o *PutPolicyParams) WithPolicy(policy string) *PutPolicyParams {
o.SetPolicy(policy)
return o
} | go | func (o *PutPolicyParams) WithPolicy(policy string) *PutPolicyParams {
o.SetPolicy(policy)
return o
} | [
"func",
"(",
"o",
"*",
"PutPolicyParams",
")",
"WithPolicy",
"(",
"policy",
"string",
")",
"*",
"PutPolicyParams",
"{",
"o",
".",
"SetPolicy",
"(",
"policy",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPolicy adds the policy to the put policy params | [
"WithPolicy",
"adds",
"the",
"policy",
"to",
"the",
"put",
"policy",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/put_policy_parameters.go#L109-L112 |
163,933 | cilium/cilium | pkg/maps/encrypt/encrypt.go | MapUpdateContext | func MapUpdateContext(ctxID uint32, keyID uint8) error {
k := newEncryptKey(ctxID)
v := &EncryptValue{
encryptKeyID: keyID,
}
return encryptMap.Update(k, v)
} | go | func MapUpdateContext(ctxID uint32, keyID uint8) error {
k := newEncryptKey(ctxID)
v := &EncryptValue{
encryptKeyID: keyID,
}
return encryptMap.Update(k, v)
} | [
"func",
"MapUpdateContext",
"(",
"ctxID",
"uint32",
",",
"keyID",
"uint8",
")",
"error",
"{",
"k",
":=",
"newEncryptKey",
"(",
"ctxID",
")",
"\n",
"v",
":=",
"&",
"EncryptValue",
"{",
"encryptKeyID",
":",
"keyID",
",",
"}",
"\n",
"return",
"encryptMap",
... | // MapUpdateContext updates the encrypt state with ctxID to use the new keyID | [
"MapUpdateContext",
"updates",
"the",
"encrypt",
"state",
"with",
"ctxID",
"to",
"use",
"the",
"new",
"keyID"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/encrypt/encrypt.go#L96-L102 |
163,934 | cilium/cilium | pkg/kafka/response.go | String | func (res *ResponseMessage) String() string {
b, err := json.Marshal(res.response)
if err != nil {
return err.Error()
}
return string(b)
} | go | func (res *ResponseMessage) String() string {
b, err := json.Marshal(res.response)
if err != nil {
return err.Error()
}
return string(b)
} | [
"func",
"(",
"res",
"*",
"ResponseMessage",
")",
"String",
"(",
")",
"string",
"{",
"b",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"res",
".",
"response",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
".",
"Error",
"(",
")",
"\n... | // String returns a human readable representation of the response message | [
"String",
"returns",
"a",
"human",
"readable",
"representation",
"of",
"the",
"response",
"message"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kafka/response.go#L54-L60 |
163,935 | cilium/cilium | pkg/kafka/response.go | ReadResponse | func ReadResponse(reader io.Reader) (*ResponseMessage, error) {
rsp := &ResponseMessage{}
var err error
_, rsp.rawMsg, err = proto.ReadResp(reader)
if err != nil {
return nil, err
}
if len(rsp.rawMsg) < 6 {
return nil,
fmt.Errorf("unexpected end of response (length < 6 bytes)")
}
return rsp, nil
} | go | func ReadResponse(reader io.Reader) (*ResponseMessage, error) {
rsp := &ResponseMessage{}
var err error
_, rsp.rawMsg, err = proto.ReadResp(reader)
if err != nil {
return nil, err
}
if len(rsp.rawMsg) < 6 {
return nil,
fmt.Errorf("unexpected end of response (length < 6 bytes)")
}
return rsp, nil
} | [
"func",
"ReadResponse",
"(",
"reader",
"io",
".",
"Reader",
")",
"(",
"*",
"ResponseMessage",
",",
"error",
")",
"{",
"rsp",
":=",
"&",
"ResponseMessage",
"{",
"}",
"\n",
"var",
"err",
"error",
"\n\n",
"_",
",",
"rsp",
".",
"rawMsg",
",",
"err",
"=",... | // ReadResponse will read a Kafka response from an io.Reader and return the
// message or an error. | [
"ReadResponse",
"will",
"read",
"a",
"Kafka",
"response",
"from",
"an",
"io",
".",
"Reader",
"and",
"return",
"the",
"message",
"or",
"an",
"error",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kafka/response.go#L64-L79 |
163,936 | cilium/cilium | pkg/k8s/client/informers/externalversions/cilium.io/v2/interface.go | CiliumEndpoints | func (v *version) CiliumEndpoints() CiliumEndpointInformer {
return &ciliumEndpointInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
} | go | func (v *version) CiliumEndpoints() CiliumEndpointInformer {
return &ciliumEndpointInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
} | [
"func",
"(",
"v",
"*",
"version",
")",
"CiliumEndpoints",
"(",
")",
"CiliumEndpointInformer",
"{",
"return",
"&",
"ciliumEndpointInformer",
"{",
"factory",
":",
"v",
".",
"factory",
",",
"namespace",
":",
"v",
".",
"namespace",
",",
"tweakListOptions",
":",
... | // CiliumEndpoints returns a CiliumEndpointInformer. | [
"CiliumEndpoints",
"returns",
"a",
"CiliumEndpointInformer",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/client/informers/externalversions/cilium.io/v2/interface.go#L43-L45 |
163,937 | cilium/cilium | pkg/k8s/client/informers/externalversions/cilium.io/v2/interface.go | CiliumNetworkPolicies | func (v *version) CiliumNetworkPolicies() CiliumNetworkPolicyInformer {
return &ciliumNetworkPolicyInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
} | go | func (v *version) CiliumNetworkPolicies() CiliumNetworkPolicyInformer {
return &ciliumNetworkPolicyInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
} | [
"func",
"(",
"v",
"*",
"version",
")",
"CiliumNetworkPolicies",
"(",
")",
"CiliumNetworkPolicyInformer",
"{",
"return",
"&",
"ciliumNetworkPolicyInformer",
"{",
"factory",
":",
"v",
".",
"factory",
",",
"namespace",
":",
"v",
".",
"namespace",
",",
"tweakListOpt... | // CiliumNetworkPolicies returns a CiliumNetworkPolicyInformer. | [
"CiliumNetworkPolicies",
"returns",
"a",
"CiliumNetworkPolicyInformer",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/client/informers/externalversions/cilium.io/v2/interface.go#L48-L50 |
163,938 | cilium/cilium | pkg/policy/identifier.go | ForEach | func (e *EndpointSet) ForEach(wg *sync.WaitGroup, epFunc func(epp Endpoint)) {
e.mutex.Lock()
defer e.mutex.Unlock()
wg.Add(len(e.endpoints))
for ep := range e.endpoints {
go func(eppp Endpoint) {
epFunc(eppp)
wg.Done()
}(ep)
}
} | go | func (e *EndpointSet) ForEach(wg *sync.WaitGroup, epFunc func(epp Endpoint)) {
e.mutex.Lock()
defer e.mutex.Unlock()
wg.Add(len(e.endpoints))
for ep := range e.endpoints {
go func(eppp Endpoint) {
epFunc(eppp)
wg.Done()
}(ep)
}
} | [
"func",
"(",
"e",
"*",
"EndpointSet",
")",
"ForEach",
"(",
"wg",
"*",
"sync",
".",
"WaitGroup",
",",
"epFunc",
"func",
"(",
"epp",
"Endpoint",
")",
")",
"{",
"e",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"mutex",
".",
"Unlock... | // ForEach runs epFunc asynchronously for all endpoints in the EndpointSet. It
// signals to the provided WaitGroup when epFunc has been executed for each
// endpoint. | [
"ForEach",
"runs",
"epFunc",
"asynchronously",
"for",
"all",
"endpoints",
"in",
"the",
"EndpointSet",
".",
"It",
"signals",
"to",
"the",
"provided",
"WaitGroup",
"when",
"epFunc",
"has",
"been",
"executed",
"for",
"each",
"endpoint",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/identifier.go#L69-L81 |
163,939 | cilium/cilium | pkg/policy/identifier.go | Delete | func (e *EndpointSet) Delete(ep Endpoint) {
e.mutex.Lock()
delete(e.endpoints, ep)
e.mutex.Unlock()
} | go | func (e *EndpointSet) Delete(ep Endpoint) {
e.mutex.Lock()
delete(e.endpoints, ep)
e.mutex.Unlock()
} | [
"func",
"(",
"e",
"*",
"EndpointSet",
")",
"Delete",
"(",
"ep",
"Endpoint",
")",
"{",
"e",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"delete",
"(",
"e",
".",
"endpoints",
",",
"ep",
")",
"\n",
"e",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
... | // Delete removes ep from the EndpointSet. | [
"Delete",
"removes",
"ep",
"from",
"the",
"EndpointSet",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/identifier.go#L84-L88 |
163,940 | cilium/cilium | pkg/policy/identifier.go | Insert | func (e *EndpointSet) Insert(ep Endpoint) {
e.mutex.Lock()
e.endpoints[ep] = struct{}{}
e.mutex.Unlock()
} | go | func (e *EndpointSet) Insert(ep Endpoint) {
e.mutex.Lock()
e.endpoints[ep] = struct{}{}
e.mutex.Unlock()
} | [
"func",
"(",
"e",
"*",
"EndpointSet",
")",
"Insert",
"(",
"ep",
"Endpoint",
")",
"{",
"e",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"e",
".",
"endpoints",
"[",
"ep",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n",
"e",
".",
"mutex",
".",
"Unl... | // Insert adds ep to the EndpointSet. | [
"Insert",
"adds",
"ep",
"to",
"the",
"EndpointSet",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/identifier.go#L91-L95 |
163,941 | cilium/cilium | pkg/policy/identifier.go | Len | func (e *EndpointSet) Len() int {
e.mutex.RLock()
defer e.mutex.RUnlock()
return len(e.endpoints)
} | go | func (e *EndpointSet) Len() int {
e.mutex.RLock()
defer e.mutex.RUnlock()
return len(e.endpoints)
} | [
"func",
"(",
"e",
"*",
"EndpointSet",
")",
"Len",
"(",
")",
"int",
"{",
"e",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"e",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"len",
"(",
"e",
".",
"endpoints",
")",
"\n",
"}"
] | // Len returns the number of elements in the EndpointSet. | [
"Len",
"returns",
"the",
"number",
"of",
"elements",
"in",
"the",
"EndpointSet",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/identifier.go#L98-L102 |
163,942 | cilium/cilium | pkg/endpoint/connector/veth.go | SetupVethRemoteNs | func SetupVethRemoteNs(netNs ns.NetNS, srcIfName, dstIfName string) (int, int, error) {
return 0, 0, netNs.Do(func(_ ns.NetNS) error {
err := link.Rename(srcIfName, dstIfName)
if err != nil {
return fmt.Errorf("failed to rename veth from %q to %q: %s", srcIfName, dstIfName, err)
}
return nil
})
} | go | func SetupVethRemoteNs(netNs ns.NetNS, srcIfName, dstIfName string) (int, int, error) {
return 0, 0, netNs.Do(func(_ ns.NetNS) error {
err := link.Rename(srcIfName, dstIfName)
if err != nil {
return fmt.Errorf("failed to rename veth from %q to %q: %s", srcIfName, dstIfName, err)
}
return nil
})
} | [
"func",
"SetupVethRemoteNs",
"(",
"netNs",
"ns",
".",
"NetNS",
",",
"srcIfName",
",",
"dstIfName",
"string",
")",
"(",
"int",
",",
"int",
",",
"error",
")",
"{",
"return",
"0",
",",
"0",
",",
"netNs",
".",
"Do",
"(",
"func",
"(",
"_",
"ns",
".",
... | // SetupVethRemoteNs renames the netdevice in the target namespace to the
// provided dstIfName. | [
"SetupVethRemoteNs",
"renames",
"the",
"netdevice",
"in",
"the",
"target",
"namespace",
"to",
"the",
"provided",
"dstIfName",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/connector/veth.go#L32-L40 |
163,943 | cilium/cilium | pkg/endpoint/connector/veth.go | SetupVeth | func SetupVeth(id string, mtu int, ep *models.EndpointChangeRequest) (*netlink.Veth, *netlink.Link, string, error) {
if id == "" {
return nil, nil, "", fmt.Errorf("invalid: empty ID")
}
lxcIfName := Endpoint2IfName(id)
tmpIfName := Endpoint2TempIfName(id)
veth, link, err := SetupVethWithNames(lxcIfName, tmpIfName, mtu, ep)
return veth, link, tmpIfName, err
} | go | func SetupVeth(id string, mtu int, ep *models.EndpointChangeRequest) (*netlink.Veth, *netlink.Link, string, error) {
if id == "" {
return nil, nil, "", fmt.Errorf("invalid: empty ID")
}
lxcIfName := Endpoint2IfName(id)
tmpIfName := Endpoint2TempIfName(id)
veth, link, err := SetupVethWithNames(lxcIfName, tmpIfName, mtu, ep)
return veth, link, tmpIfName, err
} | [
"func",
"SetupVeth",
"(",
"id",
"string",
",",
"mtu",
"int",
",",
"ep",
"*",
"models",
".",
"EndpointChangeRequest",
")",
"(",
"*",
"netlink",
".",
"Veth",
",",
"*",
"netlink",
".",
"Link",
",",
"string",
",",
"error",
")",
"{",
"if",
"id",
"==",
"... | // SetupVeth sets up the net interface, the temporary interface and fills up some endpoint
// fields such as LXCMAC, NodeMac, IfIndex and IfName. Returns a pointer for the created
// veth, a pointer for the temporary link, the name of the temporary link and error if
// something fails. | [
"SetupVeth",
"sets",
"up",
"the",
"net",
"interface",
"the",
"temporary",
"interface",
"and",
"fills",
"up",
"some",
"endpoint",
"fields",
"such",
"as",
"LXCMAC",
"NodeMac",
"IfIndex",
"and",
"IfName",
".",
"Returns",
"a",
"pointer",
"for",
"the",
"created",
... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/connector/veth.go#L46-L56 |
163,944 | cilium/cilium | pkg/endpoint/connector/veth.go | SetupVethWithNames | func SetupVethWithNames(lxcIfName, tmpIfName string, mtu int, ep *models.EndpointChangeRequest) (*netlink.Veth, *netlink.Link, error) {
veth := &netlink.Veth{
LinkAttrs: netlink.LinkAttrs{Name: lxcIfName},
PeerName: tmpIfName,
}
if err := netlink.LinkAdd(veth); err != nil {
return nil, nil, fmt.Errorf("unable to create veth pair: %s", err)
}
var err error
defer func() {
if err != nil {
if err = netlink.LinkDel(veth); err != nil {
log.WithError(err).WithField(logfields.Veth, veth.Name).Warn("failed to clean up veth")
}
}
}()
log.WithField(logfields.VethPair, []string{veth.PeerName, lxcIfName}).Debug("Created veth pair")
// Disable reverse path filter on the host side veth peer to allow
// container addresses to be used as source address when the linux
// stack performs routing.
rpFilterPath := filepath.Join("/proc", "sys", "net", "ipv4", "conf", lxcIfName, "rp_filter")
err = WriteSysConfig(rpFilterPath, "0\n")
if err != nil {
return nil, nil, fmt.Errorf("unable to disable %s: %s", rpFilterPath, err)
}
peer, err := netlink.LinkByName(tmpIfName)
if err != nil {
return nil, nil, fmt.Errorf("unable to lookup veth peer just created: %s", err)
}
if err = netlink.LinkSetMTU(peer, mtu); err != nil {
return nil, nil, fmt.Errorf("unable to set MTU to %q: %s", tmpIfName, err)
}
hostVeth, err := netlink.LinkByName(lxcIfName)
if err != nil {
return nil, nil, fmt.Errorf("unable to lookup veth just created: %s", err)
}
if err = netlink.LinkSetMTU(hostVeth, mtu); err != nil {
return nil, nil, fmt.Errorf("unable to set MTU to %q: %s", lxcIfName, err)
}
if err = netlink.LinkSetUp(veth); err != nil {
return nil, nil, fmt.Errorf("unable to bring up veth pair: %s", err)
}
ep.Mac = peer.Attrs().HardwareAddr.String()
ep.HostMac = hostVeth.Attrs().HardwareAddr.String()
ep.InterfaceIndex = int64(hostVeth.Attrs().Index)
ep.InterfaceName = lxcIfName
return veth, &peer, nil
} | go | func SetupVethWithNames(lxcIfName, tmpIfName string, mtu int, ep *models.EndpointChangeRequest) (*netlink.Veth, *netlink.Link, error) {
veth := &netlink.Veth{
LinkAttrs: netlink.LinkAttrs{Name: lxcIfName},
PeerName: tmpIfName,
}
if err := netlink.LinkAdd(veth); err != nil {
return nil, nil, fmt.Errorf("unable to create veth pair: %s", err)
}
var err error
defer func() {
if err != nil {
if err = netlink.LinkDel(veth); err != nil {
log.WithError(err).WithField(logfields.Veth, veth.Name).Warn("failed to clean up veth")
}
}
}()
log.WithField(logfields.VethPair, []string{veth.PeerName, lxcIfName}).Debug("Created veth pair")
// Disable reverse path filter on the host side veth peer to allow
// container addresses to be used as source address when the linux
// stack performs routing.
rpFilterPath := filepath.Join("/proc", "sys", "net", "ipv4", "conf", lxcIfName, "rp_filter")
err = WriteSysConfig(rpFilterPath, "0\n")
if err != nil {
return nil, nil, fmt.Errorf("unable to disable %s: %s", rpFilterPath, err)
}
peer, err := netlink.LinkByName(tmpIfName)
if err != nil {
return nil, nil, fmt.Errorf("unable to lookup veth peer just created: %s", err)
}
if err = netlink.LinkSetMTU(peer, mtu); err != nil {
return nil, nil, fmt.Errorf("unable to set MTU to %q: %s", tmpIfName, err)
}
hostVeth, err := netlink.LinkByName(lxcIfName)
if err != nil {
return nil, nil, fmt.Errorf("unable to lookup veth just created: %s", err)
}
if err = netlink.LinkSetMTU(hostVeth, mtu); err != nil {
return nil, nil, fmt.Errorf("unable to set MTU to %q: %s", lxcIfName, err)
}
if err = netlink.LinkSetUp(veth); err != nil {
return nil, nil, fmt.Errorf("unable to bring up veth pair: %s", err)
}
ep.Mac = peer.Attrs().HardwareAddr.String()
ep.HostMac = hostVeth.Attrs().HardwareAddr.String()
ep.InterfaceIndex = int64(hostVeth.Attrs().Index)
ep.InterfaceName = lxcIfName
return veth, &peer, nil
} | [
"func",
"SetupVethWithNames",
"(",
"lxcIfName",
",",
"tmpIfName",
"string",
",",
"mtu",
"int",
",",
"ep",
"*",
"models",
".",
"EndpointChangeRequest",
")",
"(",
"*",
"netlink",
".",
"Veth",
",",
"*",
"netlink",
".",
"Link",
",",
"error",
")",
"{",
"veth"... | // SetupVethWithNames sets up the net interface, the temporary interface and fills up some endpoint
// fields such as LXCMAC, NodeMac, IfIndex and IfName. Returns a pointer for the created
// veth, a pointer for the temporary link, the name of the temporary link and error if
// something fails. | [
"SetupVethWithNames",
"sets",
"up",
"the",
"net",
"interface",
"the",
"temporary",
"interface",
"and",
"fills",
"up",
"some",
"endpoint",
"fields",
"such",
"as",
"LXCMAC",
"NodeMac",
"IfIndex",
"and",
"IfName",
".",
"Returns",
"a",
"pointer",
"for",
"the",
"cr... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/connector/veth.go#L62-L119 |
163,945 | cilium/cilium | pkg/envoy/accesslog.go | GetNetHttpHeaders | func GetNetHttpHeaders(httpHeaders []*cilium.KeyValue) http.Header {
headers := make(http.Header)
for _, header := range httpHeaders {
headers.Add(header.Key, header.Value)
}
return headers
} | go | func GetNetHttpHeaders(httpHeaders []*cilium.KeyValue) http.Header {
headers := make(http.Header)
for _, header := range httpHeaders {
headers.Add(header.Key, header.Value)
}
return headers
} | [
"func",
"GetNetHttpHeaders",
"(",
"httpHeaders",
"[",
"]",
"*",
"cilium",
".",
"KeyValue",
")",
"http",
".",
"Header",
"{",
"headers",
":=",
"make",
"(",
"http",
".",
"Header",
")",
"\n\n",
"for",
"_",
",",
"header",
":=",
"range",
"httpHeaders",
"{",
... | // getNetHttpHeaders returns the Headers as net.http.Header | [
"getNetHttpHeaders",
"returns",
"the",
"Headers",
"as",
"net",
".",
"http",
".",
"Header"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/accesslog.go#L42-L50 |
163,946 | cilium/cilium | pkg/envoy/accesslog.go | GetProtocol | func GetProtocol(httpProtocol cilium.HttpProtocol) string {
switch httpProtocol {
case cilium.HttpProtocol_HTTP10:
return "HTTP/1"
case cilium.HttpProtocol_HTTP11:
return "HTTP/1.1"
case cilium.HttpProtocol_HTTP2:
return "HTTP/2"
default:
return "Unknown"
}
} | go | func GetProtocol(httpProtocol cilium.HttpProtocol) string {
switch httpProtocol {
case cilium.HttpProtocol_HTTP10:
return "HTTP/1"
case cilium.HttpProtocol_HTTP11:
return "HTTP/1.1"
case cilium.HttpProtocol_HTTP2:
return "HTTP/2"
default:
return "Unknown"
}
} | [
"func",
"GetProtocol",
"(",
"httpProtocol",
"cilium",
".",
"HttpProtocol",
")",
"string",
"{",
"switch",
"httpProtocol",
"{",
"case",
"cilium",
".",
"HttpProtocol_HTTP10",
":",
"return",
"\"",
"\"",
"\n",
"case",
"cilium",
".",
"HttpProtocol_HTTP11",
":",
"retur... | // getProtocol returns the HTTP protocol in the format that Cilium understands | [
"getProtocol",
"returns",
"the",
"HTTP",
"protocol",
"in",
"the",
"format",
"that",
"Cilium",
"understands"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/accesslog.go#L53-L64 |
163,947 | cilium/cilium | api/v1/health/client/restapi/get_hello_parameters.go | WithTimeout | func (o *GetHelloParams) WithTimeout(timeout time.Duration) *GetHelloParams {
o.SetTimeout(timeout)
return o
} | go | func (o *GetHelloParams) WithTimeout(timeout time.Duration) *GetHelloParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"GetHelloParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"GetHelloParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the get hello params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"get",
"hello",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/client/restapi/get_hello_parameters.go#L69-L72 |
163,948 | cilium/cilium | api/v1/health/client/restapi/get_hello_parameters.go | WithContext | func (o *GetHelloParams) WithContext(ctx context.Context) *GetHelloParams {
o.SetContext(ctx)
return o
} | go | func (o *GetHelloParams) WithContext(ctx context.Context) *GetHelloParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"GetHelloParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"GetHelloParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the get hello params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"get",
"hello",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/client/restapi/get_hello_parameters.go#L80-L83 |
163,949 | cilium/cilium | api/v1/health/client/restapi/get_hello_parameters.go | WithHTTPClient | func (o *GetHelloParams) WithHTTPClient(client *http.Client) *GetHelloParams {
o.SetHTTPClient(client)
return o
} | go | func (o *GetHelloParams) WithHTTPClient(client *http.Client) *GetHelloParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"GetHelloParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"GetHelloParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the get hello params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"get",
"hello",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/client/restapi/get_hello_parameters.go#L91-L94 |
163,950 | cilium/cilium | pkg/client/service.go | GetServices | func (c *Client) GetServices() ([]*models.Service, error) {
resp, err := c.Service.GetService(nil)
if err != nil {
return nil, Hint(err)
}
return resp.Payload, nil
} | go | func (c *Client) GetServices() ([]*models.Service, error) {
resp, err := c.Service.GetService(nil)
if err != nil {
return nil, Hint(err)
}
return resp.Payload, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetServices",
"(",
")",
"(",
"[",
"]",
"*",
"models",
".",
"Service",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"Service",
".",
"GetService",
"(",
"nil",
")",
"\n",
"if",
"err",
"!=",
"ni... | // GetServices returns a list of all services. | [
"GetServices",
"returns",
"a",
"list",
"of",
"all",
"services",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/service.go#L24-L30 |
163,951 | cilium/cilium | pkg/client/service.go | GetServiceID | func (c *Client) GetServiceID(id int64) (*models.Service, error) {
params := service.NewGetServiceIDParams().WithID(id).WithTimeout(api.ClientTimeout)
resp, err := c.Service.GetServiceID(params)
if err != nil {
return nil, Hint(err)
}
return resp.Payload, nil
} | go | func (c *Client) GetServiceID(id int64) (*models.Service, error) {
params := service.NewGetServiceIDParams().WithID(id).WithTimeout(api.ClientTimeout)
resp, err := c.Service.GetServiceID(params)
if err != nil {
return nil, Hint(err)
}
return resp.Payload, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetServiceID",
"(",
"id",
"int64",
")",
"(",
"*",
"models",
".",
"Service",
",",
"error",
")",
"{",
"params",
":=",
"service",
".",
"NewGetServiceIDParams",
"(",
")",
".",
"WithID",
"(",
"id",
")",
".",
"WithTim... | // GetServiceID returns a service by ID. | [
"GetServiceID",
"returns",
"a",
"service",
"by",
"ID",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/service.go#L33-L40 |
163,952 | cilium/cilium | pkg/client/service.go | PutServiceID | func (c *Client) PutServiceID(id int64, svc *models.ServiceSpec) (bool, error) {
svc.ID = id
params := service.NewPutServiceIDParams().WithID(id).WithConfig(svc).WithTimeout(api.ClientTimeout)
_, created, err := c.Service.PutServiceID(params)
return created != nil, Hint(err)
} | go | func (c *Client) PutServiceID(id int64, svc *models.ServiceSpec) (bool, error) {
svc.ID = id
params := service.NewPutServiceIDParams().WithID(id).WithConfig(svc).WithTimeout(api.ClientTimeout)
_, created, err := c.Service.PutServiceID(params)
return created != nil, Hint(err)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"PutServiceID",
"(",
"id",
"int64",
",",
"svc",
"*",
"models",
".",
"ServiceSpec",
")",
"(",
"bool",
",",
"error",
")",
"{",
"svc",
".",
"ID",
"=",
"id",
"\n",
"params",
":=",
"service",
".",
"NewPutServiceIDPara... | // PutServiceID creates or updates a service. Returns true if service was created. | [
"PutServiceID",
"creates",
"or",
"updates",
"a",
"service",
".",
"Returns",
"true",
"if",
"service",
"was",
"created",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/service.go#L43-L48 |
163,953 | cilium/cilium | pkg/client/service.go | DeleteServiceID | func (c *Client) DeleteServiceID(id int64) error {
params := service.NewDeleteServiceIDParams().WithID(id).WithTimeout(api.ClientTimeout)
_, err := c.Service.DeleteServiceID(params)
return Hint(err)
} | go | func (c *Client) DeleteServiceID(id int64) error {
params := service.NewDeleteServiceIDParams().WithID(id).WithTimeout(api.ClientTimeout)
_, err := c.Service.DeleteServiceID(params)
return Hint(err)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteServiceID",
"(",
"id",
"int64",
")",
"error",
"{",
"params",
":=",
"service",
".",
"NewDeleteServiceIDParams",
"(",
")",
".",
"WithID",
"(",
"id",
")",
".",
"WithTimeout",
"(",
"api",
".",
"ClientTimeout",
")"... | // DeleteServiceID deletes a service by ID. | [
"DeleteServiceID",
"deletes",
"a",
"service",
"by",
"ID",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/service.go#L51-L55 |
163,954 | cilium/cilium | api/v1/models/ip_a_m_response.go | Validate | func (m *IPAMResponse) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAddress(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 *IPAMResponse) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAddress(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",
"*",
"IPAMResponse",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateAddress",
"(",
"formats",
")",
";",
"err",
"!=",
"nil... | // Validate validates this IP a m response | [
"Validate",
"validates",
"this",
"IP",
"a",
"m",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/ip_a_m_response.go#L30-L45 |
163,955 | cilium/cilium | pkg/backoff/backoff.go | CalculateDuration | func CalculateDuration(min, max time.Duration, factor float64, jitter bool, failures int) time.Duration {
minFloat := float64(min)
maxFloat := float64(max)
t := minFloat * math.Pow(factor, float64(failures))
if max != time.Duration(0) && t > maxFloat {
t = maxFloat
}
if jitter {
t = rand.Float64()*(t-minFloat) + minFloat
}
return time.Duration(t)
} | go | func CalculateDuration(min, max time.Duration, factor float64, jitter bool, failures int) time.Duration {
minFloat := float64(min)
maxFloat := float64(max)
t := minFloat * math.Pow(factor, float64(failures))
if max != time.Duration(0) && t > maxFloat {
t = maxFloat
}
if jitter {
t = rand.Float64()*(t-minFloat) + minFloat
}
return time.Duration(t)
} | [
"func",
"CalculateDuration",
"(",
"min",
",",
"max",
"time",
".",
"Duration",
",",
"factor",
"float64",
",",
"jitter",
"bool",
",",
"failures",
"int",
")",
"time",
".",
"Duration",
"{",
"minFloat",
":=",
"float64",
"(",
"min",
")",
"\n",
"maxFloat",
":="... | // CalculateDuration calculates the backoff duration based on minimum base
// interval, exponential factor, jitter and number of failures. | [
"CalculateDuration",
"calculates",
"the",
"backoff",
"duration",
"based",
"on",
"minimum",
"base",
"interval",
"exponential",
"factor",
"jitter",
"and",
"number",
"of",
"failures",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/backoff/backoff.go#L71-L85 |
163,956 | cilium/cilium | pkg/backoff/backoff.go | Wait | func (b *Exponential) Wait(ctx context.Context) error {
b.attempt++
t := b.Duration(b.attempt)
log.WithFields(logrus.Fields{
"time": t,
"attempt": b.attempt,
"name": b.Name,
}).Debug("Sleeping with exponential backoff")
select {
case <-ctx.Done():
return fmt.Errorf("exponential backoff cancelled via context: %s", ctx.Err())
case <-time.After(t):
}
return nil
} | go | func (b *Exponential) Wait(ctx context.Context) error {
b.attempt++
t := b.Duration(b.attempt)
log.WithFields(logrus.Fields{
"time": t,
"attempt": b.attempt,
"name": b.Name,
}).Debug("Sleeping with exponential backoff")
select {
case <-ctx.Done():
return fmt.Errorf("exponential backoff cancelled via context: %s", ctx.Err())
case <-time.After(t):
}
return nil
} | [
"func",
"(",
"b",
"*",
"Exponential",
")",
"Wait",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"b",
".",
"attempt",
"++",
"\n",
"t",
":=",
"b",
".",
"Duration",
"(",
"b",
".",
"attempt",
")",
"\n\n",
"log",
".",
"WithFields",
"(",
"... | // Wait waits for the required time using an exponential backoff | [
"Wait",
"waits",
"for",
"the",
"required",
"time",
"using",
"an",
"exponential",
"backoff"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/backoff/backoff.go#L88-L105 |
163,957 | cilium/cilium | pkg/backoff/backoff.go | Duration | func (b *Exponential) Duration(attempt int) time.Duration {
if b.Name == "" {
b.Name = uuid.NewUUID().String()
}
min := time.Duration(1) * time.Second
if b.Min != time.Duration(0) {
min = b.Min
}
factor := float64(2)
if b.Factor != float64(0) {
factor = b.Factor
}
t := CalculateDuration(min, b.Max, factor, b.Jitter, attempt)
if b.NodeManager != nil {
t = b.NodeManager.ClusterSizeDependantInterval(t)
}
if b.Max != time.Duration(0) && t > b.Max {
t = b.Max
}
return t
} | go | func (b *Exponential) Duration(attempt int) time.Duration {
if b.Name == "" {
b.Name = uuid.NewUUID().String()
}
min := time.Duration(1) * time.Second
if b.Min != time.Duration(0) {
min = b.Min
}
factor := float64(2)
if b.Factor != float64(0) {
factor = b.Factor
}
t := CalculateDuration(min, b.Max, factor, b.Jitter, attempt)
if b.NodeManager != nil {
t = b.NodeManager.ClusterSizeDependantInterval(t)
}
if b.Max != time.Duration(0) && t > b.Max {
t = b.Max
}
return t
} | [
"func",
"(",
"b",
"*",
"Exponential",
")",
"Duration",
"(",
"attempt",
"int",
")",
"time",
".",
"Duration",
"{",
"if",
"b",
".",
"Name",
"==",
"\"",
"\"",
"{",
"b",
".",
"Name",
"=",
"uuid",
".",
"NewUUID",
"(",
")",
".",
"String",
"(",
")",
"\... | // Duration returns the wait duration for the nth attempt | [
"Duration",
"returns",
"the",
"wait",
"duration",
"for",
"the",
"nth",
"attempt"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/backoff/backoff.go#L108-L134 |
163,958 | cilium/cilium | pkg/datapath/loader/template.go | wrap | func wrap(cfg datapath.EndpointConfiguration, stats *SpanStat) *templateCfg {
if stats == nil {
stats = &SpanStat{}
}
return &templateCfg{
EndpointConfiguration: cfg,
stats: stats,
}
} | go | func wrap(cfg datapath.EndpointConfiguration, stats *SpanStat) *templateCfg {
if stats == nil {
stats = &SpanStat{}
}
return &templateCfg{
EndpointConfiguration: cfg,
stats: stats,
}
} | [
"func",
"wrap",
"(",
"cfg",
"datapath",
".",
"EndpointConfiguration",
",",
"stats",
"*",
"SpanStat",
")",
"*",
"templateCfg",
"{",
"if",
"stats",
"==",
"nil",
"{",
"stats",
"=",
"&",
"SpanStat",
"{",
"}",
"\n",
"}",
"\n",
"return",
"&",
"templateCfg",
... | // wrap takes an endpoint configuration and optional stats tracker and wraps
// it inside a templateCfg which hides static data from callers that wish to
// generate header files based on the configuration, substituting it for
// template data. | [
"wrap",
"takes",
"an",
"endpoint",
"configuration",
"and",
"optional",
"stats",
"tracker",
"and",
"wraps",
"it",
"inside",
"a",
"templateCfg",
"which",
"hides",
"static",
"data",
"from",
"callers",
"that",
"wish",
"to",
"generate",
"header",
"files",
"based",
... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/template.go#L120-L128 |
163,959 | cilium/cilium | pkg/datapath/loader/template.go | elfMapSubstitutions | func elfMapSubstitutions(ep endpoint) map[string]string {
result := make(map[string]string)
epID := uint16(ep.GetID())
for _, name := range elfMapPrefixes {
templateStr := bpf.LocalMapName(name, TemplateLxcID)
desiredStr := bpf.LocalMapName(name, epID)
result[templateStr] = desiredStr
}
if ep.ConntrackLocalLocked() {
for _, name := range elfCtMapPrefixes {
templateStr := bpf.LocalMapName(name, TemplateLxcID)
desiredStr := bpf.LocalMapName(name, epID)
result[templateStr] = desiredStr
}
}
result[policymap.CallString(TemplateLxcID)] = policymap.CallString(epID)
return result
} | go | func elfMapSubstitutions(ep endpoint) map[string]string {
result := make(map[string]string)
epID := uint16(ep.GetID())
for _, name := range elfMapPrefixes {
templateStr := bpf.LocalMapName(name, TemplateLxcID)
desiredStr := bpf.LocalMapName(name, epID)
result[templateStr] = desiredStr
}
if ep.ConntrackLocalLocked() {
for _, name := range elfCtMapPrefixes {
templateStr := bpf.LocalMapName(name, TemplateLxcID)
desiredStr := bpf.LocalMapName(name, epID)
result[templateStr] = desiredStr
}
}
result[policymap.CallString(TemplateLxcID)] = policymap.CallString(epID)
return result
} | [
"func",
"elfMapSubstitutions",
"(",
"ep",
"endpoint",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"result",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n\n",
"epID",
":=",
"uint16",
"(",
"ep",
".",
"GetID",
"(",
")",
")",
"\n",
... | // elfMapSubstitutions returns the set of map substitutions that must occur in
// an ELF template object file to update map references for the specified
// endpoint. | [
"elfMapSubstitutions",
"returns",
"the",
"set",
"of",
"map",
"substitutions",
"that",
"must",
"occur",
"in",
"an",
"ELF",
"template",
"object",
"file",
"to",
"update",
"map",
"references",
"for",
"the",
"specified",
"endpoint",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/template.go#L133-L152 |
163,960 | cilium/cilium | pkg/datapath/loader/template.go | sliceToU16 | func sliceToU16(input []byte) uint16 {
result := uint16(input[0]) << 8
result |= uint16(input[1])
return result
} | go | func sliceToU16(input []byte) uint16 {
result := uint16(input[0]) << 8
result |= uint16(input[1])
return result
} | [
"func",
"sliceToU16",
"(",
"input",
"[",
"]",
"byte",
")",
"uint16",
"{",
"result",
":=",
"uint16",
"(",
"input",
"[",
"0",
"]",
")",
"<<",
"8",
"\n",
"result",
"|=",
"uint16",
"(",
"input",
"[",
"1",
"]",
")",
"\n",
"return",
"result",
"\n",
"}"... | // sliceToU16 converts the input slice of two bytes to a uint16. | [
"sliceToU16",
"converts",
"the",
"input",
"slice",
"of",
"two",
"bytes",
"to",
"a",
"uint16",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/template.go#L155-L159 |
163,961 | cilium/cilium | pkg/datapath/loader/template.go | sliceToU32 | func sliceToU32(input []byte) uint32 {
result := uint32(input[0]) << 24
result |= uint32(input[1]) << 16
result |= uint32(input[2]) << 8
result |= uint32(input[3])
return result
} | go | func sliceToU32(input []byte) uint32 {
result := uint32(input[0]) << 24
result |= uint32(input[1]) << 16
result |= uint32(input[2]) << 8
result |= uint32(input[3])
return result
} | [
"func",
"sliceToU32",
"(",
"input",
"[",
"]",
"byte",
")",
"uint32",
"{",
"result",
":=",
"uint32",
"(",
"input",
"[",
"0",
"]",
")",
"<<",
"24",
"\n",
"result",
"|=",
"uint32",
"(",
"input",
"[",
"1",
"]",
")",
"<<",
"16",
"\n",
"result",
"|=",
... | // sliceToU32 converts the input slice of four bytes to a uint32. | [
"sliceToU32",
"converts",
"the",
"input",
"slice",
"of",
"four",
"bytes",
"to",
"a",
"uint32",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/template.go#L167-L173 |
163,962 | cilium/cilium | pkg/datapath/loader/template.go | elfVariableSubstitutions | func elfVariableSubstitutions(ep endpoint) map[string]uint32 {
result := make(map[string]uint32)
if ipv6 := ep.IPv6Address(); ipv6 != nil {
// Corresponds to DEFINE_IPV6() in bpf/lib/utils.h
result["LXC_IP_1"] = sliceToBe32(ipv6[0:4])
result["LXC_IP_2"] = sliceToBe32(ipv6[4:8])
result["LXC_IP_3"] = sliceToBe32(ipv6[8:12])
result["LXC_IP_4"] = sliceToBe32(ipv6[12:16])
}
if ipv4 := ep.IPv4Address(); ipv4 != nil {
result["LXC_IPV4"] = byteorder.HostSliceToNetwork(ipv4, reflect.Uint32).(uint32)
}
mac := ep.GetNodeMAC()
result["NODE_MAC_1"] = sliceToBe32(mac[0:4])
result["NODE_MAC_2"] = uint32(sliceToBe16(mac[4:6]))
result["LXC_ID"] = uint32(ep.GetID())
identity := ep.GetIdentity().Uint32()
result["SECLABEL"] = identity
result["SECLABEL_NB"] = byteorder.HostToNetwork(identity).(uint32)
return result
} | go | func elfVariableSubstitutions(ep endpoint) map[string]uint32 {
result := make(map[string]uint32)
if ipv6 := ep.IPv6Address(); ipv6 != nil {
// Corresponds to DEFINE_IPV6() in bpf/lib/utils.h
result["LXC_IP_1"] = sliceToBe32(ipv6[0:4])
result["LXC_IP_2"] = sliceToBe32(ipv6[4:8])
result["LXC_IP_3"] = sliceToBe32(ipv6[8:12])
result["LXC_IP_4"] = sliceToBe32(ipv6[12:16])
}
if ipv4 := ep.IPv4Address(); ipv4 != nil {
result["LXC_IPV4"] = byteorder.HostSliceToNetwork(ipv4, reflect.Uint32).(uint32)
}
mac := ep.GetNodeMAC()
result["NODE_MAC_1"] = sliceToBe32(mac[0:4])
result["NODE_MAC_2"] = uint32(sliceToBe16(mac[4:6]))
result["LXC_ID"] = uint32(ep.GetID())
identity := ep.GetIdentity().Uint32()
result["SECLABEL"] = identity
result["SECLABEL_NB"] = byteorder.HostToNetwork(identity).(uint32)
return result
} | [
"func",
"elfVariableSubstitutions",
"(",
"ep",
"endpoint",
")",
"map",
"[",
"string",
"]",
"uint32",
"{",
"result",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"uint32",
")",
"\n\n",
"if",
"ipv6",
":=",
"ep",
".",
"IPv6Address",
"(",
")",
";",
"ipv6"... | // elfVariableSubstitutions returns the set of data substitutions that must
// occur in an ELF template object file to update static data for the specified
// endpoint. | [
"elfVariableSubstitutions",
"returns",
"the",
"set",
"of",
"data",
"substitutions",
"that",
"must",
"occur",
"in",
"an",
"ELF",
"template",
"object",
"file",
"to",
"update",
"static",
"data",
"for",
"the",
"specified",
"endpoint",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/template.go#L183-L207 |
163,963 | cilium/cilium | pkg/datapath/loader/template.go | ELFSubstitutions | func ELFSubstitutions(ep endpoint) (map[string]uint32, map[string]string) {
return elfVariableSubstitutions(ep), elfMapSubstitutions(ep)
} | go | func ELFSubstitutions(ep endpoint) (map[string]uint32, map[string]string) {
return elfVariableSubstitutions(ep), elfMapSubstitutions(ep)
} | [
"func",
"ELFSubstitutions",
"(",
"ep",
"endpoint",
")",
"(",
"map",
"[",
"string",
"]",
"uint32",
",",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"return",
"elfVariableSubstitutions",
"(",
"ep",
")",
",",
"elfMapSubstitutions",
"(",
"ep",
")",
"\n",
... | // ELFSubstitutions fetches the set of variable and map substitutions that
// must be implemented against an ELF template to configure the datapath for
// the specified endpoint. | [
"ELFSubstitutions",
"fetches",
"the",
"set",
"of",
"variable",
"and",
"map",
"substitutions",
"that",
"must",
"be",
"implemented",
"against",
"an",
"ELF",
"template",
"to",
"configure",
"the",
"datapath",
"for",
"the",
"specified",
"endpoint",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/template.go#L212-L214 |
163,964 | cilium/cilium | api/v1/models/zz_generated.deepcopy.go | DeepCopy | func (in *ControllerStatus) DeepCopy() *ControllerStatus {
if in == nil {
return nil
}
out := new(ControllerStatus)
in.DeepCopyInto(out)
return out
} | go | func (in *ControllerStatus) DeepCopy() *ControllerStatus {
if in == nil {
return nil
}
out := new(ControllerStatus)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"ControllerStatus",
")",
"DeepCopy",
"(",
")",
"*",
"ControllerStatus",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"ControllerStatus",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",... | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControllerStatus. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"ControllerStatus",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/zz_generated.deepcopy.go#L75-L82 |
163,965 | cilium/cilium | api/v1/models/zz_generated.deepcopy.go | DeepCopy | func (in *ControllerStatusStatus) DeepCopy() *ControllerStatusStatus {
if in == nil {
return nil
}
out := new(ControllerStatusStatus)
in.DeepCopyInto(out)
return out
} | go | func (in *ControllerStatusStatus) DeepCopy() *ControllerStatusStatus {
if in == nil {
return nil
}
out := new(ControllerStatusStatus)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"ControllerStatusStatus",
")",
"DeepCopy",
"(",
")",
"*",
"ControllerStatusStatus",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"ControllerStatusStatus",
")",
"\n",
"in",
".",
"Dee... | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControllerStatusStatus. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"ControllerStatusStatus",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/zz_generated.deepcopy.go#L93-L100 |
163,966 | cilium/cilium | api/v1/models/zz_generated.deepcopy.go | DeepCopy | func (in *IPAMStatus) DeepCopy() *IPAMStatus {
if in == nil {
return nil
}
out := new(IPAMStatus)
in.DeepCopyInto(out)
return out
} | go | func (in *IPAMStatus) DeepCopy() *IPAMStatus {
if in == nil {
return nil
}
out := new(IPAMStatus)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"IPAMStatus",
")",
"DeepCopy",
"(",
")",
"*",
"IPAMStatus",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"IPAMStatus",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
... | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAMStatus. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"IPAMStatus",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/zz_generated.deepcopy.go#L119-L126 |
163,967 | cilium/cilium | api/v1/models/zz_generated.deepcopy.go | DeepCopy | func (in *K8sStatus) DeepCopy() *K8sStatus {
if in == nil {
return nil
}
out := new(K8sStatus)
in.DeepCopyInto(out)
return out
} | go | func (in *K8sStatus) DeepCopy() *K8sStatus {
if in == nil {
return nil
}
out := new(K8sStatus)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"K8sStatus",
")",
"DeepCopy",
"(",
")",
"*",
"K8sStatus",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"K8sStatus",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\... | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new K8sStatus. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"K8sStatus",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/zz_generated.deepcopy.go#L140-L147 |
163,968 | cilium/cilium | api/v1/models/zz_generated.deepcopy.go | DeepCopy | func (in *NodeAddressing) DeepCopy() *NodeAddressing {
if in == nil {
return nil
}
out := new(NodeAddressing)
in.DeepCopyInto(out)
return out
} | go | func (in *NodeAddressing) DeepCopy() *NodeAddressing {
if in == nil {
return nil
}
out := new(NodeAddressing)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"NodeAddressing",
")",
"DeepCopy",
"(",
")",
"*",
"NodeAddressing",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"NodeAddressing",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"ou... | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeAddressing. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"NodeAddressing",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/zz_generated.deepcopy.go#L166-L173 |
163,969 | cilium/cilium | api/v1/models/zz_generated.deepcopy.go | DeepCopy | func (in *NodeElement) DeepCopy() *NodeElement {
if in == nil {
return nil
}
out := new(NodeElement)
in.DeepCopyInto(out)
return out
} | go | func (in *NodeElement) DeepCopy() *NodeElement {
if in == nil {
return nil
}
out := new(NodeElement)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"NodeElement",
")",
"DeepCopy",
"(",
")",
"*",
"NodeElement",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"NodeElement",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")"... | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeElement. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"NodeElement",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/zz_generated.deepcopy.go#L203-L210 |
163,970 | cilium/cilium | api/v1/models/zz_generated.deepcopy.go | DeepCopy | func (in *ProxyStatistics) DeepCopy() *ProxyStatistics {
if in == nil {
return nil
}
out := new(ProxyStatistics)
in.DeepCopyInto(out)
return out
} | go | func (in *ProxyStatistics) DeepCopy() *ProxyStatistics {
if in == nil {
return nil
}
out := new(ProxyStatistics)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"ProxyStatistics",
")",
"DeepCopy",
"(",
")",
"*",
"ProxyStatistics",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"ProxyStatistics",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
... | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProxyStatistics. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"ProxyStatistics",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/zz_generated.deepcopy.go#L224-L231 |
163,971 | cilium/cilium | api/v1/models/zz_generated.deepcopy.go | DeepCopy | func (in *RequestResponseStatistics) DeepCopy() *RequestResponseStatistics {
if in == nil {
return nil
}
out := new(RequestResponseStatistics)
in.DeepCopyInto(out)
return out
} | go | func (in *RequestResponseStatistics) DeepCopy() *RequestResponseStatistics {
if in == nil {
return nil
}
out := new(RequestResponseStatistics)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"RequestResponseStatistics",
")",
"DeepCopy",
"(",
")",
"*",
"RequestResponseStatistics",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"RequestResponseStatistics",
")",
"\n",
"in",
".... | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RequestResponseStatistics. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"RequestResponseStatistics",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/zz_generated.deepcopy.go#L250-L257 |
163,972 | cilium/cilium | api/v1/models/zz_generated.deepcopy.go | DeepCopy | func (in *StatusResponse) DeepCopy() *StatusResponse {
if in == nil {
return nil
}
out := new(StatusResponse)
in.DeepCopyInto(out)
return out
} | go | func (in *StatusResponse) DeepCopy() *StatusResponse {
if in == nil {
return nil
}
out := new(StatusResponse)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"StatusResponse",
")",
"DeepCopy",
"(",
")",
"*",
"StatusResponse",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"StatusResponse",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"ou... | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StatusResponse. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"StatusResponse",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/zz_generated.deepcopy.go#L324-L331 |
163,973 | cilium/cilium | pkg/k8s/client/informers/externalversions/cilium.io/v2/ciliumendpoint.go | NewCiliumEndpointInformer | func NewCiliumEndpointInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredCiliumEndpointInformer(client, namespace, resyncPeriod, indexers, nil)
} | go | func NewCiliumEndpointInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredCiliumEndpointInformer(client, namespace, resyncPeriod, indexers, nil)
} | [
"func",
"NewCiliumEndpointInformer",
"(",
"client",
"versioned",
".",
"Interface",
",",
"namespace",
"string",
",",
"resyncPeriod",
"time",
".",
"Duration",
",",
"indexers",
"cache",
".",
"Indexers",
")",
"cache",
".",
"SharedIndexInformer",
"{",
"return",
"NewFil... | // NewCiliumEndpointInformer constructs a new informer for CiliumEndpoint type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server. | [
"NewCiliumEndpointInformer",
"constructs",
"a",
"new",
"informer",
"for",
"CiliumEndpoint",
"type",
".",
"Always",
"prefer",
"using",
"an",
"informer",
"factory",
"to",
"get",
"a",
"shared",
"informer",
"instead",
"of",
"getting",
"an",
"independent",
"one",
".",
... | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/client/informers/externalversions/cilium.io/v2/ciliumendpoint.go#L48-L50 |
163,974 | cilium/cilium | api/v1/client/daemon/get_map_parameters.go | WithTimeout | func (o *GetMapParams) WithTimeout(timeout time.Duration) *GetMapParams {
o.SetTimeout(timeout)
return o
} | go | func (o *GetMapParams) WithTimeout(timeout time.Duration) *GetMapParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"GetMapParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"GetMapParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the get map params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"get",
"map",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/daemon/get_map_parameters.go#L69-L72 |
163,975 | cilium/cilium | api/v1/client/daemon/get_map_parameters.go | WithContext | func (o *GetMapParams) WithContext(ctx context.Context) *GetMapParams {
o.SetContext(ctx)
return o
} | go | func (o *GetMapParams) WithContext(ctx context.Context) *GetMapParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"GetMapParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"GetMapParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the get map params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"get",
"map",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/daemon/get_map_parameters.go#L80-L83 |
163,976 | cilium/cilium | api/v1/client/daemon/get_map_parameters.go | WithHTTPClient | func (o *GetMapParams) WithHTTPClient(client *http.Client) *GetMapParams {
o.SetHTTPClient(client)
return o
} | go | func (o *GetMapParams) WithHTTPClient(client *http.Client) *GetMapParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"GetMapParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"GetMapParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the get map params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"get",
"map",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/daemon/get_map_parameters.go#L91-L94 |
163,977 | cilium/cilium | api/v1/client/metrics/get_metrics_parameters.go | WithTimeout | func (o *GetMetricsParams) WithTimeout(timeout time.Duration) *GetMetricsParams {
o.SetTimeout(timeout)
return o
} | go | func (o *GetMetricsParams) WithTimeout(timeout time.Duration) *GetMetricsParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"GetMetricsParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"GetMetricsParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the get metrics params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"get",
"metrics",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/metrics/get_metrics_parameters.go#L69-L72 |
163,978 | cilium/cilium | api/v1/client/metrics/get_metrics_parameters.go | WithContext | func (o *GetMetricsParams) WithContext(ctx context.Context) *GetMetricsParams {
o.SetContext(ctx)
return o
} | go | func (o *GetMetricsParams) WithContext(ctx context.Context) *GetMetricsParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"GetMetricsParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"GetMetricsParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the get metrics params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"get",
"metrics",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/metrics/get_metrics_parameters.go#L80-L83 |
163,979 | cilium/cilium | api/v1/client/metrics/get_metrics_parameters.go | WithHTTPClient | func (o *GetMetricsParams) WithHTTPClient(client *http.Client) *GetMetricsParams {
o.SetHTTPClient(client)
return o
} | go | func (o *GetMetricsParams) WithHTTPClient(client *http.Client) *GetMetricsParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"GetMetricsParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"GetMetricsParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the get metrics params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"get",
"metrics",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/metrics/get_metrics_parameters.go#L91-L94 |
163,980 | cilium/cilium | pkg/proxy/envoyproxy.go | createEnvoyRedirect | func createEnvoyRedirect(r *Redirect, stateDir string, xdsServer *envoy.XDSServer, wg *completion.WaitGroup) (RedirectImplementation, error) {
envoyOnce.Do(func() {
// Start Envoy on first invocation
envoyProxy = envoy.StartEnvoy(stateDir, option.Config.EnvoyLogPath, 0)
})
l := r.listener
if envoyProxy != nil {
redir := &envoyRedirect{
listenerName: fmt.Sprintf("%s:%d", l.name, l.proxyPort),
xdsServer: xdsServer,
}
xdsServer.AddListener(redir.listenerName, l.parserType, l.proxyPort, l.ingress, wg)
return redir, nil
}
return nil, fmt.Errorf("%s: Envoy proxy process failed to start, cannot add redirect", l.name)
} | go | func createEnvoyRedirect(r *Redirect, stateDir string, xdsServer *envoy.XDSServer, wg *completion.WaitGroup) (RedirectImplementation, error) {
envoyOnce.Do(func() {
// Start Envoy on first invocation
envoyProxy = envoy.StartEnvoy(stateDir, option.Config.EnvoyLogPath, 0)
})
l := r.listener
if envoyProxy != nil {
redir := &envoyRedirect{
listenerName: fmt.Sprintf("%s:%d", l.name, l.proxyPort),
xdsServer: xdsServer,
}
xdsServer.AddListener(redir.listenerName, l.parserType, l.proxyPort, l.ingress, wg)
return redir, nil
}
return nil, fmt.Errorf("%s: Envoy proxy process failed to start, cannot add redirect", l.name)
} | [
"func",
"createEnvoyRedirect",
"(",
"r",
"*",
"Redirect",
",",
"stateDir",
"string",
",",
"xdsServer",
"*",
"envoy",
".",
"XDSServer",
",",
"wg",
"*",
"completion",
".",
"WaitGroup",
")",
"(",
"RedirectImplementation",
",",
"error",
")",
"{",
"envoyOnce",
".... | // createEnvoyRedirect creates a redirect with corresponding proxy
// configuration. This will launch a proxy instance. | [
"createEnvoyRedirect",
"creates",
"a",
"redirect",
"with",
"corresponding",
"proxy",
"configuration",
".",
"This",
"will",
"launch",
"a",
"proxy",
"instance",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/envoyproxy.go#L41-L60 |
163,981 | cilium/cilium | pkg/proxy/envoyproxy.go | UpdateRules | func (k *envoyRedirect) UpdateRules(wg *completion.WaitGroup, l4 *policy.L4Filter) (revert.RevertFunc, error) {
return func() error { return nil }, nil
} | go | func (k *envoyRedirect) UpdateRules(wg *completion.WaitGroup, l4 *policy.L4Filter) (revert.RevertFunc, error) {
return func() error { return nil }, nil
} | [
"func",
"(",
"k",
"*",
"envoyRedirect",
")",
"UpdateRules",
"(",
"wg",
"*",
"completion",
".",
"WaitGroup",
",",
"l4",
"*",
"policy",
".",
"L4Filter",
")",
"(",
"revert",
".",
"RevertFunc",
",",
"error",
")",
"{",
"return",
"func",
"(",
")",
"error",
... | // UpdateRules is a no-op for envoy, as redirect data is synchronized via the
// xDS cache. | [
"UpdateRules",
"is",
"a",
"no",
"-",
"op",
"for",
"envoy",
"as",
"redirect",
"data",
"is",
"synchronized",
"via",
"the",
"xDS",
"cache",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/envoyproxy.go#L64-L66 |
163,982 | cilium/cilium | api/v1/client/prefilter/patch_prefilter_parameters.go | WithTimeout | func (o *PatchPrefilterParams) WithTimeout(timeout time.Duration) *PatchPrefilterParams {
o.SetTimeout(timeout)
return o
} | go | func (o *PatchPrefilterParams) WithTimeout(timeout time.Duration) *PatchPrefilterParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"PatchPrefilterParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"PatchPrefilterParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the patch prefilter params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"patch",
"prefilter",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/prefilter/patch_prefilter_parameters.go#L78-L81 |
163,983 | cilium/cilium | api/v1/client/prefilter/patch_prefilter_parameters.go | WithContext | func (o *PatchPrefilterParams) WithContext(ctx context.Context) *PatchPrefilterParams {
o.SetContext(ctx)
return o
} | go | func (o *PatchPrefilterParams) WithContext(ctx context.Context) *PatchPrefilterParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"PatchPrefilterParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"PatchPrefilterParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the patch prefilter params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"patch",
"prefilter",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/prefilter/patch_prefilter_parameters.go#L89-L92 |
163,984 | cilium/cilium | api/v1/client/prefilter/patch_prefilter_parameters.go | WithHTTPClient | func (o *PatchPrefilterParams) WithHTTPClient(client *http.Client) *PatchPrefilterParams {
o.SetHTTPClient(client)
return o
} | go | func (o *PatchPrefilterParams) WithHTTPClient(client *http.Client) *PatchPrefilterParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"PatchPrefilterParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"PatchPrefilterParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the patch prefilter params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"patch",
"prefilter",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/prefilter/patch_prefilter_parameters.go#L100-L103 |
163,985 | cilium/cilium | api/v1/client/prefilter/patch_prefilter_parameters.go | WithPrefilterSpec | func (o *PatchPrefilterParams) WithPrefilterSpec(prefilterSpec *models.PrefilterSpec) *PatchPrefilterParams {
o.SetPrefilterSpec(prefilterSpec)
return o
} | go | func (o *PatchPrefilterParams) WithPrefilterSpec(prefilterSpec *models.PrefilterSpec) *PatchPrefilterParams {
o.SetPrefilterSpec(prefilterSpec)
return o
} | [
"func",
"(",
"o",
"*",
"PatchPrefilterParams",
")",
"WithPrefilterSpec",
"(",
"prefilterSpec",
"*",
"models",
".",
"PrefilterSpec",
")",
"*",
"PatchPrefilterParams",
"{",
"o",
".",
"SetPrefilterSpec",
"(",
"prefilterSpec",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPrefilterSpec adds the prefilterSpec to the patch prefilter params | [
"WithPrefilterSpec",
"adds",
"the",
"prefilterSpec",
"to",
"the",
"patch",
"prefilter",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/prefilter/patch_prefilter_parameters.go#L111-L114 |
163,986 | confluentinc/confluent-kafka-go | kafka/error.go | String | func (e Error) String() string {
var errstr string
if len(e.str) > 0 {
errstr = e.str
} else {
errstr = e.code.String()
}
if e.IsFatal() {
return fmt.Sprintf("Fatal error: %s", errstr)
}
return errstr
} | go | func (e Error) String() string {
var errstr string
if len(e.str) > 0 {
errstr = e.str
} else {
errstr = e.code.String()
}
if e.IsFatal() {
return fmt.Sprintf("Fatal error: %s", errstr)
}
return errstr
} | [
"func",
"(",
"e",
"Error",
")",
"String",
"(",
")",
"string",
"{",
"var",
"errstr",
"string",
"\n",
"if",
"len",
"(",
"e",
".",
"str",
")",
">",
"0",
"{",
"errstr",
"=",
"e",
".",
"str",
"\n",
"}",
"else",
"{",
"errstr",
"=",
"e",
".",
"code"... | // String returns a human readable representation of an Error | [
"String",
"returns",
"a",
"human",
"readable",
"representation",
"of",
"an",
"Error"
] | cfbc1edb6a54515310a0c7840bf4a24159b51876 | https://github.com/confluentinc/confluent-kafka-go/blob/cfbc1edb6a54515310a0c7840bf4a24159b51876/kafka/error.go#L75-L88 |
163,987 | confluentinc/confluent-kafka-go | kafka/error.go | getFatalError | func getFatalError(H Handle) error {
cErrstr := (*C.char)(C.malloc(C.size_t(512)))
defer C.free(unsafe.Pointer(cErrstr))
cErr := C.rd_kafka_fatal_error(H.gethandle().rk, cErrstr, 512)
if int(cErr) == 0 {
return nil
}
err := newErrorFromCString(cErr, cErrstr)
err.fatal = true
return err
} | go | func getFatalError(H Handle) error {
cErrstr := (*C.char)(C.malloc(C.size_t(512)))
defer C.free(unsafe.Pointer(cErrstr))
cErr := C.rd_kafka_fatal_error(H.gethandle().rk, cErrstr, 512)
if int(cErr) == 0 {
return nil
}
err := newErrorFromCString(cErr, cErrstr)
err.fatal = true
return err
} | [
"func",
"getFatalError",
"(",
"H",
"Handle",
")",
"error",
"{",
"cErrstr",
":=",
"(",
"*",
"C",
".",
"char",
")",
"(",
"C",
".",
"malloc",
"(",
"C",
".",
"size_t",
"(",
"512",
")",
")",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
... | // getFatalError returns an Error object if the client instance has raised a fatal error, else nil. | [
"getFatalError",
"returns",
"an",
"Error",
"object",
"if",
"the",
"client",
"instance",
"has",
"raised",
"a",
"fatal",
"error",
"else",
"nil",
"."
] | cfbc1edb6a54515310a0c7840bf4a24159b51876 | https://github.com/confluentinc/confluent-kafka-go/blob/cfbc1edb6a54515310a0c7840bf4a24159b51876/kafka/error.go#L104-L117 |
163,988 | confluentinc/confluent-kafka-go | kafka/kafka.go | newCPartsFromTopicPartitions | func newCPartsFromTopicPartitions(partitions []TopicPartition) (cparts *C.rd_kafka_topic_partition_list_t) {
cparts = C.rd_kafka_topic_partition_list_new(C.int(len(partitions)))
for _, part := range partitions {
ctopic := C.CString(*part.Topic)
defer C.free(unsafe.Pointer(ctopic))
rktpar := C.rd_kafka_topic_partition_list_add(cparts, ctopic, C.int32_t(part.Partition))
rktpar.offset = C.int64_t(part.Offset)
}
return cparts
} | go | func newCPartsFromTopicPartitions(partitions []TopicPartition) (cparts *C.rd_kafka_topic_partition_list_t) {
cparts = C.rd_kafka_topic_partition_list_new(C.int(len(partitions)))
for _, part := range partitions {
ctopic := C.CString(*part.Topic)
defer C.free(unsafe.Pointer(ctopic))
rktpar := C.rd_kafka_topic_partition_list_add(cparts, ctopic, C.int32_t(part.Partition))
rktpar.offset = C.int64_t(part.Offset)
}
return cparts
} | [
"func",
"newCPartsFromTopicPartitions",
"(",
"partitions",
"[",
"]",
"TopicPartition",
")",
"(",
"cparts",
"*",
"C",
".",
"rd_kafka_topic_partition_list_t",
")",
"{",
"cparts",
"=",
"C",
".",
"rd_kafka_topic_partition_list_new",
"(",
"C",
".",
"int",
"(",
"len",
... | // new_cparts_from_TopicPartitions creates a new C rd_kafka_topic_partition_list_t
// from a TopicPartition array. | [
"new_cparts_from_TopicPartitions",
"creates",
"a",
"new",
"C",
"rd_kafka_topic_partition_list_t",
"from",
"a",
"TopicPartition",
"array",
"."
] | cfbc1edb6a54515310a0c7840bf4a24159b51876 | https://github.com/confluentinc/confluent-kafka-go/blob/cfbc1edb6a54515310a0c7840bf4a24159b51876/kafka/kafka.go#L200-L210 |
163,989 | confluentinc/confluent-kafka-go | kafka/consumer.go | Subscribe | func (c *Consumer) Subscribe(topic string, rebalanceCb RebalanceCb) error {
return c.SubscribeTopics([]string{topic}, rebalanceCb)
} | go | func (c *Consumer) Subscribe(topic string, rebalanceCb RebalanceCb) error {
return c.SubscribeTopics([]string{topic}, rebalanceCb)
} | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"Subscribe",
"(",
"topic",
"string",
",",
"rebalanceCb",
"RebalanceCb",
")",
"error",
"{",
"return",
"c",
".",
"SubscribeTopics",
"(",
"[",
"]",
"string",
"{",
"topic",
"}",
",",
"rebalanceCb",
")",
"\n",
"}"
] | // Subscribe to a single topic
// This replaces the current subscription | [
"Subscribe",
"to",
"a",
"single",
"topic",
"This",
"replaces",
"the",
"current",
"subscription"
] | cfbc1edb6a54515310a0c7840bf4a24159b51876 | https://github.com/confluentinc/confluent-kafka-go/blob/cfbc1edb6a54515310a0c7840bf4a24159b51876/kafka/consumer.go#L64-L66 |
163,990 | confluentinc/confluent-kafka-go | kafka/consumer.go | SubscribeTopics | func (c *Consumer) SubscribeTopics(topics []string, rebalanceCb RebalanceCb) (err error) {
ctopics := C.rd_kafka_topic_partition_list_new(C.int(len(topics)))
defer C.rd_kafka_topic_partition_list_destroy(ctopics)
for _, topic := range topics {
ctopic := C.CString(topic)
defer C.free(unsafe.Pointer(ctopic))
C.rd_kafka_topic_partition_list_add(ctopics, ctopic, C.RD_KAFKA_PARTITION_UA)
}
e := C.rd_kafka_subscribe(c.handle.rk, ctopics)
if e != C.RD_KAFKA_RESP_ERR_NO_ERROR {
return newError(e)
}
c.rebalanceCb = rebalanceCb
c.handle.currAppRebalanceEnable = c.rebalanceCb != nil || c.appRebalanceEnable
return nil
} | go | func (c *Consumer) SubscribeTopics(topics []string, rebalanceCb RebalanceCb) (err error) {
ctopics := C.rd_kafka_topic_partition_list_new(C.int(len(topics)))
defer C.rd_kafka_topic_partition_list_destroy(ctopics)
for _, topic := range topics {
ctopic := C.CString(topic)
defer C.free(unsafe.Pointer(ctopic))
C.rd_kafka_topic_partition_list_add(ctopics, ctopic, C.RD_KAFKA_PARTITION_UA)
}
e := C.rd_kafka_subscribe(c.handle.rk, ctopics)
if e != C.RD_KAFKA_RESP_ERR_NO_ERROR {
return newError(e)
}
c.rebalanceCb = rebalanceCb
c.handle.currAppRebalanceEnable = c.rebalanceCb != nil || c.appRebalanceEnable
return nil
} | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"SubscribeTopics",
"(",
"topics",
"[",
"]",
"string",
",",
"rebalanceCb",
"RebalanceCb",
")",
"(",
"err",
"error",
")",
"{",
"ctopics",
":=",
"C",
".",
"rd_kafka_topic_partition_list_new",
"(",
"C",
".",
"int",
"(",
... | // SubscribeTopics subscribes to the provided list of topics.
// This replaces the current subscription. | [
"SubscribeTopics",
"subscribes",
"to",
"the",
"provided",
"list",
"of",
"topics",
".",
"This",
"replaces",
"the",
"current",
"subscription",
"."
] | cfbc1edb6a54515310a0c7840bf4a24159b51876 | https://github.com/confluentinc/confluent-kafka-go/blob/cfbc1edb6a54515310a0c7840bf4a24159b51876/kafka/consumer.go#L70-L89 |
163,991 | confluentinc/confluent-kafka-go | kafka/consumer.go | Unsubscribe | func (c *Consumer) Unsubscribe() (err error) {
C.rd_kafka_unsubscribe(c.handle.rk)
return nil
} | go | func (c *Consumer) Unsubscribe() (err error) {
C.rd_kafka_unsubscribe(c.handle.rk)
return nil
} | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"Unsubscribe",
"(",
")",
"(",
"err",
"error",
")",
"{",
"C",
".",
"rd_kafka_unsubscribe",
"(",
"c",
".",
"handle",
".",
"rk",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Unsubscribe from the current subscription, if any. | [
"Unsubscribe",
"from",
"the",
"current",
"subscription",
"if",
"any",
"."
] | cfbc1edb6a54515310a0c7840bf4a24159b51876 | https://github.com/confluentinc/confluent-kafka-go/blob/cfbc1edb6a54515310a0c7840bf4a24159b51876/kafka/consumer.go#L92-L95 |
163,992 | confluentinc/confluent-kafka-go | kafka/consumer.go | Assign | func (c *Consumer) Assign(partitions []TopicPartition) (err error) {
c.appReassigned = true
cparts := newCPartsFromTopicPartitions(partitions)
defer C.rd_kafka_topic_partition_list_destroy(cparts)
e := C.rd_kafka_assign(c.handle.rk, cparts)
if e != C.RD_KAFKA_RESP_ERR_NO_ERROR {
return newError(e)
}
return nil
} | go | func (c *Consumer) Assign(partitions []TopicPartition) (err error) {
c.appReassigned = true
cparts := newCPartsFromTopicPartitions(partitions)
defer C.rd_kafka_topic_partition_list_destroy(cparts)
e := C.rd_kafka_assign(c.handle.rk, cparts)
if e != C.RD_KAFKA_RESP_ERR_NO_ERROR {
return newError(e)
}
return nil
} | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"Assign",
"(",
"partitions",
"[",
"]",
"TopicPartition",
")",
"(",
"err",
"error",
")",
"{",
"c",
".",
"appReassigned",
"=",
"true",
"\n\n",
"cparts",
":=",
"newCPartsFromTopicPartitions",
"(",
"partitions",
")",
"\n... | // Assign an atomic set of partitions to consume.
// This replaces the current assignment. | [
"Assign",
"an",
"atomic",
"set",
"of",
"partitions",
"to",
"consume",
".",
"This",
"replaces",
"the",
"current",
"assignment",
"."
] | cfbc1edb6a54515310a0c7840bf4a24159b51876 | https://github.com/confluentinc/confluent-kafka-go/blob/cfbc1edb6a54515310a0c7840bf4a24159b51876/kafka/consumer.go#L99-L111 |
163,993 | confluentinc/confluent-kafka-go | kafka/consumer.go | Unassign | func (c *Consumer) Unassign() (err error) {
c.appReassigned = true
e := C.rd_kafka_assign(c.handle.rk, nil)
if e != C.RD_KAFKA_RESP_ERR_NO_ERROR {
return newError(e)
}
return nil
} | go | func (c *Consumer) Unassign() (err error) {
c.appReassigned = true
e := C.rd_kafka_assign(c.handle.rk, nil)
if e != C.RD_KAFKA_RESP_ERR_NO_ERROR {
return newError(e)
}
return nil
} | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"Unassign",
"(",
")",
"(",
"err",
"error",
")",
"{",
"c",
".",
"appReassigned",
"=",
"true",
"\n\n",
"e",
":=",
"C",
".",
"rd_kafka_assign",
"(",
"c",
".",
"handle",
".",
"rk",
",",
"nil",
")",
"\n",
"if",
... | // Unassign the current set of partitions to consume. | [
"Unassign",
"the",
"current",
"set",
"of",
"partitions",
"to",
"consume",
"."
] | cfbc1edb6a54515310a0c7840bf4a24159b51876 | https://github.com/confluentinc/confluent-kafka-go/blob/cfbc1edb6a54515310a0c7840bf4a24159b51876/kafka/consumer.go#L114-L123 |
163,994 | confluentinc/confluent-kafka-go | kafka/consumer.go | commit | func (c *Consumer) commit(offsets []TopicPartition) (committedOffsets []TopicPartition, err error) {
var rkqu *C.rd_kafka_queue_t
rkqu = C.rd_kafka_queue_new(c.handle.rk)
defer C.rd_kafka_queue_destroy(rkqu)
var coffsets *C.rd_kafka_topic_partition_list_t
if offsets != nil {
coffsets = newCPartsFromTopicPartitions(offsets)
defer C.rd_kafka_topic_partition_list_destroy(coffsets)
}
cErr := C.rd_kafka_commit_queue(c.handle.rk, coffsets, rkqu, nil, nil)
if cErr != C.RD_KAFKA_RESP_ERR_NO_ERROR {
return nil, newError(cErr)
}
rkev := C.rd_kafka_queue_poll(rkqu, C.int(-1))
if rkev == nil {
// shouldn't happen
return nil, newError(C.RD_KAFKA_RESP_ERR__DESTROY)
}
defer C.rd_kafka_event_destroy(rkev)
if C.rd_kafka_event_type(rkev) != C.RD_KAFKA_EVENT_OFFSET_COMMIT {
panic(fmt.Sprintf("Expected OFFSET_COMMIT, got %s",
C.GoString(C.rd_kafka_event_name(rkev))))
}
cErr = C.rd_kafka_event_error(rkev)
if cErr != C.RD_KAFKA_RESP_ERR_NO_ERROR {
return nil, newErrorFromCString(cErr, C.rd_kafka_event_error_string(rkev))
}
cRetoffsets := C.rd_kafka_event_topic_partition_list(rkev)
if cRetoffsets == nil {
// no offsets, no error
return nil, nil
}
committedOffsets = newTopicPartitionsFromCparts(cRetoffsets)
return committedOffsets, nil
} | go | func (c *Consumer) commit(offsets []TopicPartition) (committedOffsets []TopicPartition, err error) {
var rkqu *C.rd_kafka_queue_t
rkqu = C.rd_kafka_queue_new(c.handle.rk)
defer C.rd_kafka_queue_destroy(rkqu)
var coffsets *C.rd_kafka_topic_partition_list_t
if offsets != nil {
coffsets = newCPartsFromTopicPartitions(offsets)
defer C.rd_kafka_topic_partition_list_destroy(coffsets)
}
cErr := C.rd_kafka_commit_queue(c.handle.rk, coffsets, rkqu, nil, nil)
if cErr != C.RD_KAFKA_RESP_ERR_NO_ERROR {
return nil, newError(cErr)
}
rkev := C.rd_kafka_queue_poll(rkqu, C.int(-1))
if rkev == nil {
// shouldn't happen
return nil, newError(C.RD_KAFKA_RESP_ERR__DESTROY)
}
defer C.rd_kafka_event_destroy(rkev)
if C.rd_kafka_event_type(rkev) != C.RD_KAFKA_EVENT_OFFSET_COMMIT {
panic(fmt.Sprintf("Expected OFFSET_COMMIT, got %s",
C.GoString(C.rd_kafka_event_name(rkev))))
}
cErr = C.rd_kafka_event_error(rkev)
if cErr != C.RD_KAFKA_RESP_ERR_NO_ERROR {
return nil, newErrorFromCString(cErr, C.rd_kafka_event_error_string(rkev))
}
cRetoffsets := C.rd_kafka_event_topic_partition_list(rkev)
if cRetoffsets == nil {
// no offsets, no error
return nil, nil
}
committedOffsets = newTopicPartitionsFromCparts(cRetoffsets)
return committedOffsets, nil
} | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"commit",
"(",
"offsets",
"[",
"]",
"TopicPartition",
")",
"(",
"committedOffsets",
"[",
"]",
"TopicPartition",
",",
"err",
"error",
")",
"{",
"var",
"rkqu",
"*",
"C",
".",
"rd_kafka_queue_t",
"\n\n",
"rkqu",
"=",
... | // commit offsets for specified offsets.
// If offsets is nil the currently assigned partitions' offsets are committed.
// This is a blocking call, caller will need to wrap in go-routine to
// get async or throw-away behaviour. | [
"commit",
"offsets",
"for",
"specified",
"offsets",
".",
"If",
"offsets",
"is",
"nil",
"the",
"currently",
"assigned",
"partitions",
"offsets",
"are",
"committed",
".",
"This",
"is",
"a",
"blocking",
"call",
"caller",
"will",
"need",
"to",
"wrap",
"in",
"go"... | cfbc1edb6a54515310a0c7840bf4a24159b51876 | https://github.com/confluentinc/confluent-kafka-go/blob/cfbc1edb6a54515310a0c7840bf4a24159b51876/kafka/consumer.go#L129-L171 |
163,995 | confluentinc/confluent-kafka-go | kafka/consumer.go | CommitMessage | func (c *Consumer) CommitMessage(m *Message) ([]TopicPartition, error) {
if m.TopicPartition.Error != nil {
return nil, newErrorFromString(ErrInvalidArg, "Can't commit errored message")
}
offsets := []TopicPartition{m.TopicPartition}
offsets[0].Offset++
return c.commit(offsets)
} | go | func (c *Consumer) CommitMessage(m *Message) ([]TopicPartition, error) {
if m.TopicPartition.Error != nil {
return nil, newErrorFromString(ErrInvalidArg, "Can't commit errored message")
}
offsets := []TopicPartition{m.TopicPartition}
offsets[0].Offset++
return c.commit(offsets)
} | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"CommitMessage",
"(",
"m",
"*",
"Message",
")",
"(",
"[",
"]",
"TopicPartition",
",",
"error",
")",
"{",
"if",
"m",
".",
"TopicPartition",
".",
"Error",
"!=",
"nil",
"{",
"return",
"nil",
",",
"newErrorFromString... | // CommitMessage commits offset based on the provided message.
// This is a blocking call.
// Returns the committed offsets on success. | [
"CommitMessage",
"commits",
"offset",
"based",
"on",
"the",
"provided",
"message",
".",
"This",
"is",
"a",
"blocking",
"call",
".",
"Returns",
"the",
"committed",
"offsets",
"on",
"success",
"."
] | cfbc1edb6a54515310a0c7840bf4a24159b51876 | https://github.com/confluentinc/confluent-kafka-go/blob/cfbc1edb6a54515310a0c7840bf4a24159b51876/kafka/consumer.go#L183-L190 |
163,996 | confluentinc/confluent-kafka-go | kafka/consumer.go | CommitOffsets | func (c *Consumer) CommitOffsets(offsets []TopicPartition) ([]TopicPartition, error) {
return c.commit(offsets)
} | go | func (c *Consumer) CommitOffsets(offsets []TopicPartition) ([]TopicPartition, error) {
return c.commit(offsets)
} | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"CommitOffsets",
"(",
"offsets",
"[",
"]",
"TopicPartition",
")",
"(",
"[",
"]",
"TopicPartition",
",",
"error",
")",
"{",
"return",
"c",
".",
"commit",
"(",
"offsets",
")",
"\n",
"}"
] | // CommitOffsets commits the provided list of offsets
// This is a blocking call.
// Returns the committed offsets on success. | [
"CommitOffsets",
"commits",
"the",
"provided",
"list",
"of",
"offsets",
"This",
"is",
"a",
"blocking",
"call",
".",
"Returns",
"the",
"committed",
"offsets",
"on",
"success",
"."
] | cfbc1edb6a54515310a0c7840bf4a24159b51876 | https://github.com/confluentinc/confluent-kafka-go/blob/cfbc1edb6a54515310a0c7840bf4a24159b51876/kafka/consumer.go#L195-L197 |
163,997 | confluentinc/confluent-kafka-go | kafka/consumer.go | Close | func (c *Consumer) Close() (err error) {
if c.eventsChanEnable {
// Wait for consumerReader() to terminate (by closing readerTermChan)
close(c.readerTermChan)
c.handle.waitTerminated(1)
close(c.events)
}
C.rd_kafka_queue_destroy(c.handle.rkq)
c.handle.rkq = nil
e := C.rd_kafka_consumer_close(c.handle.rk)
if e != C.RD_KAFKA_RESP_ERR_NO_ERROR {
return newError(e)
}
c.handle.cleanup()
C.rd_kafka_destroy(c.handle.rk)
return nil
} | go | func (c *Consumer) Close() (err error) {
if c.eventsChanEnable {
// Wait for consumerReader() to terminate (by closing readerTermChan)
close(c.readerTermChan)
c.handle.waitTerminated(1)
close(c.events)
}
C.rd_kafka_queue_destroy(c.handle.rkq)
c.handle.rkq = nil
e := C.rd_kafka_consumer_close(c.handle.rk)
if e != C.RD_KAFKA_RESP_ERR_NO_ERROR {
return newError(e)
}
c.handle.cleanup()
C.rd_kafka_destroy(c.handle.rk)
return nil
} | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"Close",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"c",
".",
"eventsChanEnable",
"{",
"// Wait for consumerReader() to terminate (by closing readerTermChan)",
"close",
"(",
"c",
".",
"readerTermChan",
")",
"\n",
"c",
... | // Close Consumer instance.
// The object is no longer usable after this call. | [
"Close",
"Consumer",
"instance",
".",
"The",
"object",
"is",
"no",
"longer",
"usable",
"after",
"this",
"call",
"."
] | cfbc1edb6a54515310a0c7840bf4a24159b51876 | https://github.com/confluentinc/confluent-kafka-go/blob/cfbc1edb6a54515310a0c7840bf4a24159b51876/kafka/consumer.go#L326-L348 |
163,998 | confluentinc/confluent-kafka-go | kafka/consumer.go | rebalance | func (c *Consumer) rebalance(ev Event) bool {
c.appReassigned = false
if c.rebalanceCb != nil {
c.rebalanceCb(c, ev)
}
return c.appReassigned
} | go | func (c *Consumer) rebalance(ev Event) bool {
c.appReassigned = false
if c.rebalanceCb != nil {
c.rebalanceCb(c, ev)
}
return c.appReassigned
} | [
"func",
"(",
"c",
"*",
"Consumer",
")",
"rebalance",
"(",
"ev",
"Event",
")",
"bool",
"{",
"c",
".",
"appReassigned",
"=",
"false",
"\n\n",
"if",
"c",
".",
"rebalanceCb",
"!=",
"nil",
"{",
"c",
".",
"rebalanceCb",
"(",
"c",
",",
"ev",
")",
"\n",
... | // rebalance calls the application's rebalance callback, if any.
// Returns true if the underlying assignment was updated, else false. | [
"rebalance",
"calls",
"the",
"application",
"s",
"rebalance",
"callback",
"if",
"any",
".",
"Returns",
"true",
"if",
"the",
"underlying",
"assignment",
"was",
"updated",
"else",
"false",
"."
] | cfbc1edb6a54515310a0c7840bf4a24159b51876 | https://github.com/confluentinc/confluent-kafka-go/blob/cfbc1edb6a54515310a0c7840bf4a24159b51876/kafka/consumer.go#L442-L450 |
163,999 | confluentinc/confluent-kafka-go | kafka/consumer.go | consumerReader | func consumerReader(c *Consumer, termChan chan bool) {
out:
for true {
select {
case _ = <-termChan:
break out
default:
_, term := c.handle.eventPoll(c.events, 100, 1000, termChan)
if term {
break out
}
}
}
c.handle.terminatedChan <- "consumerReader"
return
} | go | func consumerReader(c *Consumer, termChan chan bool) {
out:
for true {
select {
case _ = <-termChan:
break out
default:
_, term := c.handle.eventPoll(c.events, 100, 1000, termChan)
if term {
break out
}
}
}
c.handle.terminatedChan <- "consumerReader"
return
} | [
"func",
"consumerReader",
"(",
"c",
"*",
"Consumer",
",",
"termChan",
"chan",
"bool",
")",
"{",
"out",
":",
"for",
"true",
"{",
"select",
"{",
"case",
"_",
"=",
"<-",
"termChan",
":",
"break",
"out",
"\n",
"default",
":",
"_",
",",
"term",
":=",
"c... | // consumerReader reads messages and events from the librdkafka consumer queue
// and posts them on the consumer channel.
// Runs until termChan closes | [
"consumerReader",
"reads",
"messages",
"and",
"events",
"from",
"the",
"librdkafka",
"consumer",
"queue",
"and",
"posts",
"them",
"on",
"the",
"consumer",
"channel",
".",
"Runs",
"until",
"termChan",
"closes"
] | cfbc1edb6a54515310a0c7840bf4a24159b51876 | https://github.com/confluentinc/confluent-kafka-go/blob/cfbc1edb6a54515310a0c7840bf4a24159b51876/kafka/consumer.go#L455-L474 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.