id
int32 0
167k
| repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
163,800 | cilium/cilium | pkg/identity/identity.go | RequiresGlobalIdentity | func RequiresGlobalIdentity(lbls labels.Labels) bool {
for _, label := range lbls {
switch label.Source {
case labels.LabelSourceCIDR, labels.LabelSourceReserved:
default:
return true
}
}
return false
} | go | func RequiresGlobalIdentity(lbls labels.Labels) bool {
for _, label := range lbls {
switch label.Source {
case labels.LabelSourceCIDR, labels.LabelSourceReserved:
default:
return true
}
}
return false
} | [
"func",
"RequiresGlobalIdentity",
"(",
"lbls",
"labels",
".",
"Labels",
")",
"bool",
"{",
"for",
"_",
",",
"label",
":=",
"range",
"lbls",
"{",
"switch",
"label",
".",
"Source",
"{",
"case",
"labels",
".",
"LabelSourceCIDR",
",",
"labels",
".",
"LabelSourceReserved",
":",
"default",
":",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] | // RequiresGlobalIdentity returns true if the label combination requires a
// global identity | [
"RequiresGlobalIdentity",
"returns",
"true",
"if",
"the",
"label",
"combination",
"requires",
"a",
"global",
"identity"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/identity.go#L197-L207 |
163,801 | cilium/cilium | daemon/fqdn.go | extractDNSLookups | func extractDNSLookups(endpoints []*endpoint.Endpoint, CIDRStr, matchPatternStr string) (lookups []*models.DNSLookup, err error) {
cidrMatcher := func(ip net.IP) bool { return true }
if CIDRStr != "" {
_, cidr, err := net.ParseCIDR(CIDRStr)
if err != nil {
return nil, err
}
cidrMatcher = func(ip net.IP) bool { return cidr.Contains(ip) }
}
nameMatcher := func(name string) bool { return true }
if matchPatternStr != "" {
matcher, err := matchpattern.Validate(matchpattern.Sanitize(matchPatternStr))
if err != nil {
return nil, err
}
nameMatcher = func(name string) bool { return matcher.MatchString(name) }
}
for _, ep := range endpoints {
for _, lookup := range ep.DNSHistory.Dump() {
if !nameMatcher(lookup.Name) {
continue
}
// The API model needs strings
IPStrings := make([]string, 0, len(lookup.IPs))
// only proceed if any IP matches the cidr selector
anIPMatches := false
for _, ip := range lookup.IPs {
anIPMatches = anIPMatches || cidrMatcher(ip)
IPStrings = append(IPStrings, ip.String())
}
if !anIPMatches {
continue
}
lookups = append(lookups, &models.DNSLookup{
Fqdn: lookup.Name,
Ips: IPStrings,
LookupTime: strfmt.DateTime(lookup.LookupTime),
TTL: int64(lookup.TTL),
ExpirationTime: strfmt.DateTime(lookup.ExpirationTime),
EndpointID: int64(ep.ID),
})
}
}
return lookups, nil
} | go | func extractDNSLookups(endpoints []*endpoint.Endpoint, CIDRStr, matchPatternStr string) (lookups []*models.DNSLookup, err error) {
cidrMatcher := func(ip net.IP) bool { return true }
if CIDRStr != "" {
_, cidr, err := net.ParseCIDR(CIDRStr)
if err != nil {
return nil, err
}
cidrMatcher = func(ip net.IP) bool { return cidr.Contains(ip) }
}
nameMatcher := func(name string) bool { return true }
if matchPatternStr != "" {
matcher, err := matchpattern.Validate(matchpattern.Sanitize(matchPatternStr))
if err != nil {
return nil, err
}
nameMatcher = func(name string) bool { return matcher.MatchString(name) }
}
for _, ep := range endpoints {
for _, lookup := range ep.DNSHistory.Dump() {
if !nameMatcher(lookup.Name) {
continue
}
// The API model needs strings
IPStrings := make([]string, 0, len(lookup.IPs))
// only proceed if any IP matches the cidr selector
anIPMatches := false
for _, ip := range lookup.IPs {
anIPMatches = anIPMatches || cidrMatcher(ip)
IPStrings = append(IPStrings, ip.String())
}
if !anIPMatches {
continue
}
lookups = append(lookups, &models.DNSLookup{
Fqdn: lookup.Name,
Ips: IPStrings,
LookupTime: strfmt.DateTime(lookup.LookupTime),
TTL: int64(lookup.TTL),
ExpirationTime: strfmt.DateTime(lookup.ExpirationTime),
EndpointID: int64(ep.ID),
})
}
}
return lookups, nil
} | [
"func",
"extractDNSLookups",
"(",
"endpoints",
"[",
"]",
"*",
"endpoint",
".",
"Endpoint",
",",
"CIDRStr",
",",
"matchPatternStr",
"string",
")",
"(",
"lookups",
"[",
"]",
"*",
"models",
".",
"DNSLookup",
",",
"err",
"error",
")",
"{",
"cidrMatcher",
":=",
"func",
"(",
"ip",
"net",
".",
"IP",
")",
"bool",
"{",
"return",
"true",
"}",
"\n",
"if",
"CIDRStr",
"!=",
"\"",
"\"",
"{",
"_",
",",
"cidr",
",",
"err",
":=",
"net",
".",
"ParseCIDR",
"(",
"CIDRStr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"cidrMatcher",
"=",
"func",
"(",
"ip",
"net",
".",
"IP",
")",
"bool",
"{",
"return",
"cidr",
".",
"Contains",
"(",
"ip",
")",
"}",
"\n",
"}",
"\n\n",
"nameMatcher",
":=",
"func",
"(",
"name",
"string",
")",
"bool",
"{",
"return",
"true",
"}",
"\n",
"if",
"matchPatternStr",
"!=",
"\"",
"\"",
"{",
"matcher",
",",
"err",
":=",
"matchpattern",
".",
"Validate",
"(",
"matchpattern",
".",
"Sanitize",
"(",
"matchPatternStr",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"nameMatcher",
"=",
"func",
"(",
"name",
"string",
")",
"bool",
"{",
"return",
"matcher",
".",
"MatchString",
"(",
"name",
")",
"}",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"ep",
":=",
"range",
"endpoints",
"{",
"for",
"_",
",",
"lookup",
":=",
"range",
"ep",
".",
"DNSHistory",
".",
"Dump",
"(",
")",
"{",
"if",
"!",
"nameMatcher",
"(",
"lookup",
".",
"Name",
")",
"{",
"continue",
"\n",
"}",
"\n\n",
"// The API model needs strings",
"IPStrings",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"lookup",
".",
"IPs",
")",
")",
"\n\n",
"// only proceed if any IP matches the cidr selector",
"anIPMatches",
":=",
"false",
"\n",
"for",
"_",
",",
"ip",
":=",
"range",
"lookup",
".",
"IPs",
"{",
"anIPMatches",
"=",
"anIPMatches",
"||",
"cidrMatcher",
"(",
"ip",
")",
"\n",
"IPStrings",
"=",
"append",
"(",
"IPStrings",
",",
"ip",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n",
"if",
"!",
"anIPMatches",
"{",
"continue",
"\n",
"}",
"\n\n",
"lookups",
"=",
"append",
"(",
"lookups",
",",
"&",
"models",
".",
"DNSLookup",
"{",
"Fqdn",
":",
"lookup",
".",
"Name",
",",
"Ips",
":",
"IPStrings",
",",
"LookupTime",
":",
"strfmt",
".",
"DateTime",
"(",
"lookup",
".",
"LookupTime",
")",
",",
"TTL",
":",
"int64",
"(",
"lookup",
".",
"TTL",
")",
",",
"ExpirationTime",
":",
"strfmt",
".",
"DateTime",
"(",
"lookup",
".",
"ExpirationTime",
")",
",",
"EndpointID",
":",
"int64",
"(",
"ep",
".",
"ID",
")",
",",
"}",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"lookups",
",",
"nil",
"\n",
"}"
] | // extractDNSLookups returns API models.DNSLookup copies of DNS data in each
// endpoint's DNSHistory. These are filtered by CIDRStr and matchPatternStr if
// they are non-empty. | [
"extractDNSLookups",
"returns",
"API",
"models",
".",
"DNSLookup",
"copies",
"of",
"DNS",
"data",
"in",
"each",
"endpoint",
"s",
"DNSHistory",
".",
"These",
"are",
"filtered",
"by",
"CIDRStr",
"and",
"matchPatternStr",
"if",
"they",
"are",
"non",
"-",
"empty",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/fqdn.go#L509-L559 |
163,802 | cilium/cilium | daemon/fqdn.go | readPreCache | func readPreCache(preCachePath string) (cache *fqdn.DNSCache, err error) {
data, err := ioutil.ReadFile(preCachePath)
if err != nil {
return nil, err
}
cache = fqdn.NewDNSCache(0) // no per-host limit here
if err = cache.UnmarshalJSON(data); err != nil {
return nil, err
}
return cache, nil
} | go | func readPreCache(preCachePath string) (cache *fqdn.DNSCache, err error) {
data, err := ioutil.ReadFile(preCachePath)
if err != nil {
return nil, err
}
cache = fqdn.NewDNSCache(0) // no per-host limit here
if err = cache.UnmarshalJSON(data); err != nil {
return nil, err
}
return cache, nil
} | [
"func",
"readPreCache",
"(",
"preCachePath",
"string",
")",
"(",
"cache",
"*",
"fqdn",
".",
"DNSCache",
",",
"err",
"error",
")",
"{",
"data",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"preCachePath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"cache",
"=",
"fqdn",
".",
"NewDNSCache",
"(",
"0",
")",
"// no per-host limit here",
"\n",
"if",
"err",
"=",
"cache",
".",
"UnmarshalJSON",
"(",
"data",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"cache",
",",
"nil",
"\n",
"}"
] | // readPreCache returns a fqdn.DNSCache object created from the json data at
// preCachePath | [
"readPreCache",
"returns",
"a",
"fqdn",
".",
"DNSCache",
"object",
"created",
"from",
"the",
"json",
"data",
"at",
"preCachePath"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/fqdn.go#L587-L598 |
163,803 | cilium/cilium | pkg/policy/groups/aws/aws.go | GetIPsFromGroup | func GetIPsFromGroup(group *api.ToGroups) ([]net.IP, error) {
result := []net.IP{}
if group.AWS == nil {
return result, fmt.Errorf("no aws data available")
}
return getInstancesIpsFromFilter(group.AWS)
} | go | func GetIPsFromGroup(group *api.ToGroups) ([]net.IP, error) {
result := []net.IP{}
if group.AWS == nil {
return result, fmt.Errorf("no aws data available")
}
return getInstancesIpsFromFilter(group.AWS)
} | [
"func",
"GetIPsFromGroup",
"(",
"group",
"*",
"api",
".",
"ToGroups",
")",
"(",
"[",
"]",
"net",
".",
"IP",
",",
"error",
")",
"{",
"result",
":=",
"[",
"]",
"net",
".",
"IP",
"{",
"}",
"\n",
"if",
"group",
".",
"AWS",
"==",
"nil",
"{",
"return",
"result",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"getInstancesIpsFromFilter",
"(",
"group",
".",
"AWS",
")",
"\n",
"}"
] | // GetIPsFromGroup will return the list of the ips for the given group filter | [
"GetIPsFromGroup",
"will",
"return",
"the",
"list",
"of",
"the",
"ips",
"for",
"the",
"given",
"group",
"filter"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/groups/aws/aws.go#L44-L50 |
163,804 | cilium/cilium | pkg/policy/groups/aws/aws.go | initializeAWSAccount | func initializeAWSAccount(region string) (*aws.Config, error) {
cfg, err := external.LoadDefaultAWSConfig()
if err != nil {
return nil, fmt.Errorf("Cannot initialize aws connector: %s", err)
}
cfg.Region = region
cfg.LogLevel = awsLogLevel
return &cfg, nil
} | go | func initializeAWSAccount(region string) (*aws.Config, error) {
cfg, err := external.LoadDefaultAWSConfig()
if err != nil {
return nil, fmt.Errorf("Cannot initialize aws connector: %s", err)
}
cfg.Region = region
cfg.LogLevel = awsLogLevel
return &cfg, nil
} | [
"func",
"initializeAWSAccount",
"(",
"region",
"string",
")",
"(",
"*",
"aws",
".",
"Config",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"external",
".",
"LoadDefaultAWSConfig",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"cfg",
".",
"Region",
"=",
"region",
"\n",
"cfg",
".",
"LogLevel",
"=",
"awsLogLevel",
"\n",
"return",
"&",
"cfg",
",",
"nil",
"\n",
"}"
] | // initializeAWSAccount retrieve the env variables from the runtime and it
// iniliazes the account in the specified region. | [
"initializeAWSAccount",
"retrieve",
"the",
"env",
"variables",
"from",
"the",
"runtime",
"and",
"it",
"iniliazes",
"the",
"account",
"in",
"the",
"specified",
"region",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/groups/aws/aws.go#L54-L62 |
163,805 | cilium/cilium | pkg/policy/groups/aws/aws.go | getInstancesIpsFromFilter | func getInstancesIpsFromFilter(filter *api.AWSGroup) ([]net.IP, error) {
region := filter.Region
if filter.Region == "" {
region = getDefaultRegion()
}
input := &ec2.DescribeInstancesInput{}
for labelKey, labelValue := range filter.Labels {
newFilter := ec2.Filter{
Name: aws.String(fmt.Sprintf("%s:%s", policyEC2Labelskey, labelKey)),
Values: []string{labelValue},
}
input.Filters = append(input.Filters, newFilter)
}
if len(filter.SecurityGroupsIds) > 0 {
newFilter := ec2.Filter{
Name: policySecurityGroupIDKey,
Values: filter.SecurityGroupsIds,
}
input.Filters = append(input.Filters, newFilter)
}
if len(filter.SecurityGroupsNames) > 0 {
newFilter := ec2.Filter{
Name: policySecurityGroupName,
Values: filter.SecurityGroupsNames,
}
input.Filters = append(input.Filters, newFilter)
}
cfg, err := initializeAWSAccount(region)
if err != nil {
return []net.IP{}, err
}
svc := ec2.New(*cfg)
req := svc.DescribeInstancesRequest(input)
result, err := req.Send()
if err != nil {
return []net.IP{}, fmt.Errorf("Cannot retrieve aws information: %s", err)
}
return awsDumpIpsFromRequest(result), nil
} | go | func getInstancesIpsFromFilter(filter *api.AWSGroup) ([]net.IP, error) {
region := filter.Region
if filter.Region == "" {
region = getDefaultRegion()
}
input := &ec2.DescribeInstancesInput{}
for labelKey, labelValue := range filter.Labels {
newFilter := ec2.Filter{
Name: aws.String(fmt.Sprintf("%s:%s", policyEC2Labelskey, labelKey)),
Values: []string{labelValue},
}
input.Filters = append(input.Filters, newFilter)
}
if len(filter.SecurityGroupsIds) > 0 {
newFilter := ec2.Filter{
Name: policySecurityGroupIDKey,
Values: filter.SecurityGroupsIds,
}
input.Filters = append(input.Filters, newFilter)
}
if len(filter.SecurityGroupsNames) > 0 {
newFilter := ec2.Filter{
Name: policySecurityGroupName,
Values: filter.SecurityGroupsNames,
}
input.Filters = append(input.Filters, newFilter)
}
cfg, err := initializeAWSAccount(region)
if err != nil {
return []net.IP{}, err
}
svc := ec2.New(*cfg)
req := svc.DescribeInstancesRequest(input)
result, err := req.Send()
if err != nil {
return []net.IP{}, fmt.Errorf("Cannot retrieve aws information: %s", err)
}
return awsDumpIpsFromRequest(result), nil
} | [
"func",
"getInstancesIpsFromFilter",
"(",
"filter",
"*",
"api",
".",
"AWSGroup",
")",
"(",
"[",
"]",
"net",
".",
"IP",
",",
"error",
")",
"{",
"region",
":=",
"filter",
".",
"Region",
"\n",
"if",
"filter",
".",
"Region",
"==",
"\"",
"\"",
"{",
"region",
"=",
"getDefaultRegion",
"(",
")",
"\n",
"}",
"\n",
"input",
":=",
"&",
"ec2",
".",
"DescribeInstancesInput",
"{",
"}",
"\n",
"for",
"labelKey",
",",
"labelValue",
":=",
"range",
"filter",
".",
"Labels",
"{",
"newFilter",
":=",
"ec2",
".",
"Filter",
"{",
"Name",
":",
"aws",
".",
"String",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"policyEC2Labelskey",
",",
"labelKey",
")",
")",
",",
"Values",
":",
"[",
"]",
"string",
"{",
"labelValue",
"}",
",",
"}",
"\n",
"input",
".",
"Filters",
"=",
"append",
"(",
"input",
".",
"Filters",
",",
"newFilter",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"filter",
".",
"SecurityGroupsIds",
")",
">",
"0",
"{",
"newFilter",
":=",
"ec2",
".",
"Filter",
"{",
"Name",
":",
"policySecurityGroupIDKey",
",",
"Values",
":",
"filter",
".",
"SecurityGroupsIds",
",",
"}",
"\n",
"input",
".",
"Filters",
"=",
"append",
"(",
"input",
".",
"Filters",
",",
"newFilter",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"filter",
".",
"SecurityGroupsNames",
")",
">",
"0",
"{",
"newFilter",
":=",
"ec2",
".",
"Filter",
"{",
"Name",
":",
"policySecurityGroupName",
",",
"Values",
":",
"filter",
".",
"SecurityGroupsNames",
",",
"}",
"\n",
"input",
".",
"Filters",
"=",
"append",
"(",
"input",
".",
"Filters",
",",
"newFilter",
")",
"\n",
"}",
"\n",
"cfg",
",",
"err",
":=",
"initializeAWSAccount",
"(",
"region",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"net",
".",
"IP",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"svc",
":=",
"ec2",
".",
"New",
"(",
"*",
"cfg",
")",
"\n",
"req",
":=",
"svc",
".",
"DescribeInstancesRequest",
"(",
"input",
")",
"\n",
"result",
",",
"err",
":=",
"req",
".",
"Send",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[",
"]",
"net",
".",
"IP",
"{",
"}",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"awsDumpIpsFromRequest",
"(",
"result",
")",
",",
"nil",
"\n",
"}"
] | // getInstancesFromFilter returns the instances IPs in aws EC2 filter by the
// given filter | [
"getInstancesFromFilter",
"returns",
"the",
"instances",
"IPs",
"in",
"aws",
"EC2",
"filter",
"by",
"the",
"given",
"filter"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/groups/aws/aws.go#L66-L104 |
163,806 | cilium/cilium | pkg/kvstore/store/store.go | validate | func (c *Configuration) validate() error {
if c.Prefix == "" {
return fmt.Errorf("prefix must be specified")
}
if c.KeyCreator == nil {
return fmt.Errorf("KeyCreator must be specified")
}
if c.SynchronizationInterval == 0 {
c.SynchronizationInterval = option.Config.KVstorePeriodicSync
}
if c.Backend == nil {
c.Backend = kvstore.Client()
}
return nil
} | go | func (c *Configuration) validate() error {
if c.Prefix == "" {
return fmt.Errorf("prefix must be specified")
}
if c.KeyCreator == nil {
return fmt.Errorf("KeyCreator must be specified")
}
if c.SynchronizationInterval == 0 {
c.SynchronizationInterval = option.Config.KVstorePeriodicSync
}
if c.Backend == nil {
c.Backend = kvstore.Client()
}
return nil
} | [
"func",
"(",
"c",
"*",
"Configuration",
")",
"validate",
"(",
")",
"error",
"{",
"if",
"c",
".",
"Prefix",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"c",
".",
"KeyCreator",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"c",
".",
"SynchronizationInterval",
"==",
"0",
"{",
"c",
".",
"SynchronizationInterval",
"=",
"option",
".",
"Config",
".",
"KVstorePeriodicSync",
"\n",
"}",
"\n\n",
"if",
"c",
".",
"Backend",
"==",
"nil",
"{",
"c",
".",
"Backend",
"=",
"kvstore",
".",
"Client",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // validate is invoked by JoinSharedStore to validate and complete the
// configuration. It returns nil when the configuration is valid. | [
"validate",
"is",
"invoked",
"by",
"JoinSharedStore",
"to",
"validate",
"and",
"complete",
"the",
"configuration",
".",
"It",
"returns",
"nil",
"when",
"the",
"configuration",
"is",
"valid",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/store/store.go#L81-L99 |
163,807 | cilium/cilium | pkg/kvstore/store/store.go | JoinSharedStore | func JoinSharedStore(c Configuration) (*SharedStore, error) {
if err := c.validate(); err != nil {
return nil, err
}
s := &SharedStore{
conf: c,
localKeys: map[string]LocalKey{},
sharedKeys: map[string]Key{},
backend: c.Backend,
}
s.name = "store-" + s.conf.Prefix
s.controllerName = "kvstore-sync-" + s.name
if err := s.listAndStartWatcher(); err != nil {
return nil, err
}
controllers.UpdateController(s.controllerName,
controller.ControllerParams{
DoFunc: func(ctx context.Context) error {
return s.syncLocalKeys()
},
RunInterval: s.conf.SynchronizationInterval,
},
)
return s, nil
} | go | func JoinSharedStore(c Configuration) (*SharedStore, error) {
if err := c.validate(); err != nil {
return nil, err
}
s := &SharedStore{
conf: c,
localKeys: map[string]LocalKey{},
sharedKeys: map[string]Key{},
backend: c.Backend,
}
s.name = "store-" + s.conf.Prefix
s.controllerName = "kvstore-sync-" + s.name
if err := s.listAndStartWatcher(); err != nil {
return nil, err
}
controllers.UpdateController(s.controllerName,
controller.ControllerParams{
DoFunc: func(ctx context.Context) error {
return s.syncLocalKeys()
},
RunInterval: s.conf.SynchronizationInterval,
},
)
return s, nil
} | [
"func",
"JoinSharedStore",
"(",
"c",
"Configuration",
")",
"(",
"*",
"SharedStore",
",",
"error",
")",
"{",
"if",
"err",
":=",
"c",
".",
"validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"s",
":=",
"&",
"SharedStore",
"{",
"conf",
":",
"c",
",",
"localKeys",
":",
"map",
"[",
"string",
"]",
"LocalKey",
"{",
"}",
",",
"sharedKeys",
":",
"map",
"[",
"string",
"]",
"Key",
"{",
"}",
",",
"backend",
":",
"c",
".",
"Backend",
",",
"}",
"\n\n",
"s",
".",
"name",
"=",
"\"",
"\"",
"+",
"s",
".",
"conf",
".",
"Prefix",
"\n",
"s",
".",
"controllerName",
"=",
"\"",
"\"",
"+",
"s",
".",
"name",
"\n\n",
"if",
"err",
":=",
"s",
".",
"listAndStartWatcher",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"controllers",
".",
"UpdateController",
"(",
"s",
".",
"controllerName",
",",
"controller",
".",
"ControllerParams",
"{",
"DoFunc",
":",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"return",
"s",
".",
"syncLocalKeys",
"(",
")",
"\n",
"}",
",",
"RunInterval",
":",
"s",
".",
"conf",
".",
"SynchronizationInterval",
",",
"}",
",",
")",
"\n\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] | // JoinSharedStore creates a new shared store based on the provided
// configuration. An error is returned if the configuration is invalid. The
// store is initialized with the contents of the kvstore. An error is returned
// if the contents cannot be retrieved synchronously from the kvstore. Starts a
// controller to continuously synchronize the store with the kvstore. | [
"JoinSharedStore",
"creates",
"a",
"new",
"shared",
"store",
"based",
"on",
"the",
"provided",
"configuration",
".",
"An",
"error",
"is",
"returned",
"if",
"the",
"configuration",
"is",
"invalid",
".",
"The",
"store",
"is",
"initialized",
"with",
"the",
"contents",
"of",
"the",
"kvstore",
".",
"An",
"error",
"is",
"returned",
"if",
"the",
"contents",
"cannot",
"be",
"retrieved",
"synchronously",
"from",
"the",
"kvstore",
".",
"Starts",
"a",
"controller",
"to",
"continuously",
"synchronize",
"the",
"store",
"with",
"the",
"kvstore",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/store/store.go#L190-L219 |
163,808 | cilium/cilium | pkg/kvstore/store/store.go | keyPath | func (s *SharedStore) keyPath(key NamedKey) string {
// WARNING - STABLE API: The composition of the absolute key path
// cannot be changed without breaking up and downgrades.
return path.Join(s.conf.Prefix, key.GetKeyName())
} | go | func (s *SharedStore) keyPath(key NamedKey) string {
// WARNING - STABLE API: The composition of the absolute key path
// cannot be changed without breaking up and downgrades.
return path.Join(s.conf.Prefix, key.GetKeyName())
} | [
"func",
"(",
"s",
"*",
"SharedStore",
")",
"keyPath",
"(",
"key",
"NamedKey",
")",
"string",
"{",
"// WARNING - STABLE API: The composition of the absolute key path",
"// cannot be changed without breaking up and downgrades.",
"return",
"path",
".",
"Join",
"(",
"s",
".",
"conf",
".",
"Prefix",
",",
"key",
".",
"GetKeyName",
"(",
")",
")",
"\n",
"}"
] | // keyPath returns the absolute kvstore path of a key | [
"keyPath",
"returns",
"the",
"absolute",
"kvstore",
"path",
"of",
"a",
"key"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/store/store.go#L258-L262 |
163,809 | cilium/cilium | pkg/kvstore/store/store.go | syncLocalKey | func (s *SharedStore) syncLocalKey(key LocalKey) error {
jsonValue, err := key.Marshal()
if err != nil {
return err
}
// Update key in kvstore, overwrite an eventual existing key, attach
// lease to expire entry when agent dies and never comes back up.
if _, err := s.backend.UpdateIfDifferent(context.TODO(), s.keyPath(key), jsonValue, true); err != nil {
return err
}
return nil
} | go | func (s *SharedStore) syncLocalKey(key LocalKey) error {
jsonValue, err := key.Marshal()
if err != nil {
return err
}
// Update key in kvstore, overwrite an eventual existing key, attach
// lease to expire entry when agent dies and never comes back up.
if _, err := s.backend.UpdateIfDifferent(context.TODO(), s.keyPath(key), jsonValue, true); err != nil {
return err
}
return nil
} | [
"func",
"(",
"s",
"*",
"SharedStore",
")",
"syncLocalKey",
"(",
"key",
"LocalKey",
")",
"error",
"{",
"jsonValue",
",",
"err",
":=",
"key",
".",
"Marshal",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// Update key in kvstore, overwrite an eventual existing key, attach",
"// lease to expire entry when agent dies and never comes back up.",
"if",
"_",
",",
"err",
":=",
"s",
".",
"backend",
".",
"UpdateIfDifferent",
"(",
"context",
".",
"TODO",
"(",
")",
",",
"s",
".",
"keyPath",
"(",
"key",
")",
",",
"jsonValue",
",",
"true",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // syncLocalKey synchronizes a key to the kvstore | [
"syncLocalKey",
"synchronizes",
"a",
"key",
"to",
"the",
"kvstore"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/store/store.go#L265-L278 |
163,810 | cilium/cilium | pkg/kvstore/store/store.go | syncLocalKeys | func (s *SharedStore) syncLocalKeys() error {
// Create a copy of all local keys so we can unlock and sync to kvstore
// without holding the lock
s.mutex.RLock()
keys := []LocalKey{}
for _, key := range s.localKeys {
keys = append(keys, key)
}
s.mutex.RUnlock()
for _, key := range keys {
if err := s.syncLocalKey(key); err != nil {
return err
}
}
return nil
} | go | func (s *SharedStore) syncLocalKeys() error {
// Create a copy of all local keys so we can unlock and sync to kvstore
// without holding the lock
s.mutex.RLock()
keys := []LocalKey{}
for _, key := range s.localKeys {
keys = append(keys, key)
}
s.mutex.RUnlock()
for _, key := range keys {
if err := s.syncLocalKey(key); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"s",
"*",
"SharedStore",
")",
"syncLocalKeys",
"(",
")",
"error",
"{",
"// Create a copy of all local keys so we can unlock and sync to kvstore",
"// without holding the lock",
"s",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"keys",
":=",
"[",
"]",
"LocalKey",
"{",
"}",
"\n",
"for",
"_",
",",
"key",
":=",
"range",
"s",
".",
"localKeys",
"{",
"keys",
"=",
"append",
"(",
"keys",
",",
"key",
")",
"\n",
"}",
"\n",
"s",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n\n",
"for",
"_",
",",
"key",
":=",
"range",
"keys",
"{",
"if",
"err",
":=",
"s",
".",
"syncLocalKey",
"(",
"key",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // syncLocalKeys synchronizes all local keys with the kvstore | [
"syncLocalKeys",
"synchronizes",
"all",
"local",
"keys",
"with",
"the",
"kvstore"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/store/store.go#L281-L298 |
163,811 | cilium/cilium | pkg/kvstore/store/store.go | SharedKeysMap | func (s *SharedStore) SharedKeysMap() map[string]Key {
s.mutex.RLock()
defer s.mutex.RUnlock()
sharedKeysCopy := make(map[string]Key, len(s.sharedKeys))
for k, v := range s.sharedKeys {
sharedKeysCopy[k] = v
}
return sharedKeysCopy
} | go | func (s *SharedStore) SharedKeysMap() map[string]Key {
s.mutex.RLock()
defer s.mutex.RUnlock()
sharedKeysCopy := make(map[string]Key, len(s.sharedKeys))
for k, v := range s.sharedKeys {
sharedKeysCopy[k] = v
}
return sharedKeysCopy
} | [
"func",
"(",
"s",
"*",
"SharedStore",
")",
"SharedKeysMap",
"(",
")",
"map",
"[",
"string",
"]",
"Key",
"{",
"s",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n",
"sharedKeysCopy",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"Key",
",",
"len",
"(",
"s",
".",
"sharedKeys",
")",
")",
"\n\n",
"for",
"k",
",",
"v",
":=",
"range",
"s",
".",
"sharedKeys",
"{",
"sharedKeysCopy",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"return",
"sharedKeysCopy",
"\n",
"}"
] | // SharedKeysMap returns a copy of the SharedKeysMap, the returned map can
// be safely modified but the values of the map represent the actual data
// stored in the internal SharedStore SharedKeys map. | [
"SharedKeysMap",
"returns",
"a",
"copy",
"of",
"the",
"SharedKeysMap",
"the",
"returned",
"map",
"can",
"be",
"safely",
"modified",
"but",
"the",
"values",
"of",
"the",
"map",
"represent",
"the",
"actual",
"data",
"stored",
"in",
"the",
"internal",
"SharedStore",
"SharedKeys",
"map",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/store/store.go#L316-L325 |
163,812 | cilium/cilium | pkg/kvstore/store/store.go | UpdateLocalKey | func (s *SharedStore) UpdateLocalKey(key LocalKey) {
s.mutex.Lock()
s.localKeys[key.GetKeyName()] = key.DeepKeyCopy()
s.mutex.Unlock()
} | go | func (s *SharedStore) UpdateLocalKey(key LocalKey) {
s.mutex.Lock()
s.localKeys[key.GetKeyName()] = key.DeepKeyCopy()
s.mutex.Unlock()
} | [
"func",
"(",
"s",
"*",
"SharedStore",
")",
"UpdateLocalKey",
"(",
"key",
"LocalKey",
")",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"s",
".",
"localKeys",
"[",
"key",
".",
"GetKeyName",
"(",
")",
"]",
"=",
"key",
".",
"DeepKeyCopy",
"(",
")",
"\n",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // UpdateLocalKey adds a key to be synchronized with the kvstore | [
"UpdateLocalKey",
"adds",
"a",
"key",
"to",
"be",
"synchronized",
"with",
"the",
"kvstore"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/store/store.go#L328-L332 |
163,813 | cilium/cilium | pkg/kvstore/store/store.go | UpdateLocalKeySync | func (s *SharedStore) UpdateLocalKeySync(key LocalKey) error {
s.UpdateLocalKey(key)
if err := s.syncLocalKey(key); err != nil {
s.DeleteLocalKey(key)
return err
}
return nil
} | go | func (s *SharedStore) UpdateLocalKeySync(key LocalKey) error {
s.UpdateLocalKey(key)
if err := s.syncLocalKey(key); err != nil {
s.DeleteLocalKey(key)
return err
}
return nil
} | [
"func",
"(",
"s",
"*",
"SharedStore",
")",
"UpdateLocalKeySync",
"(",
"key",
"LocalKey",
")",
"error",
"{",
"s",
".",
"UpdateLocalKey",
"(",
"key",
")",
"\n\n",
"if",
"err",
":=",
"s",
".",
"syncLocalKey",
"(",
"key",
")",
";",
"err",
"!=",
"nil",
"{",
"s",
".",
"DeleteLocalKey",
"(",
"key",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // UpdateLocalKeySync synchronously synchronizes a local key with the kvstore
// and adds it to the list of local keys to be synchronized if the initial
// synchronous synchronization was successful | [
"UpdateLocalKeySync",
"synchronously",
"synchronizes",
"a",
"local",
"key",
"with",
"the",
"kvstore",
"and",
"adds",
"it",
"to",
"the",
"list",
"of",
"local",
"keys",
"to",
"be",
"synchronized",
"if",
"the",
"initial",
"synchronous",
"synchronization",
"was",
"successful"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/store/store.go#L337-L346 |
163,814 | cilium/cilium | pkg/kvstore/store/store.go | UpdateKeySync | func (s *SharedStore) UpdateKeySync(key LocalKey) error {
err := s.syncLocalKey(key)
if err != nil {
s.DeleteLocalKey(key)
return err
}
return err
} | go | func (s *SharedStore) UpdateKeySync(key LocalKey) error {
err := s.syncLocalKey(key)
if err != nil {
s.DeleteLocalKey(key)
return err
}
return err
} | [
"func",
"(",
"s",
"*",
"SharedStore",
")",
"UpdateKeySync",
"(",
"key",
"LocalKey",
")",
"error",
"{",
"err",
":=",
"s",
".",
"syncLocalKey",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"s",
".",
"DeleteLocalKey",
"(",
"key",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"err",
"\n",
"}"
] | // UpdateKeySync synchronously synchronizes a key with the kvstore. | [
"UpdateKeySync",
"synchronously",
"synchronizes",
"a",
"key",
"with",
"the",
"kvstore",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/store/store.go#L349-L357 |
163,815 | cilium/cilium | pkg/kvstore/store/store.go | DeleteLocalKey | func (s *SharedStore) DeleteLocalKey(key NamedKey) {
name := key.GetKeyName()
s.mutex.Lock()
_, ok := s.localKeys[name]
delete(s.localKeys, name)
s.mutex.Unlock()
err := s.backend.Delete(s.keyPath(key))
if ok {
if err != nil {
s.getLogger().WithError(err).Warning("Unable to delete key in kvstore")
}
s.onDelete(key)
}
} | go | func (s *SharedStore) DeleteLocalKey(key NamedKey) {
name := key.GetKeyName()
s.mutex.Lock()
_, ok := s.localKeys[name]
delete(s.localKeys, name)
s.mutex.Unlock()
err := s.backend.Delete(s.keyPath(key))
if ok {
if err != nil {
s.getLogger().WithError(err).Warning("Unable to delete key in kvstore")
}
s.onDelete(key)
}
} | [
"func",
"(",
"s",
"*",
"SharedStore",
")",
"DeleteLocalKey",
"(",
"key",
"NamedKey",
")",
"{",
"name",
":=",
"key",
".",
"GetKeyName",
"(",
")",
"\n\n",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"_",
",",
"ok",
":=",
"s",
".",
"localKeys",
"[",
"name",
"]",
"\n",
"delete",
"(",
"s",
".",
"localKeys",
",",
"name",
")",
"\n",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"err",
":=",
"s",
".",
"backend",
".",
"Delete",
"(",
"s",
".",
"keyPath",
"(",
"key",
")",
")",
"\n\n",
"if",
"ok",
"{",
"if",
"err",
"!=",
"nil",
"{",
"s",
".",
"getLogger",
"(",
")",
".",
"WithError",
"(",
"err",
")",
".",
"Warning",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"s",
".",
"onDelete",
"(",
"key",
")",
"\n",
"}",
"\n",
"}"
] | // DeleteLocalKey removes a key from being synchronized with the kvstore | [
"DeleteLocalKey",
"removes",
"a",
"key",
"from",
"being",
"synchronized",
"with",
"the",
"kvstore"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/store/store.go#L360-L377 |
163,816 | cilium/cilium | pkg/kvstore/store/store.go | getLocalKeys | func (s *SharedStore) getLocalKeys() []Key {
s.mutex.RLock()
defer s.mutex.RUnlock()
keys := make([]Key, len(s.localKeys))
idx := 0
for _, key := range s.localKeys {
keys[idx] = key
idx++
}
return keys
} | go | func (s *SharedStore) getLocalKeys() []Key {
s.mutex.RLock()
defer s.mutex.RUnlock()
keys := make([]Key, len(s.localKeys))
idx := 0
for _, key := range s.localKeys {
keys[idx] = key
idx++
}
return keys
} | [
"func",
"(",
"s",
"*",
"SharedStore",
")",
"getLocalKeys",
"(",
")",
"[",
"]",
"Key",
"{",
"s",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n\n",
"keys",
":=",
"make",
"(",
"[",
"]",
"Key",
",",
"len",
"(",
"s",
".",
"localKeys",
")",
")",
"\n",
"idx",
":=",
"0",
"\n",
"for",
"_",
",",
"key",
":=",
"range",
"s",
".",
"localKeys",
"{",
"keys",
"[",
"idx",
"]",
"=",
"key",
"\n",
"idx",
"++",
"\n",
"}",
"\n\n",
"return",
"keys",
"\n",
"}"
] | // getLocalKeys returns all local keys | [
"getLocalKeys",
"returns",
"all",
"local",
"keys"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/store/store.go#L380-L392 |
163,817 | cilium/cilium | pkg/kvstore/store/store.go | getSharedKeys | func (s *SharedStore) getSharedKeys() []Key {
s.mutex.RLock()
defer s.mutex.RUnlock()
keys := make([]Key, len(s.sharedKeys))
idx := 0
for _, key := range s.sharedKeys {
keys[idx] = key
idx++
}
return keys
} | go | func (s *SharedStore) getSharedKeys() []Key {
s.mutex.RLock()
defer s.mutex.RUnlock()
keys := make([]Key, len(s.sharedKeys))
idx := 0
for _, key := range s.sharedKeys {
keys[idx] = key
idx++
}
return keys
} | [
"func",
"(",
"s",
"*",
"SharedStore",
")",
"getSharedKeys",
"(",
")",
"[",
"]",
"Key",
"{",
"s",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"RUnlock",
"(",
")",
"\n\n",
"keys",
":=",
"make",
"(",
"[",
"]",
"Key",
",",
"len",
"(",
"s",
".",
"sharedKeys",
")",
")",
"\n",
"idx",
":=",
"0",
"\n",
"for",
"_",
",",
"key",
":=",
"range",
"s",
".",
"sharedKeys",
"{",
"keys",
"[",
"idx",
"]",
"=",
"key",
"\n",
"idx",
"++",
"\n",
"}",
"\n\n",
"return",
"keys",
"\n",
"}"
] | // getSharedKeys returns all shared keys | [
"getSharedKeys",
"returns",
"all",
"shared",
"keys"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/store/store.go#L395-L407 |
163,818 | cilium/cilium | pkg/set/set.go | SliceSubsetOf | func SliceSubsetOf(sub, main []string) (bool, []string) {
var diff []string
occurences := make(map[string]int, len(main))
result := true
for _, element := range main {
occurences[element]++
}
for _, element := range sub {
if count, ok := occurences[element]; !ok {
// Element was not found in the main slice.
result = false
diff = append(diff, element)
} else if count < 1 {
// The element is in both slices, but the sub slice
// has more duplicates.
result = false
} else {
occurences[element]--
}
}
return result, diff
} | go | func SliceSubsetOf(sub, main []string) (bool, []string) {
var diff []string
occurences := make(map[string]int, len(main))
result := true
for _, element := range main {
occurences[element]++
}
for _, element := range sub {
if count, ok := occurences[element]; !ok {
// Element was not found in the main slice.
result = false
diff = append(diff, element)
} else if count < 1 {
// The element is in both slices, but the sub slice
// has more duplicates.
result = false
} else {
occurences[element]--
}
}
return result, diff
} | [
"func",
"SliceSubsetOf",
"(",
"sub",
",",
"main",
"[",
"]",
"string",
")",
"(",
"bool",
",",
"[",
"]",
"string",
")",
"{",
"var",
"diff",
"[",
"]",
"string",
"\n",
"occurences",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"int",
",",
"len",
"(",
"main",
")",
")",
"\n",
"result",
":=",
"true",
"\n",
"for",
"_",
",",
"element",
":=",
"range",
"main",
"{",
"occurences",
"[",
"element",
"]",
"++",
"\n",
"}",
"\n",
"for",
"_",
",",
"element",
":=",
"range",
"sub",
"{",
"if",
"count",
",",
"ok",
":=",
"occurences",
"[",
"element",
"]",
";",
"!",
"ok",
"{",
"// Element was not found in the main slice.",
"result",
"=",
"false",
"\n",
"diff",
"=",
"append",
"(",
"diff",
",",
"element",
")",
"\n",
"}",
"else",
"if",
"count",
"<",
"1",
"{",
"// The element is in both slices, but the sub slice",
"// has more duplicates.",
"result",
"=",
"false",
"\n",
"}",
"else",
"{",
"occurences",
"[",
"element",
"]",
"--",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"result",
",",
"diff",
"\n",
"}"
] | // SliceSubsetOf checks whether the first slice is a subset of the second slice. If
// not, it also returns slice of elements which are the difference of both
// input slices. | [
"SliceSubsetOf",
"checks",
"whether",
"the",
"first",
"slice",
"is",
"a",
"subset",
"of",
"the",
"second",
"slice",
".",
"If",
"not",
"it",
"also",
"returns",
"slice",
"of",
"elements",
"which",
"are",
"the",
"difference",
"of",
"both",
"input",
"slices",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/set/set.go#L20-L41 |
163,819 | cilium/cilium | api/v1/server/restapi/endpoint/get_endpoint_id_config_responses.go | WithPayload | func (o *GetEndpointIDConfigOK) WithPayload(payload *models.EndpointConfigurationStatus) *GetEndpointIDConfigOK {
o.Payload = payload
return o
} | go | func (o *GetEndpointIDConfigOK) WithPayload(payload *models.EndpointConfigurationStatus) *GetEndpointIDConfigOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointIDConfigOK",
")",
"WithPayload",
"(",
"payload",
"*",
"models",
".",
"EndpointConfigurationStatus",
")",
"*",
"GetEndpointIDConfigOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get endpoint Id config o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"endpoint",
"Id",
"config",
"o",
"k",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/endpoint/get_endpoint_id_config_responses.go#L38-L41 |
163,820 | cilium/cilium | pkg/monitor/datapath_drop.go | DumpInfo | func (n *DropNotify) DumpInfo(data []byte) {
fmt.Printf("xx drop (%s) flow %#x to endpoint %d, identity %d->%d: %s\n",
api.DropReason(n.SubType), n.Hash, n.DstID, n.SrcLabel, n.DstLabel,
GetConnectionSummary(data[DropNotifyLen:]))
} | go | func (n *DropNotify) DumpInfo(data []byte) {
fmt.Printf("xx drop (%s) flow %#x to endpoint %d, identity %d->%d: %s\n",
api.DropReason(n.SubType), n.Hash, n.DstID, n.SrcLabel, n.DstLabel,
GetConnectionSummary(data[DropNotifyLen:]))
} | [
"func",
"(",
"n",
"*",
"DropNotify",
")",
"DumpInfo",
"(",
"data",
"[",
"]",
"byte",
")",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"api",
".",
"DropReason",
"(",
"n",
".",
"SubType",
")",
",",
"n",
".",
"Hash",
",",
"n",
".",
"DstID",
",",
"n",
".",
"SrcLabel",
",",
"n",
".",
"DstLabel",
",",
"GetConnectionSummary",
"(",
"data",
"[",
"DropNotifyLen",
":",
"]",
")",
")",
"\n",
"}"
] | // DumpInfo prints a summary of the drop messages. | [
"DumpInfo",
"prints",
"a",
"summary",
"of",
"the",
"drop",
"messages",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/datapath_drop.go#L45-L49 |
163,821 | cilium/cilium | pkg/monitor/datapath_drop.go | DumpVerbose | func (n *DropNotify) DumpVerbose(dissect bool, data []byte, prefix string) {
fmt.Printf("%s MARK %#x FROM %d DROP: %d bytes, reason %s",
prefix, n.Hash, n.Source, n.OrigLen, api.DropReason(n.SubType))
if n.SrcLabel != 0 || n.DstLabel != 0 {
fmt.Printf(", identity %d->%d", n.SrcLabel, n.DstLabel)
}
if n.DstID != 0 {
fmt.Printf(", to endpoint %d\n", n.DstID)
} else {
fmt.Printf("\n")
}
if n.CapLen > 0 && len(data) > DropNotifyLen {
Dissect(dissect, data[DropNotifyLen:])
}
} | go | func (n *DropNotify) DumpVerbose(dissect bool, data []byte, prefix string) {
fmt.Printf("%s MARK %#x FROM %d DROP: %d bytes, reason %s",
prefix, n.Hash, n.Source, n.OrigLen, api.DropReason(n.SubType))
if n.SrcLabel != 0 || n.DstLabel != 0 {
fmt.Printf(", identity %d->%d", n.SrcLabel, n.DstLabel)
}
if n.DstID != 0 {
fmt.Printf(", to endpoint %d\n", n.DstID)
} else {
fmt.Printf("\n")
}
if n.CapLen > 0 && len(data) > DropNotifyLen {
Dissect(dissect, data[DropNotifyLen:])
}
} | [
"func",
"(",
"n",
"*",
"DropNotify",
")",
"DumpVerbose",
"(",
"dissect",
"bool",
",",
"data",
"[",
"]",
"byte",
",",
"prefix",
"string",
")",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"prefix",
",",
"n",
".",
"Hash",
",",
"n",
".",
"Source",
",",
"n",
".",
"OrigLen",
",",
"api",
".",
"DropReason",
"(",
"n",
".",
"SubType",
")",
")",
"\n\n",
"if",
"n",
".",
"SrcLabel",
"!=",
"0",
"||",
"n",
".",
"DstLabel",
"!=",
"0",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"n",
".",
"SrcLabel",
",",
"n",
".",
"DstLabel",
")",
"\n",
"}",
"\n\n",
"if",
"n",
".",
"DstID",
"!=",
"0",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"n",
".",
"DstID",
")",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"n",
".",
"CapLen",
">",
"0",
"&&",
"len",
"(",
"data",
")",
">",
"DropNotifyLen",
"{",
"Dissect",
"(",
"dissect",
",",
"data",
"[",
"DropNotifyLen",
":",
"]",
")",
"\n",
"}",
"\n",
"}"
] | // DumpVerbose prints the drop notification in human readable form | [
"DumpVerbose",
"prints",
"the",
"drop",
"notification",
"in",
"human",
"readable",
"form"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/datapath_drop.go#L52-L69 |
163,822 | cilium/cilium | pkg/monitor/datapath_drop.go | DropNotifyToVerbose | func DropNotifyToVerbose(n *DropNotify) DropNotifyVerbose {
return DropNotifyVerbose{
Type: "drop",
Mark: fmt.Sprintf("%#x", n.Hash),
Reason: api.DropReason(n.SubType),
Source: n.Source,
Bytes: n.OrigLen,
SrcLabel: n.SrcLabel,
DstLabel: n.DstLabel,
DstID: n.DstID,
}
} | go | func DropNotifyToVerbose(n *DropNotify) DropNotifyVerbose {
return DropNotifyVerbose{
Type: "drop",
Mark: fmt.Sprintf("%#x", n.Hash),
Reason: api.DropReason(n.SubType),
Source: n.Source,
Bytes: n.OrigLen,
SrcLabel: n.SrcLabel,
DstLabel: n.DstLabel,
DstID: n.DstID,
}
} | [
"func",
"DropNotifyToVerbose",
"(",
"n",
"*",
"DropNotify",
")",
"DropNotifyVerbose",
"{",
"return",
"DropNotifyVerbose",
"{",
"Type",
":",
"\"",
"\"",
",",
"Mark",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"n",
".",
"Hash",
")",
",",
"Reason",
":",
"api",
".",
"DropReason",
"(",
"n",
".",
"SubType",
")",
",",
"Source",
":",
"n",
".",
"Source",
",",
"Bytes",
":",
"n",
".",
"OrigLen",
",",
"SrcLabel",
":",
"n",
".",
"SrcLabel",
",",
"DstLabel",
":",
"n",
".",
"DstLabel",
",",
"DstID",
":",
"n",
".",
"DstID",
",",
"}",
"\n",
"}"
] | //DropNotifyToVerbose creates verbose notification from DropNotify | [
"DropNotifyToVerbose",
"creates",
"verbose",
"notification",
"from",
"DropNotify"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/datapath_drop.go#L108-L119 |
163,823 | cilium/cilium | pkg/identity/numericidentity.go | InitWellKnownIdentities | func InitWellKnownIdentities() {
// Derive the namespace in which the Cilium components are running
namespace := option.Config.K8sNamespace
// etcd-operator labels
// k8s:io.cilium.k8s.policy.serviceaccount=cilium-etcd-sa
// k8s:io.kubernetes.pod.namespace=<NAMESPACE>
// k8s:io.cilium/app=etcd-operator
// k8s:io.cilium.k8s.policy.cluster=default
WellKnown.add(ReservedETCDOperator, []string{
"k8s:io.cilium/app=etcd-operator",
fmt.Sprintf("k8s:%s=%s", api.PodNamespaceLabel, namespace),
fmt.Sprintf("k8s:%s=cilium-etcd-sa", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
// cilium-etcd labels
// k8s:app=etcd
// k8s:io.cilium/app=etcd-operator
// k8s:etcd_cluster=cilium-etcd
// k8s:io.cilium.k8s.policy.serviceaccount=default
// k8s:io.kubernetes.pod.namespace=<NAMESPACE>
// k8s:io.cilium.k8s.policy.cluster=default
// these 2 labels are ignored by cilium-agent as they can change over time
// container:annotation.etcd.version=3.3.9
// k8s:etcd_node=cilium-etcd-6snk6vsjcm
WellKnown.add(ReservedCiliumKVStore, []string{
"k8s:app=etcd",
"k8s:etcd_cluster=cilium-etcd",
"k8s:io.cilium/app=etcd-operator",
fmt.Sprintf("k8s:%s=%s", api.PodNamespaceLabel, namespace),
fmt.Sprintf("k8s:%s=default", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
// kube-dns labels
// k8s:io.cilium.k8s.policy.serviceaccount=kube-dns
// k8s:io.kubernetes.pod.namespace=kube-system
// k8s:k8s-app=kube-dns
// k8s:io.cilium.k8s.policy.cluster=default
WellKnown.add(ReservedKubeDNS, []string{
"k8s:k8s-app=kube-dns",
fmt.Sprintf("k8s:%s=kube-system", api.PodNamespaceLabel),
fmt.Sprintf("k8s:%s=kube-dns", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
// kube-dns EKS labels
// k8s:io.cilium.k8s.policy.serviceaccount=kube-dns
// k8s:io.kubernetes.pod.namespace=kube-system
// k8s:k8s-app=kube-dns
// k8s:io.cilium.k8s.policy.cluster=default
// k8s:eks.amazonaws.com/component=kube-dns
WellKnown.add(ReservedEKSKubeDNS, []string{
"k8s:k8s-app=kube-dns",
"k8s:eks.amazonaws.com/component=kube-dns",
fmt.Sprintf("k8s:%s=kube-system", api.PodNamespaceLabel),
fmt.Sprintf("k8s:%s=kube-dns", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
// kube-dns EKS labels
// k8s:io.cilium.k8s.policy.serviceaccount=coredns
// k8s:io.kubernetes.pod.namespace=kube-system
// k8s:k8s-app=kube-dns
// k8s:io.cilium.k8s.policy.cluster=default
// k8s:eks.amazonaws.com/component=coredns
WellKnown.add(ReservedEKSCoreDNS, []string{
"k8s:k8s-app=kube-dns",
"k8s:eks.amazonaws.com/component=coredns",
fmt.Sprintf("k8s:%s=kube-system", api.PodNamespaceLabel),
fmt.Sprintf("k8s:%s=coredns", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
// CoreDNS labels
// k8s:io.cilium.k8s.policy.serviceaccount=coredns
// k8s:io.kubernetes.pod.namespace=kube-system
// k8s:k8s-app=kube-dns
// k8s:io.cilium.k8s.policy.cluster=default
WellKnown.add(ReservedCoreDNS, []string{
"k8s:k8s-app=kube-dns",
fmt.Sprintf("k8s:%s=kube-system", api.PodNamespaceLabel),
fmt.Sprintf("k8s:%s=coredns", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
// CiliumOperator labels
// k8s:io.cilium.k8s.policy.serviceaccount=cilium-operator
// k8s:io.kubernetes.pod.namespace=<NAMESPACE>
// k8s:name=cilium-operator
// k8s:io.cilium/app=operator
// k8s:io.cilium.k8s.policy.cluster=default
WellKnown.add(ReservedCiliumOperator, []string{
"k8s:name=cilium-operator",
"k8s:io.cilium/app=operator",
fmt.Sprintf("k8s:%s=%s", api.PodNamespaceLabel, namespace),
fmt.Sprintf("k8s:%s=cilium-operator", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
// cilium-etcd-operator labels
// k8s:io.cilium.k8s.policy.cluster=default
// k8s:io.cilium.k8s.policy.serviceaccount=cilium-etcd-operator
// k8s:io.cilium/app=etcd-operator
// k8s:io.kubernetes.pod.namespace=<NAMESPACE>
// k8s:name=cilium-etcd-operator
WellKnown.add(ReservedCiliumEtcdOperator, []string{
"k8s:name=cilium-etcd-operator",
"k8s:io.cilium/app=etcd-operator",
fmt.Sprintf("k8s:%s=%s", api.PodNamespaceLabel, namespace),
fmt.Sprintf("k8s:%s=cilium-etcd-operator", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
} | go | func InitWellKnownIdentities() {
// Derive the namespace in which the Cilium components are running
namespace := option.Config.K8sNamespace
// etcd-operator labels
// k8s:io.cilium.k8s.policy.serviceaccount=cilium-etcd-sa
// k8s:io.kubernetes.pod.namespace=<NAMESPACE>
// k8s:io.cilium/app=etcd-operator
// k8s:io.cilium.k8s.policy.cluster=default
WellKnown.add(ReservedETCDOperator, []string{
"k8s:io.cilium/app=etcd-operator",
fmt.Sprintf("k8s:%s=%s", api.PodNamespaceLabel, namespace),
fmt.Sprintf("k8s:%s=cilium-etcd-sa", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
// cilium-etcd labels
// k8s:app=etcd
// k8s:io.cilium/app=etcd-operator
// k8s:etcd_cluster=cilium-etcd
// k8s:io.cilium.k8s.policy.serviceaccount=default
// k8s:io.kubernetes.pod.namespace=<NAMESPACE>
// k8s:io.cilium.k8s.policy.cluster=default
// these 2 labels are ignored by cilium-agent as they can change over time
// container:annotation.etcd.version=3.3.9
// k8s:etcd_node=cilium-etcd-6snk6vsjcm
WellKnown.add(ReservedCiliumKVStore, []string{
"k8s:app=etcd",
"k8s:etcd_cluster=cilium-etcd",
"k8s:io.cilium/app=etcd-operator",
fmt.Sprintf("k8s:%s=%s", api.PodNamespaceLabel, namespace),
fmt.Sprintf("k8s:%s=default", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
// kube-dns labels
// k8s:io.cilium.k8s.policy.serviceaccount=kube-dns
// k8s:io.kubernetes.pod.namespace=kube-system
// k8s:k8s-app=kube-dns
// k8s:io.cilium.k8s.policy.cluster=default
WellKnown.add(ReservedKubeDNS, []string{
"k8s:k8s-app=kube-dns",
fmt.Sprintf("k8s:%s=kube-system", api.PodNamespaceLabel),
fmt.Sprintf("k8s:%s=kube-dns", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
// kube-dns EKS labels
// k8s:io.cilium.k8s.policy.serviceaccount=kube-dns
// k8s:io.kubernetes.pod.namespace=kube-system
// k8s:k8s-app=kube-dns
// k8s:io.cilium.k8s.policy.cluster=default
// k8s:eks.amazonaws.com/component=kube-dns
WellKnown.add(ReservedEKSKubeDNS, []string{
"k8s:k8s-app=kube-dns",
"k8s:eks.amazonaws.com/component=kube-dns",
fmt.Sprintf("k8s:%s=kube-system", api.PodNamespaceLabel),
fmt.Sprintf("k8s:%s=kube-dns", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
// kube-dns EKS labels
// k8s:io.cilium.k8s.policy.serviceaccount=coredns
// k8s:io.kubernetes.pod.namespace=kube-system
// k8s:k8s-app=kube-dns
// k8s:io.cilium.k8s.policy.cluster=default
// k8s:eks.amazonaws.com/component=coredns
WellKnown.add(ReservedEKSCoreDNS, []string{
"k8s:k8s-app=kube-dns",
"k8s:eks.amazonaws.com/component=coredns",
fmt.Sprintf("k8s:%s=kube-system", api.PodNamespaceLabel),
fmt.Sprintf("k8s:%s=coredns", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
// CoreDNS labels
// k8s:io.cilium.k8s.policy.serviceaccount=coredns
// k8s:io.kubernetes.pod.namespace=kube-system
// k8s:k8s-app=kube-dns
// k8s:io.cilium.k8s.policy.cluster=default
WellKnown.add(ReservedCoreDNS, []string{
"k8s:k8s-app=kube-dns",
fmt.Sprintf("k8s:%s=kube-system", api.PodNamespaceLabel),
fmt.Sprintf("k8s:%s=coredns", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
// CiliumOperator labels
// k8s:io.cilium.k8s.policy.serviceaccount=cilium-operator
// k8s:io.kubernetes.pod.namespace=<NAMESPACE>
// k8s:name=cilium-operator
// k8s:io.cilium/app=operator
// k8s:io.cilium.k8s.policy.cluster=default
WellKnown.add(ReservedCiliumOperator, []string{
"k8s:name=cilium-operator",
"k8s:io.cilium/app=operator",
fmt.Sprintf("k8s:%s=%s", api.PodNamespaceLabel, namespace),
fmt.Sprintf("k8s:%s=cilium-operator", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
// cilium-etcd-operator labels
// k8s:io.cilium.k8s.policy.cluster=default
// k8s:io.cilium.k8s.policy.serviceaccount=cilium-etcd-operator
// k8s:io.cilium/app=etcd-operator
// k8s:io.kubernetes.pod.namespace=<NAMESPACE>
// k8s:name=cilium-etcd-operator
WellKnown.add(ReservedCiliumEtcdOperator, []string{
"k8s:name=cilium-etcd-operator",
"k8s:io.cilium/app=etcd-operator",
fmt.Sprintf("k8s:%s=%s", api.PodNamespaceLabel, namespace),
fmt.Sprintf("k8s:%s=cilium-etcd-operator", api.PolicyLabelServiceAccount),
fmt.Sprintf("k8s:%s=%s", api.PolicyLabelCluster, option.Config.ClusterName),
})
} | [
"func",
"InitWellKnownIdentities",
"(",
")",
"{",
"// Derive the namespace in which the Cilium components are running",
"namespace",
":=",
"option",
".",
"Config",
".",
"K8sNamespace",
"\n\n",
"// etcd-operator labels",
"// k8s:io.cilium.k8s.policy.serviceaccount=cilium-etcd-sa",
"// k8s:io.kubernetes.pod.namespace=<NAMESPACE>",
"// k8s:io.cilium/app=etcd-operator",
"// k8s:io.cilium.k8s.policy.cluster=default",
"WellKnown",
".",
"add",
"(",
"ReservedETCDOperator",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PodNamespaceLabel",
",",
"namespace",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelServiceAccount",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelCluster",
",",
"option",
".",
"Config",
".",
"ClusterName",
")",
",",
"}",
")",
"\n\n",
"// cilium-etcd labels",
"// k8s:app=etcd",
"// k8s:io.cilium/app=etcd-operator",
"// k8s:etcd_cluster=cilium-etcd",
"// k8s:io.cilium.k8s.policy.serviceaccount=default",
"// k8s:io.kubernetes.pod.namespace=<NAMESPACE>",
"// k8s:io.cilium.k8s.policy.cluster=default",
"// these 2 labels are ignored by cilium-agent as they can change over time",
"// container:annotation.etcd.version=3.3.9",
"// k8s:etcd_node=cilium-etcd-6snk6vsjcm",
"WellKnown",
".",
"add",
"(",
"ReservedCiliumKVStore",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PodNamespaceLabel",
",",
"namespace",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelServiceAccount",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelCluster",
",",
"option",
".",
"Config",
".",
"ClusterName",
")",
",",
"}",
")",
"\n\n",
"// kube-dns labels",
"// k8s:io.cilium.k8s.policy.serviceaccount=kube-dns",
"// k8s:io.kubernetes.pod.namespace=kube-system",
"// k8s:k8s-app=kube-dns",
"// k8s:io.cilium.k8s.policy.cluster=default",
"WellKnown",
".",
"add",
"(",
"ReservedKubeDNS",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PodNamespaceLabel",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelServiceAccount",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelCluster",
",",
"option",
".",
"Config",
".",
"ClusterName",
")",
",",
"}",
")",
"\n\n",
"// kube-dns EKS labels",
"// k8s:io.cilium.k8s.policy.serviceaccount=kube-dns",
"// k8s:io.kubernetes.pod.namespace=kube-system",
"// k8s:k8s-app=kube-dns",
"// k8s:io.cilium.k8s.policy.cluster=default",
"// k8s:eks.amazonaws.com/component=kube-dns",
"WellKnown",
".",
"add",
"(",
"ReservedEKSKubeDNS",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PodNamespaceLabel",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelServiceAccount",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelCluster",
",",
"option",
".",
"Config",
".",
"ClusterName",
")",
",",
"}",
")",
"\n\n",
"// kube-dns EKS labels",
"// k8s:io.cilium.k8s.policy.serviceaccount=coredns",
"// k8s:io.kubernetes.pod.namespace=kube-system",
"// k8s:k8s-app=kube-dns",
"// k8s:io.cilium.k8s.policy.cluster=default",
"// k8s:eks.amazonaws.com/component=coredns",
"WellKnown",
".",
"add",
"(",
"ReservedEKSCoreDNS",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PodNamespaceLabel",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelServiceAccount",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelCluster",
",",
"option",
".",
"Config",
".",
"ClusterName",
")",
",",
"}",
")",
"\n\n",
"// CoreDNS labels",
"// k8s:io.cilium.k8s.policy.serviceaccount=coredns",
"// k8s:io.kubernetes.pod.namespace=kube-system",
"// k8s:k8s-app=kube-dns",
"// k8s:io.cilium.k8s.policy.cluster=default",
"WellKnown",
".",
"add",
"(",
"ReservedCoreDNS",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PodNamespaceLabel",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelServiceAccount",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelCluster",
",",
"option",
".",
"Config",
".",
"ClusterName",
")",
",",
"}",
")",
"\n\n",
"// CiliumOperator labels",
"// k8s:io.cilium.k8s.policy.serviceaccount=cilium-operator",
"// k8s:io.kubernetes.pod.namespace=<NAMESPACE>",
"// k8s:name=cilium-operator",
"// k8s:io.cilium/app=operator",
"// k8s:io.cilium.k8s.policy.cluster=default",
"WellKnown",
".",
"add",
"(",
"ReservedCiliumOperator",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PodNamespaceLabel",
",",
"namespace",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelServiceAccount",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelCluster",
",",
"option",
".",
"Config",
".",
"ClusterName",
")",
",",
"}",
")",
"\n\n",
"// cilium-etcd-operator labels",
"// k8s:io.cilium.k8s.policy.cluster=default",
"// k8s:io.cilium.k8s.policy.serviceaccount=cilium-etcd-operator",
"// k8s:io.cilium/app=etcd-operator",
"// k8s:io.kubernetes.pod.namespace=<NAMESPACE>",
"// k8s:name=cilium-etcd-operator",
"WellKnown",
".",
"add",
"(",
"ReservedCiliumEtcdOperator",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PodNamespaceLabel",
",",
"namespace",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelServiceAccount",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"api",
".",
"PolicyLabelCluster",
",",
"option",
".",
"Config",
".",
"ClusterName",
")",
",",
"}",
")",
"\n",
"}"
] | // InitWellKnownIdentities establishes all well-known identities | [
"InitWellKnownIdentities",
"establishes",
"all",
"well",
"-",
"known",
"identities"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/numericidentity.go#L147-L261 |
163,824 | cilium/cilium | pkg/identity/numericidentity.go | IsUserReservedIdentity | func IsUserReservedIdentity(id NumericIdentity) bool {
return id.Uint32() >= UserReservedNumericIdentity.Uint32() &&
id.Uint32() < MinimalNumericIdentity.Uint32()
} | go | func IsUserReservedIdentity(id NumericIdentity) bool {
return id.Uint32() >= UserReservedNumericIdentity.Uint32() &&
id.Uint32() < MinimalNumericIdentity.Uint32()
} | [
"func",
"IsUserReservedIdentity",
"(",
"id",
"NumericIdentity",
")",
"bool",
"{",
"return",
"id",
".",
"Uint32",
"(",
")",
">=",
"UserReservedNumericIdentity",
".",
"Uint32",
"(",
")",
"&&",
"id",
".",
"Uint32",
"(",
")",
"<",
"MinimalNumericIdentity",
".",
"Uint32",
"(",
")",
"\n",
"}"
] | // IsUserReservedIdentity returns true if the given NumericIdentity belongs
// to the space reserved for users. | [
"IsUserReservedIdentity",
"returns",
"true",
"if",
"the",
"given",
"NumericIdentity",
"belongs",
"to",
"the",
"space",
"reserved",
"for",
"users",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/numericidentity.go#L289-L292 |
163,825 | cilium/cilium | pkg/identity/numericidentity.go | AddUserDefinedNumericIdentity | func AddUserDefinedNumericIdentity(identity NumericIdentity, label string) error {
if !IsUserReservedIdentity(identity) {
return ErrNotUserIdentity
}
reservedIdentities[label] = identity
reservedIdentityNames[identity] = label
return nil
} | go | func AddUserDefinedNumericIdentity(identity NumericIdentity, label string) error {
if !IsUserReservedIdentity(identity) {
return ErrNotUserIdentity
}
reservedIdentities[label] = identity
reservedIdentityNames[identity] = label
return nil
} | [
"func",
"AddUserDefinedNumericIdentity",
"(",
"identity",
"NumericIdentity",
",",
"label",
"string",
")",
"error",
"{",
"if",
"!",
"IsUserReservedIdentity",
"(",
"identity",
")",
"{",
"return",
"ErrNotUserIdentity",
"\n",
"}",
"\n",
"reservedIdentities",
"[",
"label",
"]",
"=",
"identity",
"\n",
"reservedIdentityNames",
"[",
"identity",
"]",
"=",
"label",
"\n",
"return",
"nil",
"\n",
"}"
] | // AddUserDefinedNumericIdentity adds the given numeric identity and respective
// label to the list of reservedIdentities. If the numeric identity is not
// between UserReservedNumericIdentity and MinimalNumericIdentity it will return
// ErrNotUserIdentity.
// Is not safe for concurrent use. | [
"AddUserDefinedNumericIdentity",
"adds",
"the",
"given",
"numeric",
"identity",
"and",
"respective",
"label",
"to",
"the",
"list",
"of",
"reservedIdentities",
".",
"If",
"the",
"numeric",
"identity",
"is",
"not",
"between",
"UserReservedNumericIdentity",
"and",
"MinimalNumericIdentity",
"it",
"will",
"return",
"ErrNotUserIdentity",
".",
"Is",
"not",
"safe",
"for",
"concurrent",
"use",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/numericidentity.go#L299-L306 |
163,826 | cilium/cilium | pkg/identity/numericidentity.go | DelReservedNumericIdentity | func DelReservedNumericIdentity(identity NumericIdentity) error {
if !IsUserReservedIdentity(identity) {
return ErrNotUserIdentity
}
label, ok := reservedIdentityNames[identity]
if ok {
delete(reservedIdentities, label)
delete(reservedIdentityNames, identity)
}
return nil
} | go | func DelReservedNumericIdentity(identity NumericIdentity) error {
if !IsUserReservedIdentity(identity) {
return ErrNotUserIdentity
}
label, ok := reservedIdentityNames[identity]
if ok {
delete(reservedIdentities, label)
delete(reservedIdentityNames, identity)
}
return nil
} | [
"func",
"DelReservedNumericIdentity",
"(",
"identity",
"NumericIdentity",
")",
"error",
"{",
"if",
"!",
"IsUserReservedIdentity",
"(",
"identity",
")",
"{",
"return",
"ErrNotUserIdentity",
"\n",
"}",
"\n",
"label",
",",
"ok",
":=",
"reservedIdentityNames",
"[",
"identity",
"]",
"\n",
"if",
"ok",
"{",
"delete",
"(",
"reservedIdentities",
",",
"label",
")",
"\n",
"delete",
"(",
"reservedIdentityNames",
",",
"identity",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // DelReservedNumericIdentity deletes the given Numeric Identity from the list
// of reservedIdentities. If the numeric identity is not between
// UserReservedNumericIdentity and MinimalNumericIdentity it will return
// ErrNotUserIdentity.
// Is not safe for concurrent use. | [
"DelReservedNumericIdentity",
"deletes",
"the",
"given",
"Numeric",
"Identity",
"from",
"the",
"list",
"of",
"reservedIdentities",
".",
"If",
"the",
"numeric",
"identity",
"is",
"not",
"between",
"UserReservedNumericIdentity",
"and",
"MinimalNumericIdentity",
"it",
"will",
"return",
"ErrNotUserIdentity",
".",
"Is",
"not",
"safe",
"for",
"concurrent",
"use",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/numericidentity.go#L313-L323 |
163,827 | cilium/cilium | pkg/identity/numericidentity.go | GetAllReservedIdentities | func GetAllReservedIdentities() []NumericIdentity {
identities := []NumericIdentity{}
for _, id := range reservedIdentities {
identities = append(identities, id)
}
return identities
} | go | func GetAllReservedIdentities() []NumericIdentity {
identities := []NumericIdentity{}
for _, id := range reservedIdentities {
identities = append(identities, id)
}
return identities
} | [
"func",
"GetAllReservedIdentities",
"(",
")",
"[",
"]",
"NumericIdentity",
"{",
"identities",
":=",
"[",
"]",
"NumericIdentity",
"{",
"}",
"\n",
"for",
"_",
",",
"id",
":=",
"range",
"reservedIdentities",
"{",
"identities",
"=",
"append",
"(",
"identities",
",",
"id",
")",
"\n",
"}",
"\n",
"return",
"identities",
"\n",
"}"
] | // GetAllReservedIdentities returns a list of all reserved numeric identities. | [
"GetAllReservedIdentities",
"returns",
"a",
"list",
"of",
"all",
"reserved",
"numeric",
"identities",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/numericidentity.go#L377-L383 |
163,828 | cilium/cilium | pkg/identity/numericidentity.go | IterateReservedIdentities | func IterateReservedIdentities(f func(key string, value NumericIdentity)) {
for key, value := range reservedIdentities {
f(key, value)
}
} | go | func IterateReservedIdentities(f func(key string, value NumericIdentity)) {
for key, value := range reservedIdentities {
f(key, value)
}
} | [
"func",
"IterateReservedIdentities",
"(",
"f",
"func",
"(",
"key",
"string",
",",
"value",
"NumericIdentity",
")",
")",
"{",
"for",
"key",
",",
"value",
":=",
"range",
"reservedIdentities",
"{",
"f",
"(",
"key",
",",
"value",
")",
"\n",
"}",
"\n",
"}"
] | // IterateReservedIdentities iterates over all reservedIdentities and executes
// the given function for each key, value pair in reservedIdentities. | [
"IterateReservedIdentities",
"iterates",
"over",
"all",
"reservedIdentities",
"and",
"executes",
"the",
"given",
"function",
"for",
"each",
"key",
"value",
"pair",
"in",
"reservedIdentities",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/identity/numericidentity.go#L387-L391 |
163,829 | cilium/cilium | api/v1/client/cilium_client.go | NewHTTPClientWithConfig | func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *Cilium {
// ensure nullable parameters have default
if cfg == nil {
cfg = DefaultTransportConfig()
}
// create transport and client
transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
return New(transport, formats)
} | go | func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *Cilium {
// ensure nullable parameters have default
if cfg == nil {
cfg = DefaultTransportConfig()
}
// create transport and client
transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
return New(transport, formats)
} | [
"func",
"NewHTTPClientWithConfig",
"(",
"formats",
"strfmt",
".",
"Registry",
",",
"cfg",
"*",
"TransportConfig",
")",
"*",
"Cilium",
"{",
"// ensure nullable parameters have default",
"if",
"cfg",
"==",
"nil",
"{",
"cfg",
"=",
"DefaultTransportConfig",
"(",
")",
"\n",
"}",
"\n\n",
"// create transport and client",
"transport",
":=",
"httptransport",
".",
"New",
"(",
"cfg",
".",
"Host",
",",
"cfg",
".",
"BasePath",
",",
"cfg",
".",
"Schemes",
")",
"\n",
"return",
"New",
"(",
"transport",
",",
"formats",
")",
"\n",
"}"
] | // NewHTTPClientWithConfig creates a new cilium HTTP client,
// using a customizable transport config. | [
"NewHTTPClientWithConfig",
"creates",
"a",
"new",
"cilium",
"HTTP",
"client",
"using",
"a",
"customizable",
"transport",
"config",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/cilium_client.go#L45-L54 |
163,830 | cilium/cilium | api/v1/client/cilium_client.go | New | func New(transport runtime.ClientTransport, formats strfmt.Registry) *Cilium {
// ensure nullable parameters have default
if formats == nil {
formats = strfmt.Default
}
cli := new(Cilium)
cli.Transport = transport
cli.Daemon = daemon.New(transport, formats)
cli.Endpoint = endpoint.New(transport, formats)
cli.IPAM = ipam.New(transport, formats)
cli.Metrics = metrics.New(transport, formats)
cli.Policy = policy.New(transport, formats)
cli.Prefilter = prefilter.New(transport, formats)
cli.Service = service.New(transport, formats)
return cli
} | go | func New(transport runtime.ClientTransport, formats strfmt.Registry) *Cilium {
// ensure nullable parameters have default
if formats == nil {
formats = strfmt.Default
}
cli := new(Cilium)
cli.Transport = transport
cli.Daemon = daemon.New(transport, formats)
cli.Endpoint = endpoint.New(transport, formats)
cli.IPAM = ipam.New(transport, formats)
cli.Metrics = metrics.New(transport, formats)
cli.Policy = policy.New(transport, formats)
cli.Prefilter = prefilter.New(transport, formats)
cli.Service = service.New(transport, formats)
return cli
} | [
"func",
"New",
"(",
"transport",
"runtime",
".",
"ClientTransport",
",",
"formats",
"strfmt",
".",
"Registry",
")",
"*",
"Cilium",
"{",
"// ensure nullable parameters have default",
"if",
"formats",
"==",
"nil",
"{",
"formats",
"=",
"strfmt",
".",
"Default",
"\n",
"}",
"\n\n",
"cli",
":=",
"new",
"(",
"Cilium",
")",
"\n",
"cli",
".",
"Transport",
"=",
"transport",
"\n\n",
"cli",
".",
"Daemon",
"=",
"daemon",
".",
"New",
"(",
"transport",
",",
"formats",
")",
"\n\n",
"cli",
".",
"Endpoint",
"=",
"endpoint",
".",
"New",
"(",
"transport",
",",
"formats",
")",
"\n\n",
"cli",
".",
"IPAM",
"=",
"ipam",
".",
"New",
"(",
"transport",
",",
"formats",
")",
"\n\n",
"cli",
".",
"Metrics",
"=",
"metrics",
".",
"New",
"(",
"transport",
",",
"formats",
")",
"\n\n",
"cli",
".",
"Policy",
"=",
"policy",
".",
"New",
"(",
"transport",
",",
"formats",
")",
"\n\n",
"cli",
".",
"Prefilter",
"=",
"prefilter",
".",
"New",
"(",
"transport",
",",
"formats",
")",
"\n\n",
"cli",
".",
"Service",
"=",
"service",
".",
"New",
"(",
"transport",
",",
"formats",
")",
"\n\n",
"return",
"cli",
"\n",
"}"
] | // New creates a new cilium client | [
"New",
"creates",
"a",
"new",
"cilium",
"client"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/cilium_client.go#L57-L81 |
163,831 | cilium/cilium | api/v1/client/endpoint/get_endpoint_parameters.go | WithTimeout | func (o *GetEndpointParams) WithTimeout(timeout time.Duration) *GetEndpointParams {
o.SetTimeout(timeout)
return o
} | go | func (o *GetEndpointParams) WithTimeout(timeout time.Duration) *GetEndpointParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"GetEndpointParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the get endpoint params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"get",
"endpoint",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_parameters.go#L79-L82 |
163,832 | cilium/cilium | api/v1/client/endpoint/get_endpoint_parameters.go | WithContext | func (o *GetEndpointParams) WithContext(ctx context.Context) *GetEndpointParams {
o.SetContext(ctx)
return o
} | go | func (o *GetEndpointParams) WithContext(ctx context.Context) *GetEndpointParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"GetEndpointParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the get endpoint params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"get",
"endpoint",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_parameters.go#L90-L93 |
163,833 | cilium/cilium | api/v1/client/endpoint/get_endpoint_parameters.go | WithHTTPClient | func (o *GetEndpointParams) WithHTTPClient(client *http.Client) *GetEndpointParams {
o.SetHTTPClient(client)
return o
} | go | func (o *GetEndpointParams) WithHTTPClient(client *http.Client) *GetEndpointParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"GetEndpointParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the get endpoint params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"get",
"endpoint",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_parameters.go#L101-L104 |
163,834 | cilium/cilium | api/v1/client/endpoint/get_endpoint_parameters.go | WithLabels | func (o *GetEndpointParams) WithLabels(labels models.Labels) *GetEndpointParams {
o.SetLabels(labels)
return o
} | go | func (o *GetEndpointParams) WithLabels(labels models.Labels) *GetEndpointParams {
o.SetLabels(labels)
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointParams",
")",
"WithLabels",
"(",
"labels",
"models",
".",
"Labels",
")",
"*",
"GetEndpointParams",
"{",
"o",
".",
"SetLabels",
"(",
"labels",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithLabels adds the labels to the get endpoint params | [
"WithLabels",
"adds",
"the",
"labels",
"to",
"the",
"get",
"endpoint",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_parameters.go#L112-L115 |
163,835 | cilium/cilium | api/v1/server/restapi/service/put_service_id_responses.go | WithPayload | func (o *PutServiceIDInvalidFrontend) WithPayload(payload models.Error) *PutServiceIDInvalidFrontend {
o.Payload = payload
return o
} | go | func (o *PutServiceIDInvalidFrontend) WithPayload(payload models.Error) *PutServiceIDInvalidFrontend {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"PutServiceIDInvalidFrontend",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"PutServiceIDInvalidFrontend",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the put service Id invalid frontend response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"put",
"service",
"Id",
"invalid",
"frontend",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/service/put_service_id_responses.go#L86-L89 |
163,836 | cilium/cilium | api/v1/server/restapi/service/put_service_id_responses.go | WithPayload | func (o *PutServiceIDInvalidBackend) WithPayload(payload models.Error) *PutServiceIDInvalidBackend {
o.Payload = payload
return o
} | go | func (o *PutServiceIDInvalidBackend) WithPayload(payload models.Error) *PutServiceIDInvalidBackend {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"PutServiceIDInvalidBackend",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"PutServiceIDInvalidBackend",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the put service Id invalid backend response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"put",
"service",
"Id",
"invalid",
"backend",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/service/put_service_id_responses.go#L128-L131 |
163,837 | cilium/cilium | api/v1/server/restapi/service/put_service_id_responses.go | WithPayload | func (o *PutServiceIDFailure) WithPayload(payload models.Error) *PutServiceIDFailure {
o.Payload = payload
return o
} | go | func (o *PutServiceIDFailure) WithPayload(payload models.Error) *PutServiceIDFailure {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"PutServiceIDFailure",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"PutServiceIDFailure",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the put service Id failure response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"put",
"service",
"Id",
"failure",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/service/put_service_id_responses.go#L170-L173 |
163,838 | cilium/cilium | pkg/endpoint/connector/ipvlan.go | CreateIpvlanSlave | func CreateIpvlanSlave(id string, mtu, masterDev int, mode string, ep *models.EndpointChangeRequest) (*netlink.IPVlan, *netlink.Link, string, error) {
if id == "" {
return nil, nil, "", fmt.Errorf("invalid: empty ID")
}
tmpIfName := Endpoint2TempIfName(id)
ipvlan, link, err := createIpvlanSlave(tmpIfName, mtu, masterDev, mode, ep)
return ipvlan, link, tmpIfName, err
} | go | func CreateIpvlanSlave(id string, mtu, masterDev int, mode string, ep *models.EndpointChangeRequest) (*netlink.IPVlan, *netlink.Link, string, error) {
if id == "" {
return nil, nil, "", fmt.Errorf("invalid: empty ID")
}
tmpIfName := Endpoint2TempIfName(id)
ipvlan, link, err := createIpvlanSlave(tmpIfName, mtu, masterDev, mode, ep)
return ipvlan, link, tmpIfName, err
} | [
"func",
"CreateIpvlanSlave",
"(",
"id",
"string",
",",
"mtu",
",",
"masterDev",
"int",
",",
"mode",
"string",
",",
"ep",
"*",
"models",
".",
"EndpointChangeRequest",
")",
"(",
"*",
"netlink",
".",
"IPVlan",
",",
"*",
"netlink",
".",
"Link",
",",
"string",
",",
"error",
")",
"{",
"if",
"id",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"nil",
",",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"tmpIfName",
":=",
"Endpoint2TempIfName",
"(",
"id",
")",
"\n",
"ipvlan",
",",
"link",
",",
"err",
":=",
"createIpvlanSlave",
"(",
"tmpIfName",
",",
"mtu",
",",
"masterDev",
",",
"mode",
",",
"ep",
")",
"\n\n",
"return",
"ipvlan",
",",
"link",
",",
"tmpIfName",
",",
"err",
"\n",
"}"
] | // CreateIpvlanSlave creates an ipvlan slave in L3 based on the master device. | [
"CreateIpvlanSlave",
"creates",
"an",
"ipvlan",
"slave",
"in",
"L3",
"based",
"on",
"the",
"master",
"device",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/connector/ipvlan.go#L220-L229 |
163,839 | cilium/cilium | api/v1/server/restapi/endpoint/delete_endpoint_id.go | NewDeleteEndpointID | func NewDeleteEndpointID(ctx *middleware.Context, handler DeleteEndpointIDHandler) *DeleteEndpointID {
return &DeleteEndpointID{Context: ctx, Handler: handler}
} | go | func NewDeleteEndpointID(ctx *middleware.Context, handler DeleteEndpointIDHandler) *DeleteEndpointID {
return &DeleteEndpointID{Context: ctx, Handler: handler}
} | [
"func",
"NewDeleteEndpointID",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"DeleteEndpointIDHandler",
")",
"*",
"DeleteEndpointID",
"{",
"return",
"&",
"DeleteEndpointID",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewDeleteEndpointID creates a new http.Handler for the delete endpoint ID operation | [
"NewDeleteEndpointID",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"delete",
"endpoint",
"ID",
"operation"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/endpoint/delete_endpoint_id.go#L28-L30 |
163,840 | cilium/cilium | pkg/revert/finalize.go | Append | func (f *FinalizeList) Append(finalizeFunc FinalizeFunc) {
if finalizeFunc != nil {
f.finalizeFuncs = append(f.finalizeFuncs, finalizeFunc)
}
} | go | func (f *FinalizeList) Append(finalizeFunc FinalizeFunc) {
if finalizeFunc != nil {
f.finalizeFuncs = append(f.finalizeFuncs, finalizeFunc)
}
} | [
"func",
"(",
"f",
"*",
"FinalizeList",
")",
"Append",
"(",
"finalizeFunc",
"FinalizeFunc",
")",
"{",
"if",
"finalizeFunc",
"!=",
"nil",
"{",
"f",
".",
"finalizeFuncs",
"=",
"append",
"(",
"f",
".",
"finalizeFuncs",
",",
"finalizeFunc",
")",
"\n",
"}",
"\n",
"}"
] | // Append appends the given FinalizeFunc at the end of this list. If the
// function is nil, it is ignored. | [
"Append",
"appends",
"the",
"given",
"FinalizeFunc",
"at",
"the",
"end",
"of",
"this",
"list",
".",
"If",
"the",
"function",
"is",
"nil",
"it",
"is",
"ignored",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/revert/finalize.go#L35-L39 |
163,841 | cilium/cilium | api/v1/server/restapi/endpoint/patch_endpoint_id_responses.go | WithPayload | func (o *PatchEndpointIDInvalid) WithPayload(payload models.Error) *PatchEndpointIDInvalid {
o.Payload = payload
return o
} | go | func (o *PatchEndpointIDInvalid) WithPayload(payload models.Error) *PatchEndpointIDInvalid {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"PatchEndpointIDInvalid",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"PatchEndpointIDInvalid",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the patch endpoint Id invalid response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"patch",
"endpoint",
"Id",
"invalid",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/endpoint/patch_endpoint_id_responses.go#L62-L65 |
163,842 | cilium/cilium | api/v1/server/restapi/endpoint/patch_endpoint_id_responses.go | WithPayload | func (o *PatchEndpointIDFailed) WithPayload(payload models.Error) *PatchEndpointIDFailed {
o.Payload = payload
return o
} | go | func (o *PatchEndpointIDFailed) WithPayload(payload models.Error) *PatchEndpointIDFailed {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"PatchEndpointIDFailed",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"PatchEndpointIDFailed",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the patch endpoint Id failed response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"patch",
"endpoint",
"Id",
"failed",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/endpoint/patch_endpoint_id_responses.go#L128-L131 |
163,843 | cilium/cilium | api/v1/client/ipam/delete_ip_a_m_ip_parameters.go | WithTimeout | func (o *DeleteIPAMIPParams) WithTimeout(timeout time.Duration) *DeleteIPAMIPParams {
o.SetTimeout(timeout)
return o
} | go | func (o *DeleteIPAMIPParams) WithTimeout(timeout time.Duration) *DeleteIPAMIPParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"DeleteIPAMIPParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"DeleteIPAMIPParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the delete IP a m IP params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"delete",
"IP",
"a",
"m",
"IP",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/ipam/delete_ip_a_m_ip_parameters.go#L76-L79 |
163,844 | cilium/cilium | api/v1/client/ipam/delete_ip_a_m_ip_parameters.go | WithContext | func (o *DeleteIPAMIPParams) WithContext(ctx context.Context) *DeleteIPAMIPParams {
o.SetContext(ctx)
return o
} | go | func (o *DeleteIPAMIPParams) WithContext(ctx context.Context) *DeleteIPAMIPParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"DeleteIPAMIPParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"DeleteIPAMIPParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the delete IP a m IP params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"delete",
"IP",
"a",
"m",
"IP",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/ipam/delete_ip_a_m_ip_parameters.go#L87-L90 |
163,845 | cilium/cilium | api/v1/client/ipam/delete_ip_a_m_ip_parameters.go | WithHTTPClient | func (o *DeleteIPAMIPParams) WithHTTPClient(client *http.Client) *DeleteIPAMIPParams {
o.SetHTTPClient(client)
return o
} | go | func (o *DeleteIPAMIPParams) WithHTTPClient(client *http.Client) *DeleteIPAMIPParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"DeleteIPAMIPParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"DeleteIPAMIPParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the delete IP a m IP params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"delete",
"IP",
"a",
"m",
"IP",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/ipam/delete_ip_a_m_ip_parameters.go#L98-L101 |
163,846 | cilium/cilium | api/v1/client/ipam/delete_ip_a_m_ip_parameters.go | WithIP | func (o *DeleteIPAMIPParams) WithIP(ip string) *DeleteIPAMIPParams {
o.SetIP(ip)
return o
} | go | func (o *DeleteIPAMIPParams) WithIP(ip string) *DeleteIPAMIPParams {
o.SetIP(ip)
return o
} | [
"func",
"(",
"o",
"*",
"DeleteIPAMIPParams",
")",
"WithIP",
"(",
"ip",
"string",
")",
"*",
"DeleteIPAMIPParams",
"{",
"o",
".",
"SetIP",
"(",
"ip",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithIP adds the ip to the delete IP a m IP params | [
"WithIP",
"adds",
"the",
"ip",
"to",
"the",
"delete",
"IP",
"a",
"m",
"IP",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/ipam/delete_ip_a_m_ip_parameters.go#L109-L112 |
163,847 | cilium/cilium | api/v1/server/restapi/daemon/get_debuginfo.go | NewGetDebuginfo | func NewGetDebuginfo(ctx *middleware.Context, handler GetDebuginfoHandler) *GetDebuginfo {
return &GetDebuginfo{Context: ctx, Handler: handler}
} | go | func NewGetDebuginfo(ctx *middleware.Context, handler GetDebuginfoHandler) *GetDebuginfo {
return &GetDebuginfo{Context: ctx, Handler: handler}
} | [
"func",
"NewGetDebuginfo",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"GetDebuginfoHandler",
")",
"*",
"GetDebuginfo",
"{",
"return",
"&",
"GetDebuginfo",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewGetDebuginfo creates a new http.Handler for the get debuginfo operation | [
"NewGetDebuginfo",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"get",
"debuginfo",
"operation"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/daemon/get_debuginfo.go#L28-L30 |
163,848 | cilium/cilium | pkg/comparator/comparator.go | CompareWithNames | func CompareWithNames(a, b interface{}, nameA, nameB string) string {
stringA := pretty.Sprintf("%# v", a)
stringB := pretty.Sprintf("%# v", b)
diff := difflib.UnifiedDiff{
A: difflib.SplitLines(stringA),
B: difflib.SplitLines(stringB),
FromFile: nameA,
ToFile: nameB,
Context: 32,
}
out, err := difflib.GetUnifiedDiffString(diff)
if err != nil {
return err.Error()
}
return "Unified diff:\n" + out
} | go | func CompareWithNames(a, b interface{}, nameA, nameB string) string {
stringA := pretty.Sprintf("%# v", a)
stringB := pretty.Sprintf("%# v", b)
diff := difflib.UnifiedDiff{
A: difflib.SplitLines(stringA),
B: difflib.SplitLines(stringB),
FromFile: nameA,
ToFile: nameB,
Context: 32,
}
out, err := difflib.GetUnifiedDiffString(diff)
if err != nil {
return err.Error()
}
return "Unified diff:\n" + out
} | [
"func",
"CompareWithNames",
"(",
"a",
",",
"b",
"interface",
"{",
"}",
",",
"nameA",
",",
"nameB",
"string",
")",
"string",
"{",
"stringA",
":=",
"pretty",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"a",
")",
"\n",
"stringB",
":=",
"pretty",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"b",
")",
"\n",
"diff",
":=",
"difflib",
".",
"UnifiedDiff",
"{",
"A",
":",
"difflib",
".",
"SplitLines",
"(",
"stringA",
")",
",",
"B",
":",
"difflib",
".",
"SplitLines",
"(",
"stringB",
")",
",",
"FromFile",
":",
"nameA",
",",
"ToFile",
":",
"nameB",
",",
"Context",
":",
"32",
",",
"}",
"\n\n",
"out",
",",
"err",
":=",
"difflib",
".",
"GetUnifiedDiffString",
"(",
"diff",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
".",
"Error",
"(",
")",
"\n",
"}",
"\n",
"return",
"\"",
"\\n",
"\"",
"+",
"out",
"\n",
"}"
] | // CompareWithNames compares two interfaces and emits a unified diff as string | [
"CompareWithNames",
"compares",
"two",
"interfaces",
"and",
"emits",
"a",
"unified",
"diff",
"as",
"string"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/comparator/comparator.go#L28-L44 |
163,849 | cilium/cilium | pkg/comparator/comparator.go | MapStringEquals | func MapStringEquals(m1, m2 map[string]string) bool {
switch {
case m1 == nil && m2 == nil:
return true
case m1 == nil && m2 != nil,
m1 != nil && m2 == nil,
len(m1) != len(m2):
return false
}
for k1, v1 := range m1 {
if v2, ok := m2[k1]; !ok || v2 != v1 {
return false
}
}
return true
} | go | func MapStringEquals(m1, m2 map[string]string) bool {
switch {
case m1 == nil && m2 == nil:
return true
case m1 == nil && m2 != nil,
m1 != nil && m2 == nil,
len(m1) != len(m2):
return false
}
for k1, v1 := range m1 {
if v2, ok := m2[k1]; !ok || v2 != v1 {
return false
}
}
return true
} | [
"func",
"MapStringEquals",
"(",
"m1",
",",
"m2",
"map",
"[",
"string",
"]",
"string",
")",
"bool",
"{",
"switch",
"{",
"case",
"m1",
"==",
"nil",
"&&",
"m2",
"==",
"nil",
":",
"return",
"true",
"\n",
"case",
"m1",
"==",
"nil",
"&&",
"m2",
"!=",
"nil",
",",
"m1",
"!=",
"nil",
"&&",
"m2",
"==",
"nil",
",",
"len",
"(",
"m1",
")",
"!=",
"len",
"(",
"m2",
")",
":",
"return",
"false",
"\n",
"}",
"\n",
"for",
"k1",
",",
"v1",
":=",
"range",
"m1",
"{",
"if",
"v2",
",",
"ok",
":=",
"m2",
"[",
"k1",
"]",
";",
"!",
"ok",
"||",
"v2",
"!=",
"v1",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] | // MapStringEquals returns true if both maps are equal. | [
"MapStringEquals",
"returns",
"true",
"if",
"both",
"maps",
"are",
"equal",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/comparator/comparator.go#L47-L62 |
163,850 | cilium/cilium | pkg/node/store/store.go | RegisterNode | func (nr *NodeRegistrar) RegisterNode(n *node.Node, manager NodeManager) error {
// Join the shared store holding node information of entire cluster
store, err := store.JoinSharedStore(store.Configuration{
Prefix: NodeStorePrefix,
KeyCreator: KeyCreator,
Observer: NewNodeObserver(manager),
})
if err != nil {
return err
}
if err = store.UpdateLocalKeySync(n); err != nil {
store.Close()
return err
}
nr.SharedStore = store
return nil
} | go | func (nr *NodeRegistrar) RegisterNode(n *node.Node, manager NodeManager) error {
// Join the shared store holding node information of entire cluster
store, err := store.JoinSharedStore(store.Configuration{
Prefix: NodeStorePrefix,
KeyCreator: KeyCreator,
Observer: NewNodeObserver(manager),
})
if err != nil {
return err
}
if err = store.UpdateLocalKeySync(n); err != nil {
store.Close()
return err
}
nr.SharedStore = store
return nil
} | [
"func",
"(",
"nr",
"*",
"NodeRegistrar",
")",
"RegisterNode",
"(",
"n",
"*",
"node",
".",
"Node",
",",
"manager",
"NodeManager",
")",
"error",
"{",
"// Join the shared store holding node information of entire cluster",
"store",
",",
"err",
":=",
"store",
".",
"JoinSharedStore",
"(",
"store",
".",
"Configuration",
"{",
"Prefix",
":",
"NodeStorePrefix",
",",
"KeyCreator",
":",
"KeyCreator",
",",
"Observer",
":",
"NewNodeObserver",
"(",
"manager",
")",
",",
"}",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
"=",
"store",
".",
"UpdateLocalKeySync",
"(",
"n",
")",
";",
"err",
"!=",
"nil",
"{",
"store",
".",
"Close",
"(",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"nr",
".",
"SharedStore",
"=",
"store",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // RegisterNode registers the local node in the cluster | [
"RegisterNode",
"registers",
"the",
"local",
"node",
"in",
"the",
"cluster"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/store/store.go#L117-L138 |
163,851 | cilium/cilium | pkg/node/store/store.go | UpdateLocalKeySync | func (nr *NodeRegistrar) UpdateLocalKeySync(n *node.Node) error {
return nr.SharedStore.UpdateLocalKeySync(n)
} | go | func (nr *NodeRegistrar) UpdateLocalKeySync(n *node.Node) error {
return nr.SharedStore.UpdateLocalKeySync(n)
} | [
"func",
"(",
"nr",
"*",
"NodeRegistrar",
")",
"UpdateLocalKeySync",
"(",
"n",
"*",
"node",
".",
"Node",
")",
"error",
"{",
"return",
"nr",
".",
"SharedStore",
".",
"UpdateLocalKeySync",
"(",
"n",
")",
"\n",
"}"
] | // UpdateLocalKeySync synchronizes the local key for the node using the
// SharedStore. | [
"UpdateLocalKeySync",
"synchronizes",
"the",
"local",
"key",
"for",
"the",
"node",
"using",
"the",
"SharedStore",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/store/store.go#L142-L144 |
163,852 | cilium/cilium | pkg/node/zz_generated.deepcopy.go | DeepCopy | func (in *Address) DeepCopy() *Address {
if in == nil {
return nil
}
out := new(Address)
in.DeepCopyInto(out)
return out
} | go | func (in *Address) DeepCopy() *Address {
if in == nil {
return nil
}
out := new(Address)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"Address",
")",
"DeepCopy",
"(",
")",
"*",
"Address",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"Address",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Address. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"Address",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/node/zz_generated.deepcopy.go#L37-L44 |
163,853 | cilium/cilium | pkg/policy/api/l7.go | Sanitize | func (rule *PortRuleL7) Sanitize() error {
for k := range *rule {
if k == "" {
return fmt.Errorf("Empty key not allowed")
}
}
return nil
} | go | func (rule *PortRuleL7) Sanitize() error {
for k := range *rule {
if k == "" {
return fmt.Errorf("Empty key not allowed")
}
}
return nil
} | [
"func",
"(",
"rule",
"*",
"PortRuleL7",
")",
"Sanitize",
"(",
")",
"error",
"{",
"for",
"k",
":=",
"range",
"*",
"rule",
"{",
"if",
"k",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Sanitize sanitizes key-value pair rules. It makes sure keys are present. | [
"Sanitize",
"sanitizes",
"key",
"-",
"value",
"pair",
"rules",
".",
"It",
"makes",
"sure",
"keys",
"are",
"present",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/l7.go#L27-L34 |
163,854 | cilium/cilium | api/v1/server/restapi/endpoint/get_endpoint_id_responses.go | WithPayload | func (o *GetEndpointIDOK) WithPayload(payload *models.Endpoint) *GetEndpointIDOK {
o.Payload = payload
return o
} | go | func (o *GetEndpointIDOK) WithPayload(payload *models.Endpoint) *GetEndpointIDOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointIDOK",
")",
"WithPayload",
"(",
"payload",
"*",
"models",
".",
"Endpoint",
")",
"*",
"GetEndpointIDOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get endpoint Id o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"endpoint",
"Id",
"o",
"k",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/endpoint/get_endpoint_id_responses.go#L38-L41 |
163,855 | cilium/cilium | api/v1/server/restapi/endpoint/get_endpoint_id_responses.go | WithPayload | func (o *GetEndpointIDInvalid) WithPayload(payload models.Error) *GetEndpointIDInvalid {
o.Payload = payload
return o
} | go | func (o *GetEndpointIDInvalid) WithPayload(payload models.Error) *GetEndpointIDInvalid {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetEndpointIDInvalid",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"GetEndpointIDInvalid",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get endpoint Id invalid response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"endpoint",
"Id",
"invalid",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/endpoint/get_endpoint_id_responses.go#L82-L85 |
163,856 | cilium/cilium | plugins/cilium-cni/types/types.go | LoadNetConf | func LoadNetConf(bytes []byte) (*NetConf, string, error) {
n := &NetConf{}
if err := json.Unmarshal(bytes, n); err != nil {
return nil, "", fmt.Errorf("failed to load netconf: %s", err)
}
return n, n.CNIVersion, nil
} | go | func LoadNetConf(bytes []byte) (*NetConf, string, error) {
n := &NetConf{}
if err := json.Unmarshal(bytes, n); err != nil {
return nil, "", fmt.Errorf("failed to load netconf: %s", err)
}
return n, n.CNIVersion, nil
} | [
"func",
"LoadNetConf",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"*",
"NetConf",
",",
"string",
",",
"error",
")",
"{",
"n",
":=",
"&",
"NetConf",
"{",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"bytes",
",",
"n",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"n",
",",
"n",
".",
"CNIVersion",
",",
"nil",
"\n",
"}"
] | // LoadNetConf unmarshals a Cilium network configuration from JSON and returns
// a NetConf together with the CNI version | [
"LoadNetConf",
"unmarshals",
"a",
"Cilium",
"network",
"configuration",
"from",
"JSON",
"and",
"returns",
"a",
"NetConf",
"together",
"with",
"the",
"CNI",
"version"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/plugins/cilium-cni/types/types.go#L34-L40 |
163,857 | cilium/cilium | pkg/fqdn/lookup.go | doResolverLogic | func doResolverLogic(lookupFunc func(string, string, uint16) (*dns.Msg, error), dnsNames []string) (DNSIPs map[string]*DNSIPRecords, DNSErrors map[string]error) {
DNSIPs = make(map[string]*DNSIPRecords)
DNSErrors = make(map[string]error)
// This is the top-level list of names to query
for _, dnsName := range dnsNames {
responseData := &DNSIPRecords{TTL: math.MaxInt32}
// Query for A & AAAA for each dnsName
perTypeToQuery:
for _, dnsType := range []dns.Type{dns.Type(dns.TypeA), dns.Type(dns.TypeAAAA)} { // the dns library doesn't use dns.Type
// Try the servers in the order they were configured in resolv.conf
perServerToAttempt:
for _, server := range dnsConfig.Servers {
response, err := lookupFunc(server+":"+dnsConfig.Port, dnsName, uint16(dnsType))
// Move onto the next server when the response is bad
switch {
case err != nil:
DNSErrors[dnsName] = fmt.Errorf("error when querying %s: %s", server, err)
continue perServerToAttempt
case response.Response != true:
continue perServerToAttempt
case response.Rcode != dns.RcodeSuccess: // e.g. NXDomain or Refused
// Not an error, but also no data we can use. Move on to the next
// type. We assume that the servers are not lying to us (i.e. they
// can all answer the query)
DNSErrors[dnsName] = fmt.Errorf("no data when querying %s", server)
continue perTypeToQuery
}
// To arrive here means:
// - The server responded without a communication error
// - response.Rcode == dns.RcodeSuccess
delete(DNSErrors, dnsName) // clear any errors we set for other servers
for _, answer := range response.Answer {
switch answer := answer.(type) {
case *dns.A:
DNSIPs[dnsName] = responseData // return only when we have an answer
responseData.IPs = append(responseData.IPs, answer.A)
responseData.TTL = ttlMin(responseData.TTL, int(answer.Hdr.Ttl))
case *dns.AAAA:
DNSIPs[dnsName] = responseData // return only when we have an answer
responseData.IPs = append(responseData.IPs, answer.AAAA)
responseData.TTL = ttlMin(responseData.TTL, int(answer.Hdr.Ttl))
case *dns.CNAME:
// Do we need to enforce any policy on this?
// Responses with CNAMEs from recursive resolvers will have IPs
// included, and we will return those as the IPs for dnsName.
// We still track the TTL because the lowest TTL in the chain
// determines the valid caching time for the whole response.
responseData.TTL = ttlMin(responseData.TTL, int(answer.Hdr.Ttl))
// Treat an inappropriate response like no response, and try another
// server
default:
DNSErrors[dnsName] = fmt.Errorf("unexpected DNS Resource Records(%T) in response from %s: %s", answer, server, err)
continue perServerToAttempt
}
}
// We have a valid response, stop trying queryNames or other servers.
continue perTypeToQuery
}
}
}
return DNSIPs, DNSErrors
} | go | func doResolverLogic(lookupFunc func(string, string, uint16) (*dns.Msg, error), dnsNames []string) (DNSIPs map[string]*DNSIPRecords, DNSErrors map[string]error) {
DNSIPs = make(map[string]*DNSIPRecords)
DNSErrors = make(map[string]error)
// This is the top-level list of names to query
for _, dnsName := range dnsNames {
responseData := &DNSIPRecords{TTL: math.MaxInt32}
// Query for A & AAAA for each dnsName
perTypeToQuery:
for _, dnsType := range []dns.Type{dns.Type(dns.TypeA), dns.Type(dns.TypeAAAA)} { // the dns library doesn't use dns.Type
// Try the servers in the order they were configured in resolv.conf
perServerToAttempt:
for _, server := range dnsConfig.Servers {
response, err := lookupFunc(server+":"+dnsConfig.Port, dnsName, uint16(dnsType))
// Move onto the next server when the response is bad
switch {
case err != nil:
DNSErrors[dnsName] = fmt.Errorf("error when querying %s: %s", server, err)
continue perServerToAttempt
case response.Response != true:
continue perServerToAttempt
case response.Rcode != dns.RcodeSuccess: // e.g. NXDomain or Refused
// Not an error, but also no data we can use. Move on to the next
// type. We assume that the servers are not lying to us (i.e. they
// can all answer the query)
DNSErrors[dnsName] = fmt.Errorf("no data when querying %s", server)
continue perTypeToQuery
}
// To arrive here means:
// - The server responded without a communication error
// - response.Rcode == dns.RcodeSuccess
delete(DNSErrors, dnsName) // clear any errors we set for other servers
for _, answer := range response.Answer {
switch answer := answer.(type) {
case *dns.A:
DNSIPs[dnsName] = responseData // return only when we have an answer
responseData.IPs = append(responseData.IPs, answer.A)
responseData.TTL = ttlMin(responseData.TTL, int(answer.Hdr.Ttl))
case *dns.AAAA:
DNSIPs[dnsName] = responseData // return only when we have an answer
responseData.IPs = append(responseData.IPs, answer.AAAA)
responseData.TTL = ttlMin(responseData.TTL, int(answer.Hdr.Ttl))
case *dns.CNAME:
// Do we need to enforce any policy on this?
// Responses with CNAMEs from recursive resolvers will have IPs
// included, and we will return those as the IPs for dnsName.
// We still track the TTL because the lowest TTL in the chain
// determines the valid caching time for the whole response.
responseData.TTL = ttlMin(responseData.TTL, int(answer.Hdr.Ttl))
// Treat an inappropriate response like no response, and try another
// server
default:
DNSErrors[dnsName] = fmt.Errorf("unexpected DNS Resource Records(%T) in response from %s: %s", answer, server, err)
continue perServerToAttempt
}
}
// We have a valid response, stop trying queryNames or other servers.
continue perTypeToQuery
}
}
}
return DNSIPs, DNSErrors
} | [
"func",
"doResolverLogic",
"(",
"lookupFunc",
"func",
"(",
"string",
",",
"string",
",",
"uint16",
")",
"(",
"*",
"dns",
".",
"Msg",
",",
"error",
")",
",",
"dnsNames",
"[",
"]",
"string",
")",
"(",
"DNSIPs",
"map",
"[",
"string",
"]",
"*",
"DNSIPRecords",
",",
"DNSErrors",
"map",
"[",
"string",
"]",
"error",
")",
"{",
"DNSIPs",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"DNSIPRecords",
")",
"\n",
"DNSErrors",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"error",
")",
"\n\n",
"// This is the top-level list of names to query",
"for",
"_",
",",
"dnsName",
":=",
"range",
"dnsNames",
"{",
"responseData",
":=",
"&",
"DNSIPRecords",
"{",
"TTL",
":",
"math",
".",
"MaxInt32",
"}",
"\n\n",
"// Query for A & AAAA for each dnsName",
"perTypeToQuery",
":",
"for",
"_",
",",
"dnsType",
":=",
"range",
"[",
"]",
"dns",
".",
"Type",
"{",
"dns",
".",
"Type",
"(",
"dns",
".",
"TypeA",
")",
",",
"dns",
".",
"Type",
"(",
"dns",
".",
"TypeAAAA",
")",
"}",
"{",
"// the dns library doesn't use dns.Type",
"// Try the servers in the order they were configured in resolv.conf",
"perServerToAttempt",
":",
"for",
"_",
",",
"server",
":=",
"range",
"dnsConfig",
".",
"Servers",
"{",
"response",
",",
"err",
":=",
"lookupFunc",
"(",
"server",
"+",
"\"",
"\"",
"+",
"dnsConfig",
".",
"Port",
",",
"dnsName",
",",
"uint16",
"(",
"dnsType",
")",
")",
"\n",
"// Move onto the next server when the response is bad",
"switch",
"{",
"case",
"err",
"!=",
"nil",
":",
"DNSErrors",
"[",
"dnsName",
"]",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"server",
",",
"err",
")",
"\n",
"continue",
"perServerToAttempt",
"\n",
"case",
"response",
".",
"Response",
"!=",
"true",
":",
"continue",
"perServerToAttempt",
"\n",
"case",
"response",
".",
"Rcode",
"!=",
"dns",
".",
"RcodeSuccess",
":",
"// e.g. NXDomain or Refused",
"// Not an error, but also no data we can use. Move on to the next",
"// type. We assume that the servers are not lying to us (i.e. they",
"// can all answer the query)",
"DNSErrors",
"[",
"dnsName",
"]",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"server",
")",
"\n",
"continue",
"perTypeToQuery",
"\n",
"}",
"\n\n",
"// To arrive here means:",
"// - The server responded without a communication error",
"// - response.Rcode == dns.RcodeSuccess",
"delete",
"(",
"DNSErrors",
",",
"dnsName",
")",
"// clear any errors we set for other servers",
"\n\n",
"for",
"_",
",",
"answer",
":=",
"range",
"response",
".",
"Answer",
"{",
"switch",
"answer",
":=",
"answer",
".",
"(",
"type",
")",
"{",
"case",
"*",
"dns",
".",
"A",
":",
"DNSIPs",
"[",
"dnsName",
"]",
"=",
"responseData",
"// return only when we have an answer",
"\n",
"responseData",
".",
"IPs",
"=",
"append",
"(",
"responseData",
".",
"IPs",
",",
"answer",
".",
"A",
")",
"\n",
"responseData",
".",
"TTL",
"=",
"ttlMin",
"(",
"responseData",
".",
"TTL",
",",
"int",
"(",
"answer",
".",
"Hdr",
".",
"Ttl",
")",
")",
"\n\n",
"case",
"*",
"dns",
".",
"AAAA",
":",
"DNSIPs",
"[",
"dnsName",
"]",
"=",
"responseData",
"// return only when we have an answer",
"\n",
"responseData",
".",
"IPs",
"=",
"append",
"(",
"responseData",
".",
"IPs",
",",
"answer",
".",
"AAAA",
")",
"\n",
"responseData",
".",
"TTL",
"=",
"ttlMin",
"(",
"responseData",
".",
"TTL",
",",
"int",
"(",
"answer",
".",
"Hdr",
".",
"Ttl",
")",
")",
"\n\n",
"case",
"*",
"dns",
".",
"CNAME",
":",
"// Do we need to enforce any policy on this?",
"// Responses with CNAMEs from recursive resolvers will have IPs",
"// included, and we will return those as the IPs for dnsName.",
"// We still track the TTL because the lowest TTL in the chain",
"// determines the valid caching time for the whole response.",
"responseData",
".",
"TTL",
"=",
"ttlMin",
"(",
"responseData",
".",
"TTL",
",",
"int",
"(",
"answer",
".",
"Hdr",
".",
"Ttl",
")",
")",
"\n\n",
"// Treat an inappropriate response like no response, and try another",
"// server",
"default",
":",
"DNSErrors",
"[",
"dnsName",
"]",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"answer",
",",
"server",
",",
"err",
")",
"\n",
"continue",
"perServerToAttempt",
"\n",
"}",
"\n",
"}",
"\n\n",
"// We have a valid response, stop trying queryNames or other servers.",
"continue",
"perTypeToQuery",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"DNSIPs",
",",
"DNSErrors",
"\n",
"}"
] | // doResolverLogic exists to allow testing the more complex logic around
// collecting A and AAAA records, handling CNAMEs and trying different servers. | [
"doResolverLogic",
"exists",
"to",
"allow",
"testing",
"the",
"more",
"complex",
"logic",
"around",
"collecting",
"A",
"and",
"AAAA",
"records",
"handling",
"CNAMEs",
"and",
"trying",
"different",
"servers",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/fqdn/lookup.go#L111-L182 |
163,858 | cilium/cilium | pkg/client/client.go | DefaultSockPath | func DefaultSockPath() string {
// Check if environment variable points to socket
e := os.Getenv(defaults.SockPathEnv)
if e == "" {
// If unset, fall back to default value
e = defaults.SockPath
}
return "unix://" + e
} | go | func DefaultSockPath() string {
// Check if environment variable points to socket
e := os.Getenv(defaults.SockPathEnv)
if e == "" {
// If unset, fall back to default value
e = defaults.SockPath
}
return "unix://" + e
} | [
"func",
"DefaultSockPath",
"(",
")",
"string",
"{",
"// Check if environment variable points to socket",
"e",
":=",
"os",
".",
"Getenv",
"(",
"defaults",
".",
"SockPathEnv",
")",
"\n",
"if",
"e",
"==",
"\"",
"\"",
"{",
"// If unset, fall back to default value",
"e",
"=",
"defaults",
".",
"SockPath",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"+",
"e",
"\n\n",
"}"
] | // DefaultSockPath returns deafult UNIX domain socket path or
// path set using CILIUM_SOCK env variable | [
"DefaultSockPath",
"returns",
"deafult",
"UNIX",
"domain",
"socket",
"path",
"or",
"path",
"set",
"using",
"CILIUM_SOCK",
"env",
"variable"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/client.go#L45-L54 |
163,859 | cilium/cilium | pkg/client/client.go | NewDefaultClientWithTimeout | func NewDefaultClientWithTimeout(timeout time.Duration) (*Client, error) {
timeoutAfter := time.After(timeout)
var c *Client
var err error
for {
select {
case <-timeoutAfter:
return nil, fmt.Errorf("failed to create cilium agent client after %f seconds timeout: %s", timeout.Seconds(), err)
default:
}
c, err = NewDefaultClient()
if err != nil {
time.Sleep(500 * time.Millisecond)
continue
}
for {
select {
case <-timeoutAfter:
return nil, fmt.Errorf("failed to create cilium agent client after %f seconds timeout: %s", timeout.Seconds(), err)
default:
}
// This is an API call that we do to the cilium-agent to check
// if it is up and running.
_, err = c.Daemon.GetConfig(nil)
if err != nil {
time.Sleep(500 * time.Millisecond)
continue
}
return c, nil
}
}
} | go | func NewDefaultClientWithTimeout(timeout time.Duration) (*Client, error) {
timeoutAfter := time.After(timeout)
var c *Client
var err error
for {
select {
case <-timeoutAfter:
return nil, fmt.Errorf("failed to create cilium agent client after %f seconds timeout: %s", timeout.Seconds(), err)
default:
}
c, err = NewDefaultClient()
if err != nil {
time.Sleep(500 * time.Millisecond)
continue
}
for {
select {
case <-timeoutAfter:
return nil, fmt.Errorf("failed to create cilium agent client after %f seconds timeout: %s", timeout.Seconds(), err)
default:
}
// This is an API call that we do to the cilium-agent to check
// if it is up and running.
_, err = c.Daemon.GetConfig(nil)
if err != nil {
time.Sleep(500 * time.Millisecond)
continue
}
return c, nil
}
}
} | [
"func",
"NewDefaultClientWithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"timeoutAfter",
":=",
"time",
".",
"After",
"(",
"timeout",
")",
"\n",
"var",
"c",
"*",
"Client",
"\n",
"var",
"err",
"error",
"\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"timeoutAfter",
":",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"timeout",
".",
"Seconds",
"(",
")",
",",
"err",
")",
"\n",
"default",
":",
"}",
"\n\n",
"c",
",",
"err",
"=",
"NewDefaultClient",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"time",
".",
"Sleep",
"(",
"500",
"*",
"time",
".",
"Millisecond",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"timeoutAfter",
":",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"timeout",
".",
"Seconds",
"(",
")",
",",
"err",
")",
"\n",
"default",
":",
"}",
"\n",
"// This is an API call that we do to the cilium-agent to check",
"// if it is up and running.",
"_",
",",
"err",
"=",
"c",
".",
"Daemon",
".",
"GetConfig",
"(",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"time",
".",
"Sleep",
"(",
"500",
"*",
"time",
".",
"Millisecond",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"return",
"c",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // NewDefaultClientWithTimeout creates a client with default parameters connecting to UNIX
// domain socket and waits for cilium-agent availability. | [
"NewDefaultClientWithTimeout",
"creates",
"a",
"client",
"with",
"default",
"parameters",
"connecting",
"to",
"UNIX",
"domain",
"socket",
"and",
"waits",
"for",
"cilium",
"-",
"agent",
"availability",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/client.go#L82-L115 |
163,860 | cilium/cilium | pkg/client/client.go | NewClient | func NewClient(host string) (*Client, error) {
if host == "" {
host = DefaultSockPath()
}
tmp := strings.SplitN(host, "://", 2)
if len(tmp) != 2 {
return nil, fmt.Errorf("invalid host format '%s'", host)
}
switch tmp[0] {
case "tcp":
if _, err := url.Parse("tcp://" + tmp[1]); err != nil {
return nil, err
}
host = "http://" + tmp[1]
case "unix":
host = tmp[1]
}
transport := configureTransport(nil, tmp[0], host)
httpClient := &http.Client{Transport: transport}
clientTrans := runtime_client.NewWithClient(tmp[1], clientapi.DefaultBasePath,
clientapi.DefaultSchemes, httpClient)
return &Client{*clientapi.New(clientTrans, strfmt.Default)}, nil
} | go | func NewClient(host string) (*Client, error) {
if host == "" {
host = DefaultSockPath()
}
tmp := strings.SplitN(host, "://", 2)
if len(tmp) != 2 {
return nil, fmt.Errorf("invalid host format '%s'", host)
}
switch tmp[0] {
case "tcp":
if _, err := url.Parse("tcp://" + tmp[1]); err != nil {
return nil, err
}
host = "http://" + tmp[1]
case "unix":
host = tmp[1]
}
transport := configureTransport(nil, tmp[0], host)
httpClient := &http.Client{Transport: transport}
clientTrans := runtime_client.NewWithClient(tmp[1], clientapi.DefaultBasePath,
clientapi.DefaultSchemes, httpClient)
return &Client{*clientapi.New(clientTrans, strfmt.Default)}, nil
} | [
"func",
"NewClient",
"(",
"host",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"if",
"host",
"==",
"\"",
"\"",
"{",
"host",
"=",
"DefaultSockPath",
"(",
")",
"\n",
"}",
"\n",
"tmp",
":=",
"strings",
".",
"SplitN",
"(",
"host",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"if",
"len",
"(",
"tmp",
")",
"!=",
"2",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"host",
")",
"\n",
"}",
"\n\n",
"switch",
"tmp",
"[",
"0",
"]",
"{",
"case",
"\"",
"\"",
":",
"if",
"_",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"\"",
"\"",
"+",
"tmp",
"[",
"1",
"]",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"host",
"=",
"\"",
"\"",
"+",
"tmp",
"[",
"1",
"]",
"\n",
"case",
"\"",
"\"",
":",
"host",
"=",
"tmp",
"[",
"1",
"]",
"\n",
"}",
"\n\n",
"transport",
":=",
"configureTransport",
"(",
"nil",
",",
"tmp",
"[",
"0",
"]",
",",
"host",
")",
"\n",
"httpClient",
":=",
"&",
"http",
".",
"Client",
"{",
"Transport",
":",
"transport",
"}",
"\n",
"clientTrans",
":=",
"runtime_client",
".",
"NewWithClient",
"(",
"tmp",
"[",
"1",
"]",
",",
"clientapi",
".",
"DefaultBasePath",
",",
"clientapi",
".",
"DefaultSchemes",
",",
"httpClient",
")",
"\n",
"return",
"&",
"Client",
"{",
"*",
"clientapi",
".",
"New",
"(",
"clientTrans",
",",
"strfmt",
".",
"Default",
")",
"}",
",",
"nil",
"\n",
"}"
] | // NewClient creates a client for the given `host`.
// If host is nil then use SockPath provided by CILIUM_SOCK
// or the cilium default SockPath | [
"NewClient",
"creates",
"a",
"client",
"for",
"the",
"given",
"host",
".",
"If",
"host",
"is",
"nil",
"then",
"use",
"SockPath",
"provided",
"by",
"CILIUM_SOCK",
"or",
"the",
"cilium",
"default",
"SockPath"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/client.go#L120-L144 |
163,861 | cilium/cilium | pkg/client/client.go | FormatStatusResponseBrief | func FormatStatusResponseBrief(w io.Writer, sr *models.StatusResponse) {
msg := ""
switch {
case statusUnhealthy(sr.Kvstore):
msg = fmt.Sprintf("kvstore: %s", sr.Kvstore.Msg)
case statusUnhealthy(sr.ContainerRuntime):
msg = fmt.Sprintf("container runtime: %s", sr.ContainerRuntime.Msg)
case sr.Kubernetes != nil && stateUnhealthy(sr.Kubernetes.State):
msg = fmt.Sprintf("kubernetes: %s", sr.Kubernetes.Msg)
case statusUnhealthy(sr.Cilium):
msg = fmt.Sprintf("cilium: %s", sr.Cilium.Msg)
case sr.Cluster != nil && statusUnhealthy(sr.Cluster.CiliumHealth):
msg = fmt.Sprintf("cilium-health: %s", sr.Cluster.CiliumHealth.Msg)
}
// Only bother looking at controller failures if everything else is ok
if msg == "" {
for _, ctrl := range sr.Controllers {
if ctrl.Status == nil {
continue
}
if ctrl.Status.LastFailureMsg != "" {
msg = fmt.Sprintf("controller %s: %s",
ctrl.Name, ctrl.Status.LastFailureMsg)
break
}
}
}
if msg == "" {
fmt.Fprintf(w, "OK\n")
} else {
fmt.Fprintf(w, "error in %s\n", msg)
}
} | go | func FormatStatusResponseBrief(w io.Writer, sr *models.StatusResponse) {
msg := ""
switch {
case statusUnhealthy(sr.Kvstore):
msg = fmt.Sprintf("kvstore: %s", sr.Kvstore.Msg)
case statusUnhealthy(sr.ContainerRuntime):
msg = fmt.Sprintf("container runtime: %s", sr.ContainerRuntime.Msg)
case sr.Kubernetes != nil && stateUnhealthy(sr.Kubernetes.State):
msg = fmt.Sprintf("kubernetes: %s", sr.Kubernetes.Msg)
case statusUnhealthy(sr.Cilium):
msg = fmt.Sprintf("cilium: %s", sr.Cilium.Msg)
case sr.Cluster != nil && statusUnhealthy(sr.Cluster.CiliumHealth):
msg = fmt.Sprintf("cilium-health: %s", sr.Cluster.CiliumHealth.Msg)
}
// Only bother looking at controller failures if everything else is ok
if msg == "" {
for _, ctrl := range sr.Controllers {
if ctrl.Status == nil {
continue
}
if ctrl.Status.LastFailureMsg != "" {
msg = fmt.Sprintf("controller %s: %s",
ctrl.Name, ctrl.Status.LastFailureMsg)
break
}
}
}
if msg == "" {
fmt.Fprintf(w, "OK\n")
} else {
fmt.Fprintf(w, "error in %s\n", msg)
}
} | [
"func",
"FormatStatusResponseBrief",
"(",
"w",
"io",
".",
"Writer",
",",
"sr",
"*",
"models",
".",
"StatusResponse",
")",
"{",
"msg",
":=",
"\"",
"\"",
"\n\n",
"switch",
"{",
"case",
"statusUnhealthy",
"(",
"sr",
".",
"Kvstore",
")",
":",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"sr",
".",
"Kvstore",
".",
"Msg",
")",
"\n",
"case",
"statusUnhealthy",
"(",
"sr",
".",
"ContainerRuntime",
")",
":",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"sr",
".",
"ContainerRuntime",
".",
"Msg",
")",
"\n",
"case",
"sr",
".",
"Kubernetes",
"!=",
"nil",
"&&",
"stateUnhealthy",
"(",
"sr",
".",
"Kubernetes",
".",
"State",
")",
":",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"sr",
".",
"Kubernetes",
".",
"Msg",
")",
"\n",
"case",
"statusUnhealthy",
"(",
"sr",
".",
"Cilium",
")",
":",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"sr",
".",
"Cilium",
".",
"Msg",
")",
"\n",
"case",
"sr",
".",
"Cluster",
"!=",
"nil",
"&&",
"statusUnhealthy",
"(",
"sr",
".",
"Cluster",
".",
"CiliumHealth",
")",
":",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"sr",
".",
"Cluster",
".",
"CiliumHealth",
".",
"Msg",
")",
"\n",
"}",
"\n\n",
"// Only bother looking at controller failures if everything else is ok",
"if",
"msg",
"==",
"\"",
"\"",
"{",
"for",
"_",
",",
"ctrl",
":=",
"range",
"sr",
".",
"Controllers",
"{",
"if",
"ctrl",
".",
"Status",
"==",
"nil",
"{",
"continue",
"\n",
"}",
"\n",
"if",
"ctrl",
".",
"Status",
".",
"LastFailureMsg",
"!=",
"\"",
"\"",
"{",
"msg",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ctrl",
".",
"Name",
",",
"ctrl",
".",
"Status",
".",
"LastFailureMsg",
")",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"msg",
"==",
"\"",
"\"",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\n",
"\"",
",",
"msg",
")",
"\n",
"}",
"\n",
"}"
] | // FormatStatusResponseBrief writes a one-line status to the writer. If
// everything ok, this is "ok", otherwise a message of the form "error in ..." | [
"FormatStatusResponseBrief",
"writes",
"a",
"one",
"-",
"line",
"status",
"to",
"the",
"writer",
".",
"If",
"everything",
"ok",
"this",
"is",
"ok",
"otherwise",
"a",
"message",
"of",
"the",
"form",
"error",
"in",
"..."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/client.go#L214-L249 |
163,862 | cilium/cilium | pkg/client/client.go | FormatStatusResponse | func FormatStatusResponse(w io.Writer, sr *models.StatusResponse, allAddresses, allControllers, allNodes, allRedirects bool) {
if sr.Kvstore != nil {
fmt.Fprintf(w, "KVStore:\t%s\t%s\n", sr.Kvstore.State, sr.Kvstore.Msg)
}
if sr.ContainerRuntime != nil {
fmt.Fprintf(w, "ContainerRuntime:\t%s\t%s\n",
sr.ContainerRuntime.State, sr.ContainerRuntime.Msg)
}
if sr.Kubernetes != nil {
fmt.Fprintf(w, "Kubernetes:\t%s\t%s\n", sr.Kubernetes.State, sr.Kubernetes.Msg)
if sr.Kubernetes.State != models.K8sStatusStateDisabled {
sort.Strings(sr.Kubernetes.K8sAPIVersions)
fmt.Fprintf(w, "Kubernetes APIs:\t[\"%s\"]\n", strings.Join(sr.Kubernetes.K8sAPIVersions, "\", \""))
}
}
if sr.Cilium != nil {
fmt.Fprintf(w, "Cilium:\t%s\t%s\n", sr.Cilium.State, sr.Cilium.Msg)
}
if sr.Stale != nil {
sortedProbes := make([]string, 0, len(sr.Stale))
for probe := range sr.Stale {
sortedProbes = append(sortedProbes, probe)
}
sort.Strings(sortedProbes)
stalesStr := make([]string, 0, len(sr.Stale))
for _, probe := range sortedProbes {
stalesStr = append(stalesStr, fmt.Sprintf("%q since %s", probe, sr.Stale[probe]))
}
fmt.Fprintf(w, "Stale status:\t%s\n", strings.Join(stalesStr, ", "))
}
if nm := sr.NodeMonitor; nm != nil {
fmt.Fprintf(w, "NodeMonitor:\tListening for events on %d CPUs with %dx%d of shared memory\n",
nm.Cpus, nm.Npages, nm.Pagesize)
if nm.Lost != 0 || nm.Unknown != 0 {
fmt.Fprintf(w, "\t%d events lost, %d unknown notifications\n", nm.Lost, nm.Unknown)
}
} else {
fmt.Fprintf(w, "NodeMonitor:\tDisabled\n")
}
var localNode *models.NodeElement
if sr.Cluster != nil {
if sr.Cluster.CiliumHealth != nil {
ch := sr.Cluster.CiliumHealth
fmt.Fprintf(w, "Cilium health daemon:\t%s\t%s\n", ch.State, ch.Msg)
}
for _, node := range sr.Cluster.Nodes {
if node.Name == sr.Cluster.Self {
localNode = node
} else {
continue
}
}
}
if sr.IPAM != nil {
var v4CIDR, v6CIDR, v4AllocRangeFmt, v6AllocRangeFmt string
if localNode != nil {
if v4AllocRange := localNode.PrimaryAddress.IPV4.AllocRange; v4AllocRange != "" {
v4AllocRangeFmt = fmt.Sprintf(" allocated from %s", v4AllocRange)
if nIPs := ip.CountIPsInCIDR(v4AllocRange); nIPs > 0 {
v4CIDR = fmt.Sprintf("/%d", nIPs)
}
}
if v6AllocRange := localNode.PrimaryAddress.IPV6.AllocRange; v6AllocRange != "" {
v6AllocRangeFmt = fmt.Sprintf(" allocated from %s", v6AllocRange)
if nIPs := ip.CountIPsInCIDR(v6AllocRange); nIPs > 0 {
v6CIDR = fmt.Sprintf("/%d", nIPs)
}
}
}
if v4AllocRangeFmt != "" {
fmt.Fprintf(w, "IPv4 address pool:\t%d%s%s\n", len(sr.IPAM.IPV4), v4CIDR, v4AllocRangeFmt)
}
if v6AllocRangeFmt != "" {
fmt.Fprintf(w, "IPv6 address pool:\t%d%s%s\n", len(sr.IPAM.IPV6), v6CIDR, v6AllocRangeFmt)
}
if allAddresses {
fmt.Fprintf(w, "Allocated addresses:\n")
out := []string{}
for ip, owner := range sr.IPAM.Allocations {
out = append(out, fmt.Sprintf(" %s (%s)", ip, owner))
}
sort.Strings(out)
for _, line := range out {
fmt.Fprintln(w, line)
}
}
}
if sr.Controllers != nil {
nFailing, out := 0, []string{" Name\tLast success\tLast error\tCount\tMessage\n"}
for _, ctrl := range sr.Controllers {
status := ctrl.Status
if status == nil {
continue
}
if status.ConsecutiveFailureCount > 0 {
nFailing++
} else if !allControllers {
continue
}
failSince := timeSince(time.Time(status.LastFailureTimestamp))
successSince := timeSince(time.Time(status.LastSuccessTimestamp))
err := "no error"
if status.LastFailureMsg != "" {
err = status.LastFailureMsg
}
out = append(out, fmt.Sprintf(" %s\t%s\t%s\t%d\t%s\t\n",
ctrl.Name, successSince, failSince, status.ConsecutiveFailureCount, err))
}
nOK := len(sr.Controllers) - nFailing
fmt.Fprintf(w, "Controller Status:\t%d/%d healthy\n", nOK, len(sr.Controllers))
if len(out) > 1 {
tab := tabwriter.NewWriter(w, 0, 0, 3, ' ', 0)
sort.Strings(out)
for _, s := range out {
fmt.Fprint(tab, s)
}
tab.Flush()
}
}
if sr.Proxy != nil {
fmt.Fprintf(w, "Proxy Status:\tOK, ip %s, port-range %s\n",
sr.Proxy.IP, sr.Proxy.PortRange)
} else {
fmt.Fprintf(w, "Proxy Status:\tNo managed proxy redirect\n")
}
} | go | func FormatStatusResponse(w io.Writer, sr *models.StatusResponse, allAddresses, allControllers, allNodes, allRedirects bool) {
if sr.Kvstore != nil {
fmt.Fprintf(w, "KVStore:\t%s\t%s\n", sr.Kvstore.State, sr.Kvstore.Msg)
}
if sr.ContainerRuntime != nil {
fmt.Fprintf(w, "ContainerRuntime:\t%s\t%s\n",
sr.ContainerRuntime.State, sr.ContainerRuntime.Msg)
}
if sr.Kubernetes != nil {
fmt.Fprintf(w, "Kubernetes:\t%s\t%s\n", sr.Kubernetes.State, sr.Kubernetes.Msg)
if sr.Kubernetes.State != models.K8sStatusStateDisabled {
sort.Strings(sr.Kubernetes.K8sAPIVersions)
fmt.Fprintf(w, "Kubernetes APIs:\t[\"%s\"]\n", strings.Join(sr.Kubernetes.K8sAPIVersions, "\", \""))
}
}
if sr.Cilium != nil {
fmt.Fprintf(w, "Cilium:\t%s\t%s\n", sr.Cilium.State, sr.Cilium.Msg)
}
if sr.Stale != nil {
sortedProbes := make([]string, 0, len(sr.Stale))
for probe := range sr.Stale {
sortedProbes = append(sortedProbes, probe)
}
sort.Strings(sortedProbes)
stalesStr := make([]string, 0, len(sr.Stale))
for _, probe := range sortedProbes {
stalesStr = append(stalesStr, fmt.Sprintf("%q since %s", probe, sr.Stale[probe]))
}
fmt.Fprintf(w, "Stale status:\t%s\n", strings.Join(stalesStr, ", "))
}
if nm := sr.NodeMonitor; nm != nil {
fmt.Fprintf(w, "NodeMonitor:\tListening for events on %d CPUs with %dx%d of shared memory\n",
nm.Cpus, nm.Npages, nm.Pagesize)
if nm.Lost != 0 || nm.Unknown != 0 {
fmt.Fprintf(w, "\t%d events lost, %d unknown notifications\n", nm.Lost, nm.Unknown)
}
} else {
fmt.Fprintf(w, "NodeMonitor:\tDisabled\n")
}
var localNode *models.NodeElement
if sr.Cluster != nil {
if sr.Cluster.CiliumHealth != nil {
ch := sr.Cluster.CiliumHealth
fmt.Fprintf(w, "Cilium health daemon:\t%s\t%s\n", ch.State, ch.Msg)
}
for _, node := range sr.Cluster.Nodes {
if node.Name == sr.Cluster.Self {
localNode = node
} else {
continue
}
}
}
if sr.IPAM != nil {
var v4CIDR, v6CIDR, v4AllocRangeFmt, v6AllocRangeFmt string
if localNode != nil {
if v4AllocRange := localNode.PrimaryAddress.IPV4.AllocRange; v4AllocRange != "" {
v4AllocRangeFmt = fmt.Sprintf(" allocated from %s", v4AllocRange)
if nIPs := ip.CountIPsInCIDR(v4AllocRange); nIPs > 0 {
v4CIDR = fmt.Sprintf("/%d", nIPs)
}
}
if v6AllocRange := localNode.PrimaryAddress.IPV6.AllocRange; v6AllocRange != "" {
v6AllocRangeFmt = fmt.Sprintf(" allocated from %s", v6AllocRange)
if nIPs := ip.CountIPsInCIDR(v6AllocRange); nIPs > 0 {
v6CIDR = fmt.Sprintf("/%d", nIPs)
}
}
}
if v4AllocRangeFmt != "" {
fmt.Fprintf(w, "IPv4 address pool:\t%d%s%s\n", len(sr.IPAM.IPV4), v4CIDR, v4AllocRangeFmt)
}
if v6AllocRangeFmt != "" {
fmt.Fprintf(w, "IPv6 address pool:\t%d%s%s\n", len(sr.IPAM.IPV6), v6CIDR, v6AllocRangeFmt)
}
if allAddresses {
fmt.Fprintf(w, "Allocated addresses:\n")
out := []string{}
for ip, owner := range sr.IPAM.Allocations {
out = append(out, fmt.Sprintf(" %s (%s)", ip, owner))
}
sort.Strings(out)
for _, line := range out {
fmt.Fprintln(w, line)
}
}
}
if sr.Controllers != nil {
nFailing, out := 0, []string{" Name\tLast success\tLast error\tCount\tMessage\n"}
for _, ctrl := range sr.Controllers {
status := ctrl.Status
if status == nil {
continue
}
if status.ConsecutiveFailureCount > 0 {
nFailing++
} else if !allControllers {
continue
}
failSince := timeSince(time.Time(status.LastFailureTimestamp))
successSince := timeSince(time.Time(status.LastSuccessTimestamp))
err := "no error"
if status.LastFailureMsg != "" {
err = status.LastFailureMsg
}
out = append(out, fmt.Sprintf(" %s\t%s\t%s\t%d\t%s\t\n",
ctrl.Name, successSince, failSince, status.ConsecutiveFailureCount, err))
}
nOK := len(sr.Controllers) - nFailing
fmt.Fprintf(w, "Controller Status:\t%d/%d healthy\n", nOK, len(sr.Controllers))
if len(out) > 1 {
tab := tabwriter.NewWriter(w, 0, 0, 3, ' ', 0)
sort.Strings(out)
for _, s := range out {
fmt.Fprint(tab, s)
}
tab.Flush()
}
}
if sr.Proxy != nil {
fmt.Fprintf(w, "Proxy Status:\tOK, ip %s, port-range %s\n",
sr.Proxy.IP, sr.Proxy.PortRange)
} else {
fmt.Fprintf(w, "Proxy Status:\tNo managed proxy redirect\n")
}
} | [
"func",
"FormatStatusResponse",
"(",
"w",
"io",
".",
"Writer",
",",
"sr",
"*",
"models",
".",
"StatusResponse",
",",
"allAddresses",
",",
"allControllers",
",",
"allNodes",
",",
"allRedirects",
"bool",
")",
"{",
"if",
"sr",
".",
"Kvstore",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
",",
"sr",
".",
"Kvstore",
".",
"State",
",",
"sr",
".",
"Kvstore",
".",
"Msg",
")",
"\n",
"}",
"\n",
"if",
"sr",
".",
"ContainerRuntime",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
",",
"sr",
".",
"ContainerRuntime",
".",
"State",
",",
"sr",
".",
"ContainerRuntime",
".",
"Msg",
")",
"\n",
"}",
"\n",
"if",
"sr",
".",
"Kubernetes",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
",",
"sr",
".",
"Kubernetes",
".",
"State",
",",
"sr",
".",
"Kubernetes",
".",
"Msg",
")",
"\n",
"if",
"sr",
".",
"Kubernetes",
".",
"State",
"!=",
"models",
".",
"K8sStatusStateDisabled",
"{",
"sort",
".",
"Strings",
"(",
"sr",
".",
"Kubernetes",
".",
"K8sAPIVersions",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\\"",
"\\\"",
"\\n",
"\"",
",",
"strings",
".",
"Join",
"(",
"sr",
".",
"Kubernetes",
".",
"K8sAPIVersions",
",",
"\"",
"\\\"",
"\\\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"sr",
".",
"Cilium",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
",",
"sr",
".",
"Cilium",
".",
"State",
",",
"sr",
".",
"Cilium",
".",
"Msg",
")",
"\n",
"}",
"\n\n",
"if",
"sr",
".",
"Stale",
"!=",
"nil",
"{",
"sortedProbes",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"sr",
".",
"Stale",
")",
")",
"\n",
"for",
"probe",
":=",
"range",
"sr",
".",
"Stale",
"{",
"sortedProbes",
"=",
"append",
"(",
"sortedProbes",
",",
"probe",
")",
"\n",
"}",
"\n",
"sort",
".",
"Strings",
"(",
"sortedProbes",
")",
"\n\n",
"stalesStr",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"sr",
".",
"Stale",
")",
")",
"\n",
"for",
"_",
",",
"probe",
":=",
"range",
"sortedProbes",
"{",
"stalesStr",
"=",
"append",
"(",
"stalesStr",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"probe",
",",
"sr",
".",
"Stale",
"[",
"probe",
"]",
")",
")",
"\n",
"}",
"\n\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\n",
"\"",
",",
"strings",
".",
"Join",
"(",
"stalesStr",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n\n",
"if",
"nm",
":=",
"sr",
".",
"NodeMonitor",
";",
"nm",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\n",
"\"",
",",
"nm",
".",
"Cpus",
",",
"nm",
".",
"Npages",
",",
"nm",
".",
"Pagesize",
")",
"\n",
"if",
"nm",
".",
"Lost",
"!=",
"0",
"||",
"nm",
".",
"Unknown",
"!=",
"0",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\n",
"\"",
",",
"nm",
".",
"Lost",
",",
"nm",
".",
"Unknown",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\n",
"\"",
")",
"\n",
"}",
"\n\n",
"var",
"localNode",
"*",
"models",
".",
"NodeElement",
"\n",
"if",
"sr",
".",
"Cluster",
"!=",
"nil",
"{",
"if",
"sr",
".",
"Cluster",
".",
"CiliumHealth",
"!=",
"nil",
"{",
"ch",
":=",
"sr",
".",
"Cluster",
".",
"CiliumHealth",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
",",
"ch",
".",
"State",
",",
"ch",
".",
"Msg",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"node",
":=",
"range",
"sr",
".",
"Cluster",
".",
"Nodes",
"{",
"if",
"node",
".",
"Name",
"==",
"sr",
".",
"Cluster",
".",
"Self",
"{",
"localNode",
"=",
"node",
"\n",
"}",
"else",
"{",
"continue",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"sr",
".",
"IPAM",
"!=",
"nil",
"{",
"var",
"v4CIDR",
",",
"v6CIDR",
",",
"v4AllocRangeFmt",
",",
"v6AllocRangeFmt",
"string",
"\n",
"if",
"localNode",
"!=",
"nil",
"{",
"if",
"v4AllocRange",
":=",
"localNode",
".",
"PrimaryAddress",
".",
"IPV4",
".",
"AllocRange",
";",
"v4AllocRange",
"!=",
"\"",
"\"",
"{",
"v4AllocRangeFmt",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"v4AllocRange",
")",
"\n",
"if",
"nIPs",
":=",
"ip",
".",
"CountIPsInCIDR",
"(",
"v4AllocRange",
")",
";",
"nIPs",
">",
"0",
"{",
"v4CIDR",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"nIPs",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"v6AllocRange",
":=",
"localNode",
".",
"PrimaryAddress",
".",
"IPV6",
".",
"AllocRange",
";",
"v6AllocRange",
"!=",
"\"",
"\"",
"{",
"v6AllocRangeFmt",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"v6AllocRange",
")",
"\n",
"if",
"nIPs",
":=",
"ip",
".",
"CountIPsInCIDR",
"(",
"v6AllocRange",
")",
";",
"nIPs",
">",
"0",
"{",
"v6CIDR",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"nIPs",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"v4AllocRangeFmt",
"!=",
"\"",
"\"",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\n",
"\"",
",",
"len",
"(",
"sr",
".",
"IPAM",
".",
"IPV4",
")",
",",
"v4CIDR",
",",
"v4AllocRangeFmt",
")",
"\n",
"}",
"\n\n",
"if",
"v6AllocRangeFmt",
"!=",
"\"",
"\"",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\n",
"\"",
",",
"len",
"(",
"sr",
".",
"IPAM",
".",
"IPV6",
")",
",",
"v6CIDR",
",",
"v6AllocRangeFmt",
")",
"\n",
"}",
"\n\n",
"if",
"allAddresses",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"out",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"ip",
",",
"owner",
":=",
"range",
"sr",
".",
"IPAM",
".",
"Allocations",
"{",
"out",
"=",
"append",
"(",
"out",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ip",
",",
"owner",
")",
")",
"\n",
"}",
"\n",
"sort",
".",
"Strings",
"(",
"out",
")",
"\n",
"for",
"_",
",",
"line",
":=",
"range",
"out",
"{",
"fmt",
".",
"Fprintln",
"(",
"w",
",",
"line",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"sr",
".",
"Controllers",
"!=",
"nil",
"{",
"nFailing",
",",
"out",
":=",
"0",
",",
"[",
"]",
"string",
"{",
"\"",
"\\t",
"\\t",
"\\t",
"\\t",
"\\n",
"\"",
"}",
"\n",
"for",
"_",
",",
"ctrl",
":=",
"range",
"sr",
".",
"Controllers",
"{",
"status",
":=",
"ctrl",
".",
"Status",
"\n",
"if",
"status",
"==",
"nil",
"{",
"continue",
"\n",
"}",
"\n\n",
"if",
"status",
".",
"ConsecutiveFailureCount",
">",
"0",
"{",
"nFailing",
"++",
"\n",
"}",
"else",
"if",
"!",
"allControllers",
"{",
"continue",
"\n",
"}",
"\n\n",
"failSince",
":=",
"timeSince",
"(",
"time",
".",
"Time",
"(",
"status",
".",
"LastFailureTimestamp",
")",
")",
"\n",
"successSince",
":=",
"timeSince",
"(",
"time",
".",
"Time",
"(",
"status",
".",
"LastSuccessTimestamp",
")",
")",
"\n\n",
"err",
":=",
"\"",
"\"",
"\n",
"if",
"status",
".",
"LastFailureMsg",
"!=",
"\"",
"\"",
"{",
"err",
"=",
"status",
".",
"LastFailureMsg",
"\n",
"}",
"\n\n",
"out",
"=",
"append",
"(",
"out",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\n",
"\"",
",",
"ctrl",
".",
"Name",
",",
"successSince",
",",
"failSince",
",",
"status",
".",
"ConsecutiveFailureCount",
",",
"err",
")",
")",
"\n",
"}",
"\n\n",
"nOK",
":=",
"len",
"(",
"sr",
".",
"Controllers",
")",
"-",
"nFailing",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\n",
"\"",
",",
"nOK",
",",
"len",
"(",
"sr",
".",
"Controllers",
")",
")",
"\n",
"if",
"len",
"(",
"out",
")",
">",
"1",
"{",
"tab",
":=",
"tabwriter",
".",
"NewWriter",
"(",
"w",
",",
"0",
",",
"0",
",",
"3",
",",
"' '",
",",
"0",
")",
"\n",
"sort",
".",
"Strings",
"(",
"out",
")",
"\n",
"for",
"_",
",",
"s",
":=",
"range",
"out",
"{",
"fmt",
".",
"Fprint",
"(",
"tab",
",",
"s",
")",
"\n",
"}",
"\n",
"tab",
".",
"Flush",
"(",
")",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"if",
"sr",
".",
"Proxy",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\n",
"\"",
",",
"sr",
".",
"Proxy",
".",
"IP",
",",
"sr",
".",
"Proxy",
".",
"PortRange",
")",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\n",
"\"",
")",
"\n",
"}",
"\n",
"}"
] | // FormatStatusResponse writes a StatusResponse as a string to the writer.
//
// The parameters 'allAddresses', 'allControllers', 'allNodes', respectively,
// cause all details about that aspect of the status to be printed to the
// terminal. For each of these, if they are false then only a summary will be
// printed, with perhaps some detail if there are errors. | [
"FormatStatusResponse",
"writes",
"a",
"StatusResponse",
"as",
"a",
"string",
"to",
"the",
"writer",
".",
"The",
"parameters",
"allAddresses",
"allControllers",
"allNodes",
"respectively",
"cause",
"all",
"details",
"about",
"that",
"aspect",
"of",
"the",
"status",
"to",
"be",
"printed",
"to",
"the",
"terminal",
".",
"For",
"each",
"of",
"these",
"if",
"they",
"are",
"false",
"then",
"only",
"a",
"summary",
"will",
"be",
"printed",
"with",
"perhaps",
"some",
"detail",
"if",
"there",
"are",
"errors",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/client.go#L257-L399 |
163,863 | cilium/cilium | api/v1/models/endpoint_status.go | Validate | func (m *EndpointStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateControllers(formats); err != nil {
res = append(res, err)
}
if err := m.validateExternalIdentifiers(formats); err != nil {
res = append(res, err)
}
if err := m.validateHealth(formats); err != nil {
res = append(res, err)
}
if err := m.validateIdentity(formats); err != nil {
res = append(res, err)
}
if err := m.validateLabels(formats); err != nil {
res = append(res, err)
}
if err := m.validateLog(formats); err != nil {
res = append(res, err)
}
if err := m.validateNetworking(formats); err != nil {
res = append(res, err)
}
if err := m.validatePolicy(formats); err != nil {
res = append(res, err)
}
if err := m.validateRealized(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 *EndpointStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateControllers(formats); err != nil {
res = append(res, err)
}
if err := m.validateExternalIdentifiers(formats); err != nil {
res = append(res, err)
}
if err := m.validateHealth(formats); err != nil {
res = append(res, err)
}
if err := m.validateIdentity(formats); err != nil {
res = append(res, err)
}
if err := m.validateLabels(formats); err != nil {
res = append(res, err)
}
if err := m.validateLog(formats); err != nil {
res = append(res, err)
}
if err := m.validateNetworking(formats); err != nil {
res = append(res, err)
}
if err := m.validatePolicy(formats); err != nil {
res = append(res, err)
}
if err := m.validateRealized(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",
"*",
"EndpointStatus",
")",
"Validate",
"(",
"formats",
"strfmt",
".",
"Registry",
")",
"error",
"{",
"var",
"res",
"[",
"]",
"error",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateControllers",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateExternalIdentifiers",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateHealth",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateIdentity",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateLabels",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateLog",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateNetworking",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validatePolicy",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateRealized",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"m",
".",
"validateState",
"(",
"formats",
")",
";",
"err",
"!=",
"nil",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"res",
")",
">",
"0",
"{",
"return",
"errors",
".",
"CompositeValidationError",
"(",
"res",
"...",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Validate validates this endpoint status | [
"Validate",
"validates",
"this",
"endpoint",
"status"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/endpoint_status.go#L52-L99 |
163,864 | cilium/cilium | pkg/endpoint/metrics.go | SendMetrics | func (s *regenerationStatistics) SendMetrics() {
endpointPolicyStatus.Update(s.endpointID, s.policyStatus)
metrics.EndpointCountRegenerating.Dec()
if !s.success {
// Endpoint regeneration failed, increase on failed metrics
metrics.EndpointRegenerationCount.WithLabelValues(metrics.LabelValueOutcomeFail).Inc()
return
}
metrics.EndpointRegenerationCount.WithLabelValues(metrics.LabelValueOutcomeSuccess).Inc()
sendMetrics(s, metrics.EndpointRegenerationTimeStats)
} | go | func (s *regenerationStatistics) SendMetrics() {
endpointPolicyStatus.Update(s.endpointID, s.policyStatus)
metrics.EndpointCountRegenerating.Dec()
if !s.success {
// Endpoint regeneration failed, increase on failed metrics
metrics.EndpointRegenerationCount.WithLabelValues(metrics.LabelValueOutcomeFail).Inc()
return
}
metrics.EndpointRegenerationCount.WithLabelValues(metrics.LabelValueOutcomeSuccess).Inc()
sendMetrics(s, metrics.EndpointRegenerationTimeStats)
} | [
"func",
"(",
"s",
"*",
"regenerationStatistics",
")",
"SendMetrics",
"(",
")",
"{",
"endpointPolicyStatus",
".",
"Update",
"(",
"s",
".",
"endpointID",
",",
"s",
".",
"policyStatus",
")",
"\n",
"metrics",
".",
"EndpointCountRegenerating",
".",
"Dec",
"(",
")",
"\n\n",
"if",
"!",
"s",
".",
"success",
"{",
"// Endpoint regeneration failed, increase on failed metrics",
"metrics",
".",
"EndpointRegenerationCount",
".",
"WithLabelValues",
"(",
"metrics",
".",
"LabelValueOutcomeFail",
")",
".",
"Inc",
"(",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"metrics",
".",
"EndpointRegenerationCount",
".",
"WithLabelValues",
"(",
"metrics",
".",
"LabelValueOutcomeSuccess",
")",
".",
"Inc",
"(",
")",
"\n\n",
"sendMetrics",
"(",
"s",
",",
"metrics",
".",
"EndpointRegenerationTimeStats",
")",
"\n",
"}"
] | // SendMetrics sends the regeneration statistics for this endpoint to
// Prometheus. | [
"SendMetrics",
"sends",
"the",
"regeneration",
"statistics",
"for",
"this",
"endpoint",
"to",
"Prometheus",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/metrics.go#L72-L85 |
163,865 | cilium/cilium | pkg/endpoint/metrics.go | GetMap | func (s *regenerationStatistics) GetMap() map[string]*spanstat.SpanStat {
result := map[string]*spanstat.SpanStat{
"waitingForLock": &s.waitingForLock,
"waitingForCTClean": &s.waitingForCTClean,
"policyCalculation": &s.policyCalculation,
"proxyConfiguration": &s.proxyConfiguration,
"proxyPolicyCalculation": &s.proxyPolicyCalculation,
"proxyWaitForAck": &s.proxyWaitForAck,
"mapSync": &s.mapSync,
"prepareBuild": &s.prepareBuild,
logfields.BuildDuration: &s.totalTime,
}
for k, v := range s.datapathRealization.GetMap() {
result[k] = v
}
return result
} | go | func (s *regenerationStatistics) GetMap() map[string]*spanstat.SpanStat {
result := map[string]*spanstat.SpanStat{
"waitingForLock": &s.waitingForLock,
"waitingForCTClean": &s.waitingForCTClean,
"policyCalculation": &s.policyCalculation,
"proxyConfiguration": &s.proxyConfiguration,
"proxyPolicyCalculation": &s.proxyPolicyCalculation,
"proxyWaitForAck": &s.proxyWaitForAck,
"mapSync": &s.mapSync,
"prepareBuild": &s.prepareBuild,
logfields.BuildDuration: &s.totalTime,
}
for k, v := range s.datapathRealization.GetMap() {
result[k] = v
}
return result
} | [
"func",
"(",
"s",
"*",
"regenerationStatistics",
")",
"GetMap",
"(",
")",
"map",
"[",
"string",
"]",
"*",
"spanstat",
".",
"SpanStat",
"{",
"result",
":=",
"map",
"[",
"string",
"]",
"*",
"spanstat",
".",
"SpanStat",
"{",
"\"",
"\"",
":",
"&",
"s",
".",
"waitingForLock",
",",
"\"",
"\"",
":",
"&",
"s",
".",
"waitingForCTClean",
",",
"\"",
"\"",
":",
"&",
"s",
".",
"policyCalculation",
",",
"\"",
"\"",
":",
"&",
"s",
".",
"proxyConfiguration",
",",
"\"",
"\"",
":",
"&",
"s",
".",
"proxyPolicyCalculation",
",",
"\"",
"\"",
":",
"&",
"s",
".",
"proxyWaitForAck",
",",
"\"",
"\"",
":",
"&",
"s",
".",
"mapSync",
",",
"\"",
"\"",
":",
"&",
"s",
".",
"prepareBuild",
",",
"logfields",
".",
"BuildDuration",
":",
"&",
"s",
".",
"totalTime",
",",
"}",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"s",
".",
"datapathRealization",
".",
"GetMap",
"(",
")",
"{",
"result",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"return",
"result",
"\n",
"}"
] | // GetMap returns a map which key is the stat name and the value is the stat | [
"GetMap",
"returns",
"a",
"map",
"which",
"key",
"is",
"the",
"stat",
"name",
"and",
"the",
"value",
"is",
"the",
"stat"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/metrics.go#L88-L104 |
163,866 | cilium/cilium | pkg/endpoint/metrics.go | Update | func (epPolicyMaps *endpointPolicyStatusMap) Update(endpointID uint16, policyStatus models.EndpointPolicyEnabled) {
epPolicyMaps.mutex.Lock()
epPolicyMaps.m[endpointID] = policyStatus
epPolicyMaps.mutex.Unlock()
endpointPolicyStatus.UpdateMetrics()
} | go | func (epPolicyMaps *endpointPolicyStatusMap) Update(endpointID uint16, policyStatus models.EndpointPolicyEnabled) {
epPolicyMaps.mutex.Lock()
epPolicyMaps.m[endpointID] = policyStatus
epPolicyMaps.mutex.Unlock()
endpointPolicyStatus.UpdateMetrics()
} | [
"func",
"(",
"epPolicyMaps",
"*",
"endpointPolicyStatusMap",
")",
"Update",
"(",
"endpointID",
"uint16",
",",
"policyStatus",
"models",
".",
"EndpointPolicyEnabled",
")",
"{",
"epPolicyMaps",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"epPolicyMaps",
".",
"m",
"[",
"endpointID",
"]",
"=",
"policyStatus",
"\n",
"epPolicyMaps",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"endpointPolicyStatus",
".",
"UpdateMetrics",
"(",
")",
"\n",
"}"
] | // Update adds or updates a new endpoint to the map and update the metrics
// related | [
"Update",
"adds",
"or",
"updates",
"a",
"new",
"endpoint",
"to",
"the",
"map",
"and",
"update",
"the",
"metrics",
"related"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/metrics.go#L142-L147 |
163,867 | cilium/cilium | pkg/endpoint/metrics.go | Remove | func (epPolicyMaps *endpointPolicyStatusMap) Remove(endpointID uint16) {
epPolicyMaps.mutex.Lock()
delete(epPolicyMaps.m, endpointID)
epPolicyMaps.mutex.Unlock()
epPolicyMaps.UpdateMetrics()
} | go | func (epPolicyMaps *endpointPolicyStatusMap) Remove(endpointID uint16) {
epPolicyMaps.mutex.Lock()
delete(epPolicyMaps.m, endpointID)
epPolicyMaps.mutex.Unlock()
epPolicyMaps.UpdateMetrics()
} | [
"func",
"(",
"epPolicyMaps",
"*",
"endpointPolicyStatusMap",
")",
"Remove",
"(",
"endpointID",
"uint16",
")",
"{",
"epPolicyMaps",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"delete",
"(",
"epPolicyMaps",
".",
"m",
",",
"endpointID",
")",
"\n",
"epPolicyMaps",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"epPolicyMaps",
".",
"UpdateMetrics",
"(",
")",
"\n",
"}"
] | // Remove deletes the given endpoint from the map and update the metrics | [
"Remove",
"deletes",
"the",
"given",
"endpoint",
"from",
"the",
"map",
"and",
"update",
"the",
"metrics"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/metrics.go#L150-L155 |
163,868 | cilium/cilium | pkg/endpoint/metrics.go | UpdateMetrics | func (epPolicyMaps *endpointPolicyStatusMap) UpdateMetrics() {
policyStatus := map[models.EndpointPolicyEnabled]float64{
models.EndpointPolicyEnabledNone: 0,
models.EndpointPolicyEnabledEgress: 0,
models.EndpointPolicyEnabledIngress: 0,
models.EndpointPolicyEnabledBoth: 0,
}
epPolicyMaps.mutex.Lock()
for _, value := range epPolicyMaps.m {
policyStatus[value]++
}
epPolicyMaps.mutex.Unlock()
for k, v := range policyStatus {
metrics.PolicyEndpointStatus.WithLabelValues(string(k)).Set(v)
}
} | go | func (epPolicyMaps *endpointPolicyStatusMap) UpdateMetrics() {
policyStatus := map[models.EndpointPolicyEnabled]float64{
models.EndpointPolicyEnabledNone: 0,
models.EndpointPolicyEnabledEgress: 0,
models.EndpointPolicyEnabledIngress: 0,
models.EndpointPolicyEnabledBoth: 0,
}
epPolicyMaps.mutex.Lock()
for _, value := range epPolicyMaps.m {
policyStatus[value]++
}
epPolicyMaps.mutex.Unlock()
for k, v := range policyStatus {
metrics.PolicyEndpointStatus.WithLabelValues(string(k)).Set(v)
}
} | [
"func",
"(",
"epPolicyMaps",
"*",
"endpointPolicyStatusMap",
")",
"UpdateMetrics",
"(",
")",
"{",
"policyStatus",
":=",
"map",
"[",
"models",
".",
"EndpointPolicyEnabled",
"]",
"float64",
"{",
"models",
".",
"EndpointPolicyEnabledNone",
":",
"0",
",",
"models",
".",
"EndpointPolicyEnabledEgress",
":",
"0",
",",
"models",
".",
"EndpointPolicyEnabledIngress",
":",
"0",
",",
"models",
".",
"EndpointPolicyEnabledBoth",
":",
"0",
",",
"}",
"\n\n",
"epPolicyMaps",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"for",
"_",
",",
"value",
":=",
"range",
"epPolicyMaps",
".",
"m",
"{",
"policyStatus",
"[",
"value",
"]",
"++",
"\n",
"}",
"\n",
"epPolicyMaps",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"k",
",",
"v",
":=",
"range",
"policyStatus",
"{",
"metrics",
".",
"PolicyEndpointStatus",
".",
"WithLabelValues",
"(",
"string",
"(",
"k",
")",
")",
".",
"Set",
"(",
"v",
")",
"\n",
"}",
"\n",
"}"
] | // UpdateMetrics update the policy enforcement metrics statistics for the endpoints. | [
"UpdateMetrics",
"update",
"the",
"policy",
"enforcement",
"metrics",
"statistics",
"for",
"the",
"endpoints",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/metrics.go#L158-L175 |
163,869 | cilium/cilium | pkg/envoy/xds/watcher.go | NewResourceWatcher | func NewResourceWatcher(typeURL string, resourceSet ResourceSource, resourceAccessTimeout time.Duration) *ResourceWatcher {
w := &ResourceWatcher{
version: 1,
typeURL: typeURL,
resourceSet: resourceSet,
resourceAccessTimeout: resourceAccessTimeout,
}
w.versionCond = sync.NewCond(&w.versionLocker)
return w
} | go | func NewResourceWatcher(typeURL string, resourceSet ResourceSource, resourceAccessTimeout time.Duration) *ResourceWatcher {
w := &ResourceWatcher{
version: 1,
typeURL: typeURL,
resourceSet: resourceSet,
resourceAccessTimeout: resourceAccessTimeout,
}
w.versionCond = sync.NewCond(&w.versionLocker)
return w
} | [
"func",
"NewResourceWatcher",
"(",
"typeURL",
"string",
",",
"resourceSet",
"ResourceSource",
",",
"resourceAccessTimeout",
"time",
".",
"Duration",
")",
"*",
"ResourceWatcher",
"{",
"w",
":=",
"&",
"ResourceWatcher",
"{",
"version",
":",
"1",
",",
"typeURL",
":",
"typeURL",
",",
"resourceSet",
":",
"resourceSet",
",",
"resourceAccessTimeout",
":",
"resourceAccessTimeout",
",",
"}",
"\n",
"w",
".",
"versionCond",
"=",
"sync",
".",
"NewCond",
"(",
"&",
"w",
".",
"versionLocker",
")",
"\n",
"return",
"w",
"\n",
"}"
] | // NewResourceWatcher creates a new ResourceWatcher backed by the given
// resource set. | [
"NewResourceWatcher",
"creates",
"a",
"new",
"ResourceWatcher",
"backed",
"by",
"the",
"given",
"resource",
"set",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/xds/watcher.go#L61-L70 |
163,870 | cilium/cilium | pkg/envoy/xds/watcher.go | WatchResources | func (w *ResourceWatcher) WatchResources(ctx context.Context, typeURL string, lastVersion uint64, node *envoy_api_v2_core.Node,
resourceNames []string, out chan<- *VersionedResources) {
defer close(out)
watchLog := log.WithFields(logrus.Fields{
logfields.XDSVersionInfo: lastVersion,
logfields.XDSClientNode: node,
logfields.XDSTypeURL: typeURL,
})
var res *VersionedResources
var waitVersion uint64
var waitForVersion bool
if lastVersion != 0 {
waitForVersion = true
waitVersion = lastVersion
}
for ctx.Err() == nil && res == nil {
w.versionLocker.Lock()
// If the client ACKed a version that we have never sent back, this
// indicates that this server restarted but the client survived and had
// received a higher version number from the previous server instance.
// Bump the resource set's version number to match the client's and
// send a response immediately.
if waitForVersion && w.version < waitVersion {
w.versionLocker.Unlock()
// Calling EnsureVersion will increase the version of the resource
// set, which in turn will callback w.HandleNewResourceVersion with
// that new version number. In order for that callback to not
// deadlock, temporarily unlock w.versionLocker.
// The w.HandleNewResourceVersion callback will update w.version to
// the new resource set version.
w.resourceSet.EnsureVersion(typeURL, waitVersion+1)
w.versionLocker.Lock()
}
// Re-check w.version, since it may have been modified by calling
// EnsureVersion above.
for ctx.Err() == nil && waitForVersion && w.version <= waitVersion {
watchLog.Debugf("current resource version is %d, waiting for it to become > %d", w.version, waitVersion)
w.versionCond.Wait()
}
// In case we need to loop again, wait for any version more recent than
// the current one.
waitForVersion = true
waitVersion = w.version
w.versionLocker.Unlock()
if ctx.Err() != nil {
break
}
subCtx, cancel := context.WithTimeout(ctx, w.resourceAccessTimeout)
var err error
watchLog.Debugf("getting %d resources from set", len(resourceNames))
res, err = w.resourceSet.GetResources(subCtx, typeURL, lastVersion, node, resourceNames)
cancel()
if err != nil {
watchLog.WithError(err).Errorf("failed to query resources named: %v; terminating resource watch", resourceNames)
return
}
}
if res != nil {
// Resources have changed since the last version returned to the
// client. Send out the new version.
select {
case <-ctx.Done():
case out <- res:
return
}
}
err := ctx.Err()
if err != nil {
switch err {
case context.Canceled:
watchLog.Debug("context canceled, terminating resource watch")
default:
watchLog.WithError(err).Error("context error, terminating resource watch")
}
}
} | go | func (w *ResourceWatcher) WatchResources(ctx context.Context, typeURL string, lastVersion uint64, node *envoy_api_v2_core.Node,
resourceNames []string, out chan<- *VersionedResources) {
defer close(out)
watchLog := log.WithFields(logrus.Fields{
logfields.XDSVersionInfo: lastVersion,
logfields.XDSClientNode: node,
logfields.XDSTypeURL: typeURL,
})
var res *VersionedResources
var waitVersion uint64
var waitForVersion bool
if lastVersion != 0 {
waitForVersion = true
waitVersion = lastVersion
}
for ctx.Err() == nil && res == nil {
w.versionLocker.Lock()
// If the client ACKed a version that we have never sent back, this
// indicates that this server restarted but the client survived and had
// received a higher version number from the previous server instance.
// Bump the resource set's version number to match the client's and
// send a response immediately.
if waitForVersion && w.version < waitVersion {
w.versionLocker.Unlock()
// Calling EnsureVersion will increase the version of the resource
// set, which in turn will callback w.HandleNewResourceVersion with
// that new version number. In order for that callback to not
// deadlock, temporarily unlock w.versionLocker.
// The w.HandleNewResourceVersion callback will update w.version to
// the new resource set version.
w.resourceSet.EnsureVersion(typeURL, waitVersion+1)
w.versionLocker.Lock()
}
// Re-check w.version, since it may have been modified by calling
// EnsureVersion above.
for ctx.Err() == nil && waitForVersion && w.version <= waitVersion {
watchLog.Debugf("current resource version is %d, waiting for it to become > %d", w.version, waitVersion)
w.versionCond.Wait()
}
// In case we need to loop again, wait for any version more recent than
// the current one.
waitForVersion = true
waitVersion = w.version
w.versionLocker.Unlock()
if ctx.Err() != nil {
break
}
subCtx, cancel := context.WithTimeout(ctx, w.resourceAccessTimeout)
var err error
watchLog.Debugf("getting %d resources from set", len(resourceNames))
res, err = w.resourceSet.GetResources(subCtx, typeURL, lastVersion, node, resourceNames)
cancel()
if err != nil {
watchLog.WithError(err).Errorf("failed to query resources named: %v; terminating resource watch", resourceNames)
return
}
}
if res != nil {
// Resources have changed since the last version returned to the
// client. Send out the new version.
select {
case <-ctx.Done():
case out <- res:
return
}
}
err := ctx.Err()
if err != nil {
switch err {
case context.Canceled:
watchLog.Debug("context canceled, terminating resource watch")
default:
watchLog.WithError(err).Error("context error, terminating resource watch")
}
}
} | [
"func",
"(",
"w",
"*",
"ResourceWatcher",
")",
"WatchResources",
"(",
"ctx",
"context",
".",
"Context",
",",
"typeURL",
"string",
",",
"lastVersion",
"uint64",
",",
"node",
"*",
"envoy_api_v2_core",
".",
"Node",
",",
"resourceNames",
"[",
"]",
"string",
",",
"out",
"chan",
"<-",
"*",
"VersionedResources",
")",
"{",
"defer",
"close",
"(",
"out",
")",
"\n\n",
"watchLog",
":=",
"log",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"logfields",
".",
"XDSVersionInfo",
":",
"lastVersion",
",",
"logfields",
".",
"XDSClientNode",
":",
"node",
",",
"logfields",
".",
"XDSTypeURL",
":",
"typeURL",
",",
"}",
")",
"\n\n",
"var",
"res",
"*",
"VersionedResources",
"\n\n",
"var",
"waitVersion",
"uint64",
"\n",
"var",
"waitForVersion",
"bool",
"\n",
"if",
"lastVersion",
"!=",
"0",
"{",
"waitForVersion",
"=",
"true",
"\n",
"waitVersion",
"=",
"lastVersion",
"\n",
"}",
"\n\n",
"for",
"ctx",
".",
"Err",
"(",
")",
"==",
"nil",
"&&",
"res",
"==",
"nil",
"{",
"w",
".",
"versionLocker",
".",
"Lock",
"(",
")",
"\n",
"// If the client ACKed a version that we have never sent back, this",
"// indicates that this server restarted but the client survived and had",
"// received a higher version number from the previous server instance.",
"// Bump the resource set's version number to match the client's and",
"// send a response immediately.",
"if",
"waitForVersion",
"&&",
"w",
".",
"version",
"<",
"waitVersion",
"{",
"w",
".",
"versionLocker",
".",
"Unlock",
"(",
")",
"\n",
"// Calling EnsureVersion will increase the version of the resource",
"// set, which in turn will callback w.HandleNewResourceVersion with",
"// that new version number. In order for that callback to not",
"// deadlock, temporarily unlock w.versionLocker.",
"// The w.HandleNewResourceVersion callback will update w.version to",
"// the new resource set version.",
"w",
".",
"resourceSet",
".",
"EnsureVersion",
"(",
"typeURL",
",",
"waitVersion",
"+",
"1",
")",
"\n",
"w",
".",
"versionLocker",
".",
"Lock",
"(",
")",
"\n",
"}",
"\n\n",
"// Re-check w.version, since it may have been modified by calling",
"// EnsureVersion above.",
"for",
"ctx",
".",
"Err",
"(",
")",
"==",
"nil",
"&&",
"waitForVersion",
"&&",
"w",
".",
"version",
"<=",
"waitVersion",
"{",
"watchLog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"w",
".",
"version",
",",
"waitVersion",
")",
"\n",
"w",
".",
"versionCond",
".",
"Wait",
"(",
")",
"\n",
"}",
"\n",
"// In case we need to loop again, wait for any version more recent than",
"// the current one.",
"waitForVersion",
"=",
"true",
"\n",
"waitVersion",
"=",
"w",
".",
"version",
"\n",
"w",
".",
"versionLocker",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"ctx",
".",
"Err",
"(",
")",
"!=",
"nil",
"{",
"break",
"\n",
"}",
"\n\n",
"subCtx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"ctx",
",",
"w",
".",
"resourceAccessTimeout",
")",
"\n",
"var",
"err",
"error",
"\n",
"watchLog",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"len",
"(",
"resourceNames",
")",
")",
"\n",
"res",
",",
"err",
"=",
"w",
".",
"resourceSet",
".",
"GetResources",
"(",
"subCtx",
",",
"typeURL",
",",
"lastVersion",
",",
"node",
",",
"resourceNames",
")",
"\n",
"cancel",
"(",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"watchLog",
".",
"WithError",
"(",
"err",
")",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"resourceNames",
")",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"res",
"!=",
"nil",
"{",
"// Resources have changed since the last version returned to the",
"// client. Send out the new version.",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"case",
"out",
"<-",
"res",
":",
"return",
"\n",
"}",
"\n",
"}",
"\n\n",
"err",
":=",
"ctx",
".",
"Err",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"switch",
"err",
"{",
"case",
"context",
".",
"Canceled",
":",
"watchLog",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"default",
":",
"watchLog",
".",
"WithError",
"(",
"err",
")",
".",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // WatchResources watches for new versions of specific resources and sends them
// into the given out channel.
//
// A call to this method blocks until a version greater than lastVersion is
// available. Therefore, every call must be done in a separate goroutine.
// A watch can be canceled by canceling the given context.
//
// lastVersion is the last version successfully applied by the
// client; nil if this is the first request for resources.
// This method call must always close the out channel. | [
"WatchResources",
"watches",
"for",
"new",
"versions",
"of",
"specific",
"resources",
"and",
"sends",
"them",
"into",
"the",
"given",
"out",
"channel",
".",
"A",
"call",
"to",
"this",
"method",
"blocks",
"until",
"a",
"version",
"greater",
"than",
"lastVersion",
"is",
"available",
".",
"Therefore",
"every",
"call",
"must",
"be",
"done",
"in",
"a",
"separate",
"goroutine",
".",
"A",
"watch",
"can",
"be",
"canceled",
"by",
"canceling",
"the",
"given",
"context",
".",
"lastVersion",
"is",
"the",
"last",
"version",
"successfully",
"applied",
"by",
"the",
"client",
";",
"nil",
"if",
"this",
"is",
"the",
"first",
"request",
"for",
"resources",
".",
"This",
"method",
"call",
"must",
"always",
"close",
"the",
"out",
"channel",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/xds/watcher.go#L102-L187 |
163,871 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go | DeepCopy | func (in *CiliumEndpoint) DeepCopy() *CiliumEndpoint {
if in == nil {
return nil
}
out := new(CiliumEndpoint)
in.DeepCopyInto(out)
return out
} | go | func (in *CiliumEndpoint) DeepCopy() *CiliumEndpoint {
if in == nil {
return nil
}
out := new(CiliumEndpoint)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"CiliumEndpoint",
")",
"DeepCopy",
"(",
")",
"*",
"CiliumEndpoint",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"CiliumEndpoint",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CiliumEndpoint. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"CiliumEndpoint",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go#L36-L43 |
163,872 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go | DeepCopy | func (in *CiliumEndpointList) DeepCopy() *CiliumEndpointList {
if in == nil {
return nil
}
out := new(CiliumEndpointList)
in.DeepCopyInto(out)
return out
} | go | func (in *CiliumEndpointList) DeepCopy() *CiliumEndpointList {
if in == nil {
return nil
}
out := new(CiliumEndpointList)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"CiliumEndpointList",
")",
"DeepCopy",
"(",
")",
"*",
"CiliumEndpointList",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"CiliumEndpointList",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CiliumEndpointList. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"CiliumEndpointList",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go#L69-L76 |
163,873 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go | DeepCopy | func (in *CiliumNetworkPolicy) DeepCopy() *CiliumNetworkPolicy {
if in == nil {
return nil
}
out := new(CiliumNetworkPolicy)
in.DeepCopyInto(out)
return out
} | go | func (in *CiliumNetworkPolicy) DeepCopy() *CiliumNetworkPolicy {
if in == nil {
return nil
}
out := new(CiliumNetworkPolicy)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"CiliumNetworkPolicy",
")",
"DeepCopy",
"(",
")",
"*",
"CiliumNetworkPolicy",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"CiliumNetworkPolicy",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CiliumNetworkPolicy. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"CiliumNetworkPolicy",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go#L112-L119 |
163,874 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go | DeepCopy | func (in *CiliumNetworkPolicyList) DeepCopy() *CiliumNetworkPolicyList {
if in == nil {
return nil
}
out := new(CiliumNetworkPolicyList)
in.DeepCopyInto(out)
return out
} | go | func (in *CiliumNetworkPolicyList) DeepCopy() *CiliumNetworkPolicyList {
if in == nil {
return nil
}
out := new(CiliumNetworkPolicyList)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"CiliumNetworkPolicyList",
")",
"DeepCopy",
"(",
")",
"*",
"CiliumNetworkPolicyList",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"CiliumNetworkPolicyList",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CiliumNetworkPolicyList. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"CiliumNetworkPolicyList",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go#L145-L152 |
163,875 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go | DeepCopy | func (in *CiliumNetworkPolicyNodeStatus) DeepCopy() *CiliumNetworkPolicyNodeStatus {
if in == nil {
return nil
}
out := new(CiliumNetworkPolicyNodeStatus)
in.DeepCopyInto(out)
return out
} | go | func (in *CiliumNetworkPolicyNodeStatus) DeepCopy() *CiliumNetworkPolicyNodeStatus {
if in == nil {
return nil
}
out := new(CiliumNetworkPolicyNodeStatus)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"CiliumNetworkPolicyNodeStatus",
")",
"DeepCopy",
"(",
")",
"*",
"CiliumNetworkPolicyNodeStatus",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"CiliumNetworkPolicyNodeStatus",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CiliumNetworkPolicyNodeStatus. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"CiliumNetworkPolicyNodeStatus",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go#L177-L184 |
163,876 | cilium/cilium | pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go | DeepCopy | func (in *CiliumNetworkPolicyStatus) DeepCopy() *CiliumNetworkPolicyStatus {
if in == nil {
return nil
}
out := new(CiliumNetworkPolicyStatus)
in.DeepCopyInto(out)
return out
} | go | func (in *CiliumNetworkPolicyStatus) DeepCopy() *CiliumNetworkPolicyStatus {
if in == nil {
return nil
}
out := new(CiliumNetworkPolicyStatus)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"CiliumNetworkPolicyStatus",
")",
"DeepCopy",
"(",
")",
"*",
"CiliumNetworkPolicyStatus",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"CiliumNetworkPolicyStatus",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CiliumNetworkPolicyStatus. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"CiliumNetworkPolicyStatus",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/apis/cilium.io/v2/zz_generated.deepcopy.go#L207-L214 |
163,877 | cilium/cilium | pkg/monitor/types.go | GetAllTypes | func GetAllTypes() []string {
types := make([]string, len(monitorAPI.MessageTypeNames))
i := 0
for k := range monitorAPI.MessageTypeNames {
types[i] = k
i++
}
sort.Strings(types)
return types
} | go | func GetAllTypes() []string {
types := make([]string, len(monitorAPI.MessageTypeNames))
i := 0
for k := range monitorAPI.MessageTypeNames {
types[i] = k
i++
}
sort.Strings(types)
return types
} | [
"func",
"GetAllTypes",
"(",
")",
"[",
"]",
"string",
"{",
"types",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"monitorAPI",
".",
"MessageTypeNames",
")",
")",
"\n",
"i",
":=",
"0",
"\n",
"for",
"k",
":=",
"range",
"monitorAPI",
".",
"MessageTypeNames",
"{",
"types",
"[",
"i",
"]",
"=",
"k",
"\n",
"i",
"++",
"\n",
"}",
"\n",
"sort",
".",
"Strings",
"(",
"types",
")",
"\n",
"return",
"types",
"\n",
"}"
] | // GetAllTypes returns a slice of all known message types, sorted | [
"GetAllTypes",
"returns",
"a",
"slice",
"of",
"all",
"known",
"message",
"types",
"sorted"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/types.go#L28-L37 |
163,878 | cilium/cilium | pkg/netns/netns.go | RemoveIfFromNetNSIfExists | func RemoveIfFromNetNSIfExists(netNS ns.NetNS, ifName string) error {
return netNS.Do(func(_ ns.NetNS) error {
l, err := netlink.LinkByName(ifName)
if err != nil {
if strings.Contains(err.Error(), "Link not found") {
return nil
}
return err
}
return netlink.LinkDel(l)
})
} | go | func RemoveIfFromNetNSIfExists(netNS ns.NetNS, ifName string) error {
return netNS.Do(func(_ ns.NetNS) error {
l, err := netlink.LinkByName(ifName)
if err != nil {
if strings.Contains(err.Error(), "Link not found") {
return nil
}
return err
}
return netlink.LinkDel(l)
})
} | [
"func",
"RemoveIfFromNetNSIfExists",
"(",
"netNS",
"ns",
".",
"NetNS",
",",
"ifName",
"string",
")",
"error",
"{",
"return",
"netNS",
".",
"Do",
"(",
"func",
"(",
"_",
"ns",
".",
"NetNS",
")",
"error",
"{",
"l",
",",
"err",
":=",
"netlink",
".",
"LinkByName",
"(",
"ifName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"strings",
".",
"Contains",
"(",
"err",
".",
"Error",
"(",
")",
",",
"\"",
"\"",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"return",
"netlink",
".",
"LinkDel",
"(",
"l",
")",
"\n",
"}",
")",
"\n",
"}"
] | // RemoveIfFromNetNSIfExists removes the given interface from the given
// network namespace.
//
// If the interface does not exist, no error will be returned. | [
"RemoveIfFromNetNSIfExists",
"removes",
"the",
"given",
"interface",
"from",
"the",
"given",
"network",
"namespace",
".",
"If",
"the",
"interface",
"does",
"not",
"exist",
"no",
"error",
"will",
"be",
"returned",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/netns/netns.go#L32-L43 |
163,879 | cilium/cilium | pkg/netns/netns.go | ListNamedNetNSWithPrefix | func ListNamedNetNSWithPrefix(prefix string) ([]string, error) {
entries, err := ioutil.ReadDir(netNSRootDir())
if err != nil {
return nil, err
}
ns := make([]string, 0)
for _, e := range entries {
if !e.IsDir() && strings.HasPrefix(e.Name(), prefix) {
ns = append(ns, e.Name())
}
}
return ns, nil
} | go | func ListNamedNetNSWithPrefix(prefix string) ([]string, error) {
entries, err := ioutil.ReadDir(netNSRootDir())
if err != nil {
return nil, err
}
ns := make([]string, 0)
for _, e := range entries {
if !e.IsDir() && strings.HasPrefix(e.Name(), prefix) {
ns = append(ns, e.Name())
}
}
return ns, nil
} | [
"func",
"ListNamedNetNSWithPrefix",
"(",
"prefix",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"entries",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"netNSRootDir",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"ns",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
"for",
"_",
",",
"e",
":=",
"range",
"entries",
"{",
"if",
"!",
"e",
".",
"IsDir",
"(",
")",
"&&",
"strings",
".",
"HasPrefix",
"(",
"e",
".",
"Name",
"(",
")",
",",
"prefix",
")",
"{",
"ns",
"=",
"append",
"(",
"ns",
",",
"e",
".",
"Name",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"ns",
",",
"nil",
"\n",
"}"
] | // ListNamedNetNSWithPrefix returns list of named network namespaces which name
// starts with the given prefix. | [
"ListNamedNetNSWithPrefix",
"returns",
"list",
"of",
"named",
"network",
"namespaces",
"which",
"name",
"starts",
"with",
"the",
"given",
"prefix",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/netns/netns.go#L84-L98 |
163,880 | cilium/cilium | pkg/kvstore/config.go | setOpts | func setOpts(opts map[string]string, supportedOpts backendOptions) error {
errors := 0
for key, val := range opts {
opt, ok := supportedOpts[key]
if !ok {
errors++
log.WithField(logfields.Key, key).Error("unknown kvstore configuration key")
continue
}
if opt.validate != nil {
if err := opt.validate(val); err != nil {
log.Errorf("invalid value for key %s: %s", key, err)
errors++
}
}
}
// if errors have occurred, print the supported configuration keys to
// the log
if errors > 0 {
log.Error("Supported configuration keys:")
for key, val := range supportedOpts {
log.Errorf(" %-12s %s", key, val.description)
}
return fmt.Errorf("invalid kvstore configuration, see log for details")
}
// modify the configuration atomically after verification
for key, val := range opts {
supportedOpts[key].value = val
}
return nil
} | go | func setOpts(opts map[string]string, supportedOpts backendOptions) error {
errors := 0
for key, val := range opts {
opt, ok := supportedOpts[key]
if !ok {
errors++
log.WithField(logfields.Key, key).Error("unknown kvstore configuration key")
continue
}
if opt.validate != nil {
if err := opt.validate(val); err != nil {
log.Errorf("invalid value for key %s: %s", key, err)
errors++
}
}
}
// if errors have occurred, print the supported configuration keys to
// the log
if errors > 0 {
log.Error("Supported configuration keys:")
for key, val := range supportedOpts {
log.Errorf(" %-12s %s", key, val.description)
}
return fmt.Errorf("invalid kvstore configuration, see log for details")
}
// modify the configuration atomically after verification
for key, val := range opts {
supportedOpts[key].value = val
}
return nil
} | [
"func",
"setOpts",
"(",
"opts",
"map",
"[",
"string",
"]",
"string",
",",
"supportedOpts",
"backendOptions",
")",
"error",
"{",
"errors",
":=",
"0",
"\n\n",
"for",
"key",
",",
"val",
":=",
"range",
"opts",
"{",
"opt",
",",
"ok",
":=",
"supportedOpts",
"[",
"key",
"]",
"\n",
"if",
"!",
"ok",
"{",
"errors",
"++",
"\n",
"log",
".",
"WithField",
"(",
"logfields",
".",
"Key",
",",
"key",
")",
".",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"if",
"opt",
".",
"validate",
"!=",
"nil",
"{",
"if",
"err",
":=",
"opt",
".",
"validate",
"(",
"val",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"key",
",",
"err",
")",
"\n",
"errors",
"++",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n\n",
"// if errors have occurred, print the supported configuration keys to",
"// the log",
"if",
"errors",
">",
"0",
"{",
"log",
".",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"for",
"key",
",",
"val",
":=",
"range",
"supportedOpts",
"{",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"key",
",",
"val",
".",
"description",
")",
"\n",
"}",
"\n\n",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// modify the configuration atomically after verification",
"for",
"key",
",",
"val",
":=",
"range",
"opts",
"{",
"supportedOpts",
"[",
"key",
"]",
".",
"value",
"=",
"val",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // setOpts validates the specified options against the selected backend and
// then modifies the configuration | [
"setOpts",
"validates",
"the",
"specified",
"options",
"against",
"the",
"selected",
"backend",
"and",
"then",
"modifies",
"the",
"configuration"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/config.go#L31-L68 |
163,881 | cilium/cilium | pkg/kvstore/config.go | Setup | func Setup(selectedBackend string, opts map[string]string, goOpts *ExtraOptions) error {
var err error
setupOnce.Do(func() {
err = setup(selectedBackend, opts, goOpts)
})
return err
} | go | func Setup(selectedBackend string, opts map[string]string, goOpts *ExtraOptions) error {
var err error
setupOnce.Do(func() {
err = setup(selectedBackend, opts, goOpts)
})
return err
} | [
"func",
"Setup",
"(",
"selectedBackend",
"string",
",",
"opts",
"map",
"[",
"string",
"]",
"string",
",",
"goOpts",
"*",
"ExtraOptions",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"setupOnce",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"err",
"=",
"setup",
"(",
"selectedBackend",
",",
"opts",
",",
"goOpts",
")",
"\n",
"}",
")",
"\n\n",
"return",
"err",
"\n",
"}"
] | // Setup sets up the key-value store specified in kvStore and configures it
// with the options provided in opts | [
"Setup",
"sets",
"up",
"the",
"key",
"-",
"value",
"store",
"specified",
"in",
"kvStore",
"and",
"configures",
"it",
"with",
"the",
"options",
"provided",
"in",
"opts"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/kvstore/config.go#L105-L113 |
163,882 | cilium/cilium | pkg/maps/lbmap/ipv6.go | ToHost | func (k *Service6Key) ToHost() ServiceKey {
n := *k
n.Port = byteorder.NetworkToHost(n.Port).(uint16)
return &n
} | go | func (k *Service6Key) ToHost() ServiceKey {
n := *k
n.Port = byteorder.NetworkToHost(n.Port).(uint16)
return &n
} | [
"func",
"(",
"k",
"*",
"Service6Key",
")",
"ToHost",
"(",
")",
"ServiceKey",
"{",
"n",
":=",
"*",
"k",
"\n",
"n",
".",
"Port",
"=",
"byteorder",
".",
"NetworkToHost",
"(",
"n",
".",
"Port",
")",
".",
"(",
"uint16",
")",
"\n",
"return",
"&",
"n",
"\n",
"}"
] | // ToHost converts Service6Key to host byte order. | [
"ToHost",
"converts",
"Service6Key",
"to",
"host",
"byte",
"order",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/ipv6.go#L165-L169 |
163,883 | cilium/cilium | pkg/maps/lbmap/ipv6.go | ToNetwork | func (s *Service6Value) ToNetwork() ServiceValue {
n := *s
n.RevNat = byteorder.HostToNetwork(n.RevNat).(uint16)
n.Port = byteorder.HostToNetwork(n.Port).(uint16)
n.Weight = byteorder.HostToNetwork(n.Weight).(uint16)
return &n
} | go | func (s *Service6Value) ToNetwork() ServiceValue {
n := *s
n.RevNat = byteorder.HostToNetwork(n.RevNat).(uint16)
n.Port = byteorder.HostToNetwork(n.Port).(uint16)
n.Weight = byteorder.HostToNetwork(n.Weight).(uint16)
return &n
} | [
"func",
"(",
"s",
"*",
"Service6Value",
")",
"ToNetwork",
"(",
")",
"ServiceValue",
"{",
"n",
":=",
"*",
"s",
"\n",
"n",
".",
"RevNat",
"=",
"byteorder",
".",
"HostToNetwork",
"(",
"n",
".",
"RevNat",
")",
".",
"(",
"uint16",
")",
"\n",
"n",
".",
"Port",
"=",
"byteorder",
".",
"HostToNetwork",
"(",
"n",
".",
"Port",
")",
".",
"(",
"uint16",
")",
"\n",
"n",
".",
"Weight",
"=",
"byteorder",
".",
"HostToNetwork",
"(",
"n",
".",
"Weight",
")",
".",
"(",
"uint16",
")",
"\n",
"return",
"&",
"n",
"\n",
"}"
] | // ToNetwork converts Service6Value ports to network byte order. | [
"ToNetwork",
"converts",
"Service6Value",
"ports",
"to",
"network",
"byte",
"order",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/ipv6.go#L225-L231 |
163,884 | cilium/cilium | pkg/maps/lbmap/ipv6.go | ToHost | func (s *Service6Value) ToHost() ServiceValue {
n := *s
n.RevNat = byteorder.NetworkToHost(n.RevNat).(uint16)
n.Port = byteorder.NetworkToHost(n.Port).(uint16)
n.Weight = byteorder.NetworkToHost(n.Weight).(uint16)
return &n
} | go | func (s *Service6Value) ToHost() ServiceValue {
n := *s
n.RevNat = byteorder.NetworkToHost(n.RevNat).(uint16)
n.Port = byteorder.NetworkToHost(n.Port).(uint16)
n.Weight = byteorder.NetworkToHost(n.Weight).(uint16)
return &n
} | [
"func",
"(",
"s",
"*",
"Service6Value",
")",
"ToHost",
"(",
")",
"ServiceValue",
"{",
"n",
":=",
"*",
"s",
"\n",
"n",
".",
"RevNat",
"=",
"byteorder",
".",
"NetworkToHost",
"(",
"n",
".",
"RevNat",
")",
".",
"(",
"uint16",
")",
"\n",
"n",
".",
"Port",
"=",
"byteorder",
".",
"NetworkToHost",
"(",
"n",
".",
"Port",
")",
".",
"(",
"uint16",
")",
"\n",
"n",
".",
"Weight",
"=",
"byteorder",
".",
"NetworkToHost",
"(",
"n",
".",
"Weight",
")",
".",
"(",
"uint16",
")",
"\n",
"return",
"&",
"n",
"\n",
"}"
] | // ToHost converts Service6Value ports to host byte order. | [
"ToHost",
"converts",
"Service6Value",
"ports",
"to",
"host",
"byte",
"order",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/ipv6.go#L234-L240 |
163,885 | cilium/cilium | pkg/maps/lbmap/ipv6.go | ToNetwork | func (v *RevNat6Key) ToNetwork() RevNatKey {
n := *v
n.Key = byteorder.HostToNetwork(n.Key).(uint16)
return &n
} | go | func (v *RevNat6Key) ToNetwork() RevNatKey {
n := *v
n.Key = byteorder.HostToNetwork(n.Key).(uint16)
return &n
} | [
"func",
"(",
"v",
"*",
"RevNat6Key",
")",
"ToNetwork",
"(",
")",
"RevNatKey",
"{",
"n",
":=",
"*",
"v",
"\n",
"n",
".",
"Key",
"=",
"byteorder",
".",
"HostToNetwork",
"(",
"n",
".",
"Key",
")",
".",
"(",
"uint16",
")",
"\n",
"return",
"&",
"n",
"\n",
"}"
] | // ToNetwork converts RevNat6Key to network byte order. | [
"ToNetwork",
"converts",
"RevNat6Key",
"to",
"network",
"byte",
"order",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/ipv6.go#L266-L270 |
163,886 | cilium/cilium | proxylib/proxylib.go | Close | func Close(connectionId uint64) {
mutex.Lock()
delete(connections, connectionId)
mutex.Unlock()
} | go | func Close(connectionId uint64) {
mutex.Lock()
delete(connections, connectionId)
mutex.Unlock()
} | [
"func",
"Close",
"(",
"connectionId",
"uint64",
")",
"{",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"delete",
"(",
"connections",
",",
"connectionId",
")",
"\n",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // Make this more general connection event callback
//export Close | [
"Make",
"this",
"more",
"general",
"connection",
"event",
"callback",
"export",
"Close"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/proxylib/proxylib.go#L112-L116 |
163,887 | cilium/cilium | proxylib/proxylib.go | OpenModule | func OpenModule(params [][2]string, debug bool) uint64 {
var accessLogPath, xdsPath, nodeID string
for i := range params {
key := params[i][0]
value := strcpy(params[i][1])
switch key {
case "access-log-path":
accessLogPath = value
case "xds-path":
xdsPath = value
case "node-id":
nodeID = value
default:
return 0
}
}
if debug {
mutex.Lock()
log.SetLevel(log.DebugLevel)
mutex.Unlock()
}
// Copy strings from C-memory to Go-memory so that the string remains valid
// also after this function returns
return OpenInstance(nodeID, xdsPath, npds.NewClient, accessLogPath, accesslog.NewClient)
} | go | func OpenModule(params [][2]string, debug bool) uint64 {
var accessLogPath, xdsPath, nodeID string
for i := range params {
key := params[i][0]
value := strcpy(params[i][1])
switch key {
case "access-log-path":
accessLogPath = value
case "xds-path":
xdsPath = value
case "node-id":
nodeID = value
default:
return 0
}
}
if debug {
mutex.Lock()
log.SetLevel(log.DebugLevel)
mutex.Unlock()
}
// Copy strings from C-memory to Go-memory so that the string remains valid
// also after this function returns
return OpenInstance(nodeID, xdsPath, npds.NewClient, accessLogPath, accesslog.NewClient)
} | [
"func",
"OpenModule",
"(",
"params",
"[",
"]",
"[",
"2",
"]",
"string",
",",
"debug",
"bool",
")",
"uint64",
"{",
"var",
"accessLogPath",
",",
"xdsPath",
",",
"nodeID",
"string",
"\n",
"for",
"i",
":=",
"range",
"params",
"{",
"key",
":=",
"params",
"[",
"i",
"]",
"[",
"0",
"]",
"\n",
"value",
":=",
"strcpy",
"(",
"params",
"[",
"i",
"]",
"[",
"1",
"]",
")",
"\n\n",
"switch",
"key",
"{",
"case",
"\"",
"\"",
":",
"accessLogPath",
"=",
"value",
"\n",
"case",
"\"",
"\"",
":",
"xdsPath",
"=",
"value",
"\n",
"case",
"\"",
"\"",
":",
"nodeID",
"=",
"value",
"\n",
"default",
":",
"return",
"0",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"debug",
"{",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"log",
".",
"SetLevel",
"(",
"log",
".",
"DebugLevel",
")",
"\n",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"}",
"\n",
"// Copy strings from C-memory to Go-memory so that the string remains valid",
"// also after this function returns",
"return",
"OpenInstance",
"(",
"nodeID",
",",
"xdsPath",
",",
"npds",
".",
"NewClient",
",",
"accessLogPath",
",",
"accesslog",
".",
"NewClient",
")",
"\n",
"}"
] | // OpenModule is called before any other APIs.
// Called concurrently by different filter instances.
// Returns a library instance ID that must be passed to all other API calls.
// Calls with the same parameters will return the same instance.
// Zero return value indicates an error.
//export OpenModule | [
"OpenModule",
"is",
"called",
"before",
"any",
"other",
"APIs",
".",
"Called",
"concurrently",
"by",
"different",
"filter",
"instances",
".",
"Returns",
"a",
"library",
"instance",
"ID",
"that",
"must",
"be",
"passed",
"to",
"all",
"other",
"API",
"calls",
".",
"Calls",
"with",
"the",
"same",
"parameters",
"will",
"return",
"the",
"same",
"instance",
".",
"Zero",
"return",
"value",
"indicates",
"an",
"error",
".",
"export",
"OpenModule"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/proxylib/proxylib.go#L124-L150 |
163,888 | cilium/cilium | pkg/maps/lbmap/ipv4.go | ToNetwork | func (k *Service4Key) ToNetwork() ServiceKey {
n := *k
n.Port = byteorder.HostToNetwork(n.Port).(uint16)
return &n
} | go | func (k *Service4Key) ToNetwork() ServiceKey {
n := *k
n.Port = byteorder.HostToNetwork(n.Port).(uint16)
return &n
} | [
"func",
"(",
"k",
"*",
"Service4Key",
")",
"ToNetwork",
"(",
")",
"ServiceKey",
"{",
"n",
":=",
"*",
"k",
"\n",
"n",
".",
"Port",
"=",
"byteorder",
".",
"HostToNetwork",
"(",
"n",
".",
"Port",
")",
".",
"(",
"uint16",
")",
"\n",
"return",
"&",
"n",
"\n",
"}"
] | // ToNetwork converts Service4Key port to network byte order. | [
"ToNetwork",
"converts",
"Service4Key",
"port",
"to",
"network",
"byte",
"order",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/ipv4.go#L147-L151 |
163,889 | cilium/cilium | pkg/maps/lbmap/ipv4.go | ToNetwork | func (k *RevNat4Key) ToNetwork() RevNatKey {
n := *k
n.Key = byteorder.HostToNetwork(n.Key).(uint16)
return &n
} | go | func (k *RevNat4Key) ToNetwork() RevNatKey {
n := *k
n.Key = byteorder.HostToNetwork(n.Key).(uint16)
return &n
} | [
"func",
"(",
"k",
"*",
"RevNat4Key",
")",
"ToNetwork",
"(",
")",
"RevNatKey",
"{",
"n",
":=",
"*",
"k",
"\n",
"n",
".",
"Key",
"=",
"byteorder",
".",
"HostToNetwork",
"(",
"n",
".",
"Key",
")",
".",
"(",
"uint16",
")",
"\n",
"return",
"&",
"n",
"\n",
"}"
] | // ToNetwork converts RevNat4Key to network byte order. | [
"ToNetwork",
"converts",
"RevNat4Key",
"to",
"network",
"byte",
"order",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/ipv4.go#L269-L273 |
163,890 | cilium/cilium | pkg/maps/lbmap/ipv4.go | ToNetwork | func (v *RevNat4Value) ToNetwork() RevNatValue {
n := *v
n.Port = byteorder.HostToNetwork(n.Port).(uint16)
return &n
} | go | func (v *RevNat4Value) ToNetwork() RevNatValue {
n := *v
n.Port = byteorder.HostToNetwork(n.Port).(uint16)
return &n
} | [
"func",
"(",
"v",
"*",
"RevNat4Value",
")",
"ToNetwork",
"(",
")",
"RevNatValue",
"{",
"n",
":=",
"*",
"v",
"\n",
"n",
".",
"Port",
"=",
"byteorder",
".",
"HostToNetwork",
"(",
"n",
".",
"Port",
")",
".",
"(",
"uint16",
")",
"\n",
"return",
"&",
"n",
"\n",
"}"
] | // ToNetwork converts RevNat4Value to network byte order. | [
"ToNetwork",
"converts",
"RevNat4Value",
"to",
"network",
"byte",
"order",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/ipv4.go#L283-L287 |
163,891 | cilium/cilium | api/v1/server/restapi/service/get_service.go | NewGetService | func NewGetService(ctx *middleware.Context, handler GetServiceHandler) *GetService {
return &GetService{Context: ctx, Handler: handler}
} | go | func NewGetService(ctx *middleware.Context, handler GetServiceHandler) *GetService {
return &GetService{Context: ctx, Handler: handler}
} | [
"func",
"NewGetService",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"GetServiceHandler",
")",
"*",
"GetService",
"{",
"return",
"&",
"GetService",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewGetService creates a new http.Handler for the get service operation | [
"NewGetService",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"get",
"service",
"operation"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/service/get_service.go#L28-L30 |
163,892 | cilium/cilium | api/v1/server/restapi/ipam/post_ip_a_m_ip.go | NewPostIPAMIP | func NewPostIPAMIP(ctx *middleware.Context, handler PostIPAMIPHandler) *PostIPAMIP {
return &PostIPAMIP{Context: ctx, Handler: handler}
} | go | func NewPostIPAMIP(ctx *middleware.Context, handler PostIPAMIPHandler) *PostIPAMIP {
return &PostIPAMIP{Context: ctx, Handler: handler}
} | [
"func",
"NewPostIPAMIP",
"(",
"ctx",
"*",
"middleware",
".",
"Context",
",",
"handler",
"PostIPAMIPHandler",
")",
"*",
"PostIPAMIP",
"{",
"return",
"&",
"PostIPAMIP",
"{",
"Context",
":",
"ctx",
",",
"Handler",
":",
"handler",
"}",
"\n",
"}"
] | // NewPostIPAMIP creates a new http.Handler for the post IP a m IP operation | [
"NewPostIPAMIP",
"creates",
"a",
"new",
"http",
".",
"Handler",
"for",
"the",
"post",
"IP",
"a",
"m",
"IP",
"operation"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/ipam/post_ip_a_m_ip.go#L28-L30 |
163,893 | cilium/cilium | api/v1/health/client/connectivity/get_status_parameters.go | WithTimeout | func (o *GetStatusParams) WithTimeout(timeout time.Duration) *GetStatusParams {
o.SetTimeout(timeout)
return o
} | go | func (o *GetStatusParams) WithTimeout(timeout time.Duration) *GetStatusParams {
o.SetTimeout(timeout)
return o
} | [
"func",
"(",
"o",
"*",
"GetStatusParams",
")",
"WithTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"*",
"GetStatusParams",
"{",
"o",
".",
"SetTimeout",
"(",
"timeout",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithTimeout adds the timeout to the get status params | [
"WithTimeout",
"adds",
"the",
"timeout",
"to",
"the",
"get",
"status",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/client/connectivity/get_status_parameters.go#L69-L72 |
163,894 | cilium/cilium | api/v1/health/client/connectivity/get_status_parameters.go | WithContext | func (o *GetStatusParams) WithContext(ctx context.Context) *GetStatusParams {
o.SetContext(ctx)
return o
} | go | func (o *GetStatusParams) WithContext(ctx context.Context) *GetStatusParams {
o.SetContext(ctx)
return o
} | [
"func",
"(",
"o",
"*",
"GetStatusParams",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"GetStatusParams",
"{",
"o",
".",
"SetContext",
"(",
"ctx",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithContext adds the context to the get status params | [
"WithContext",
"adds",
"the",
"context",
"to",
"the",
"get",
"status",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/client/connectivity/get_status_parameters.go#L80-L83 |
163,895 | cilium/cilium | api/v1/health/client/connectivity/get_status_parameters.go | WithHTTPClient | func (o *GetStatusParams) WithHTTPClient(client *http.Client) *GetStatusParams {
o.SetHTTPClient(client)
return o
} | go | func (o *GetStatusParams) WithHTTPClient(client *http.Client) *GetStatusParams {
o.SetHTTPClient(client)
return o
} | [
"func",
"(",
"o",
"*",
"GetStatusParams",
")",
"WithHTTPClient",
"(",
"client",
"*",
"http",
".",
"Client",
")",
"*",
"GetStatusParams",
"{",
"o",
".",
"SetHTTPClient",
"(",
"client",
")",
"\n",
"return",
"o",
"\n",
"}"
] | // WithHTTPClient adds the HTTPClient to the get status params | [
"WithHTTPClient",
"adds",
"the",
"HTTPClient",
"to",
"the",
"get",
"status",
"params"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/client/connectivity/get_status_parameters.go#L91-L94 |
163,896 | cilium/cilium | api/v1/server/restapi/prefilter/get_prefilter_responses.go | WithPayload | func (o *GetPrefilterOK) WithPayload(payload *models.Prefilter) *GetPrefilterOK {
o.Payload = payload
return o
} | go | func (o *GetPrefilterOK) WithPayload(payload *models.Prefilter) *GetPrefilterOK {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetPrefilterOK",
")",
"WithPayload",
"(",
"payload",
"*",
"models",
".",
"Prefilter",
")",
"*",
"GetPrefilterOK",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get prefilter o k response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"prefilter",
"o",
"k",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/prefilter/get_prefilter_responses.go#L38-L41 |
163,897 | cilium/cilium | api/v1/server/restapi/prefilter/get_prefilter_responses.go | WithPayload | func (o *GetPrefilterFailure) WithPayload(payload models.Error) *GetPrefilterFailure {
o.Payload = payload
return o
} | go | func (o *GetPrefilterFailure) WithPayload(payload models.Error) *GetPrefilterFailure {
o.Payload = payload
return o
} | [
"func",
"(",
"o",
"*",
"GetPrefilterFailure",
")",
"WithPayload",
"(",
"payload",
"models",
".",
"Error",
")",
"*",
"GetPrefilterFailure",
"{",
"o",
".",
"Payload",
"=",
"payload",
"\n",
"return",
"o",
"\n",
"}"
] | // WithPayload adds the payload to the get prefilter failure response | [
"WithPayload",
"adds",
"the",
"payload",
"to",
"the",
"get",
"prefilter",
"failure",
"response"
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/prefilter/get_prefilter_responses.go#L82-L85 |
163,898 | cilium/cilium | pkg/ipcache/cidr.go | AllocateCIDRs | func AllocateCIDRs(impl Implementation, prefixes []*net.IPNet) error {
// First, if the implementation will complain, exit early.
if err := checkPrefixes(impl, prefixes); err != nil {
return err
}
// maintain list of used identities to undo on error
usedIdentities := []*identity.Identity{}
// maintain list of newly allocated identities to update ipcache
allocatedIdentities := map[string]*identity.Identity{}
for _, prefix := range prefixes {
if prefix == nil {
continue
}
id, isNew, err := cache.AllocateIdentity(context.Background(), cidr.GetCIDRLabels(prefix))
if err != nil {
cache.ReleaseSlice(context.Background(), usedIdentities)
return fmt.Errorf("failed to allocate identity for cidr %s: %s", prefix.String(), err)
}
id.CIDRLabel = labels.NewLabelsFromModel([]string{labels.LabelSourceCIDR + ":" + prefix.String()})
usedIdentities = append(usedIdentities, id)
if isNew {
allocatedIdentities[prefix.String()] = id
}
}
for prefixString, id := range allocatedIdentities {
IPIdentityCache.Upsert(prefixString, nil, 0, Identity{
ID: id.ID,
Source: FromCIDR,
})
}
return nil
} | go | func AllocateCIDRs(impl Implementation, prefixes []*net.IPNet) error {
// First, if the implementation will complain, exit early.
if err := checkPrefixes(impl, prefixes); err != nil {
return err
}
// maintain list of used identities to undo on error
usedIdentities := []*identity.Identity{}
// maintain list of newly allocated identities to update ipcache
allocatedIdentities := map[string]*identity.Identity{}
for _, prefix := range prefixes {
if prefix == nil {
continue
}
id, isNew, err := cache.AllocateIdentity(context.Background(), cidr.GetCIDRLabels(prefix))
if err != nil {
cache.ReleaseSlice(context.Background(), usedIdentities)
return fmt.Errorf("failed to allocate identity for cidr %s: %s", prefix.String(), err)
}
id.CIDRLabel = labels.NewLabelsFromModel([]string{labels.LabelSourceCIDR + ":" + prefix.String()})
usedIdentities = append(usedIdentities, id)
if isNew {
allocatedIdentities[prefix.String()] = id
}
}
for prefixString, id := range allocatedIdentities {
IPIdentityCache.Upsert(prefixString, nil, 0, Identity{
ID: id.ID,
Source: FromCIDR,
})
}
return nil
} | [
"func",
"AllocateCIDRs",
"(",
"impl",
"Implementation",
",",
"prefixes",
"[",
"]",
"*",
"net",
".",
"IPNet",
")",
"error",
"{",
"// First, if the implementation will complain, exit early.",
"if",
"err",
":=",
"checkPrefixes",
"(",
"impl",
",",
"prefixes",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// maintain list of used identities to undo on error",
"usedIdentities",
":=",
"[",
"]",
"*",
"identity",
".",
"Identity",
"{",
"}",
"\n\n",
"// maintain list of newly allocated identities to update ipcache",
"allocatedIdentities",
":=",
"map",
"[",
"string",
"]",
"*",
"identity",
".",
"Identity",
"{",
"}",
"\n\n",
"for",
"_",
",",
"prefix",
":=",
"range",
"prefixes",
"{",
"if",
"prefix",
"==",
"nil",
"{",
"continue",
"\n",
"}",
"\n\n",
"id",
",",
"isNew",
",",
"err",
":=",
"cache",
".",
"AllocateIdentity",
"(",
"context",
".",
"Background",
"(",
")",
",",
"cidr",
".",
"GetCIDRLabels",
"(",
"prefix",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"cache",
".",
"ReleaseSlice",
"(",
"context",
".",
"Background",
"(",
")",
",",
"usedIdentities",
")",
"\n",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"prefix",
".",
"String",
"(",
")",
",",
"err",
")",
"\n",
"}",
"\n\n",
"id",
".",
"CIDRLabel",
"=",
"labels",
".",
"NewLabelsFromModel",
"(",
"[",
"]",
"string",
"{",
"labels",
".",
"LabelSourceCIDR",
"+",
"\"",
"\"",
"+",
"prefix",
".",
"String",
"(",
")",
"}",
")",
"\n\n",
"usedIdentities",
"=",
"append",
"(",
"usedIdentities",
",",
"id",
")",
"\n",
"if",
"isNew",
"{",
"allocatedIdentities",
"[",
"prefix",
".",
"String",
"(",
")",
"]",
"=",
"id",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"prefixString",
",",
"id",
":=",
"range",
"allocatedIdentities",
"{",
"IPIdentityCache",
".",
"Upsert",
"(",
"prefixString",
",",
"nil",
",",
"0",
",",
"Identity",
"{",
"ID",
":",
"id",
".",
"ID",
",",
"Source",
":",
"FromCIDR",
",",
"}",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // AllocateCIDRs attempts to allocate identities for a list of CIDRs. If any
// allocation fails, all allocations are rolled back and the error is returned.
// When an identity is freshly allocated for a CIDR, it is added to the
// ipcache. | [
"AllocateCIDRs",
"attempts",
"to",
"allocate",
"identities",
"for",
"a",
"list",
"of",
"CIDRs",
".",
"If",
"any",
"allocation",
"fails",
"all",
"allocations",
"are",
"rolled",
"back",
"and",
"the",
"error",
"is",
"returned",
".",
"When",
"an",
"identity",
"is",
"freshly",
"allocated",
"for",
"a",
"CIDR",
"it",
"is",
"added",
"to",
"the",
"ipcache",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/ipcache/cidr.go#L32-L71 |
163,899 | cilium/cilium | pkg/ipcache/cidr.go | ReleaseCIDRs | func ReleaseCIDRs(prefixes []*net.IPNet) {
for _, prefix := range prefixes {
if prefix == nil {
continue
}
if id := cache.LookupIdentity(cidr.GetCIDRLabels(prefix)); id != nil {
released, err := cache.Release(context.Background(), id)
if err != nil {
log.WithError(err).Warningf("Unable to release identity for CIDR %s. Ignoring error. Identity may be leaked", prefix.String())
}
if released {
IPIdentityCache.Delete(prefix.String(), FromCIDR)
}
} else {
log.Errorf("Unable to find identity of previously used CIDR %s", prefix.String())
}
}
} | go | func ReleaseCIDRs(prefixes []*net.IPNet) {
for _, prefix := range prefixes {
if prefix == nil {
continue
}
if id := cache.LookupIdentity(cidr.GetCIDRLabels(prefix)); id != nil {
released, err := cache.Release(context.Background(), id)
if err != nil {
log.WithError(err).Warningf("Unable to release identity for CIDR %s. Ignoring error. Identity may be leaked", prefix.String())
}
if released {
IPIdentityCache.Delete(prefix.String(), FromCIDR)
}
} else {
log.Errorf("Unable to find identity of previously used CIDR %s", prefix.String())
}
}
} | [
"func",
"ReleaseCIDRs",
"(",
"prefixes",
"[",
"]",
"*",
"net",
".",
"IPNet",
")",
"{",
"for",
"_",
",",
"prefix",
":=",
"range",
"prefixes",
"{",
"if",
"prefix",
"==",
"nil",
"{",
"continue",
"\n",
"}",
"\n\n",
"if",
"id",
":=",
"cache",
".",
"LookupIdentity",
"(",
"cidr",
".",
"GetCIDRLabels",
"(",
"prefix",
")",
")",
";",
"id",
"!=",
"nil",
"{",
"released",
",",
"err",
":=",
"cache",
".",
"Release",
"(",
"context",
".",
"Background",
"(",
")",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err",
")",
".",
"Warningf",
"(",
"\"",
"\"",
",",
"prefix",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n\n",
"if",
"released",
"{",
"IPIdentityCache",
".",
"Delete",
"(",
"prefix",
".",
"String",
"(",
")",
",",
"FromCIDR",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"prefix",
".",
"String",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // ReleaseCIDRs releases the identities of a list of CIDRs. When the last use
// of the identity is released, the ipcache entry is deleted. | [
"ReleaseCIDRs",
"releases",
"the",
"identities",
"of",
"a",
"list",
"of",
"CIDRs",
".",
"When",
"the",
"last",
"use",
"of",
"the",
"identity",
"is",
"released",
"the",
"ipcache",
"entry",
"is",
"deleted",
"."
] | 6ecfff82c2314dd9d847645361b57e2646eed64b | https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/ipcache/cidr.go#L75-L94 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.