id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
162,300
cilium/cilium
pkg/pprof/pprof.go
Enable
func Enable() { go func() { if err := http.ListenAndServe(apiAddress, nil); err != nil { log.WithError(err).Warn("Unable to serve pprof API") } }() }
go
func Enable() { go func() { if err := http.ListenAndServe(apiAddress, nil); err != nil { log.WithError(err).Warn("Unable to serve pprof API") } }() }
[ "func", "Enable", "(", ")", "{", "go", "func", "(", ")", "{", "if", "err", ":=", "http", ".", "ListenAndServe", "(", "apiAddress", ",", "nil", ")", ";", "err", "!=", "nil", "{", "log", ".", "WithError", "(", "err", ")", ".", "Warn", "(", "\"", ...
// Enable runs an HTTP server to serve the pprof API
[ "Enable", "runs", "an", "HTTP", "server", "to", "serve", "the", "pprof", "API" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/pprof/pprof.go#L31-L37
162,301
cilium/cilium
proxylib/memcached/binary/parser.go
Create
func (p *ParserFactory) Create(connection *proxylib.Connection) proxylib.Parser { log.Infof("ParserFactory: Create: %v", connection) return &Parser{connection: connection, injectQueue: make([]queuedInject, 0)} }
go
func (p *ParserFactory) Create(connection *proxylib.Connection) proxylib.Parser { log.Infof("ParserFactory: Create: %v", connection) return &Parser{connection: connection, injectQueue: make([]queuedInject, 0)} }
[ "func", "(", "p", "*", "ParserFactory", ")", "Create", "(", "connection", "*", "proxylib", ".", "Connection", ")", "proxylib", ".", "Parser", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "connection", ")", "\n", "return", "&", "Parser", "{", "connec...
// Create creates binary memcached parser
[ "Create", "creates", "binary", "memcached", "parser" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/proxylib/memcached/binary/parser.go#L33-L36
162,302
cilium/cilium
api/v1/health/models/health_response.go
Validate
func (m *HealthResponse) Validate(formats strfmt.Registry) error { var res []error if err := m.validateCilium(formats); err != nil { res = append(res, err) } if err := m.validateSystemLoad(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *HealthResponse) Validate(formats strfmt.Registry) error { var res []error if err := m.validateCilium(formats); err != nil { res = append(res, err) } if err := m.validateSystemLoad(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "HealthResponse", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateCilium", "(", "formats", ")", ";", "err", "!=", "ni...
// Validate validates this health response
[ "Validate", "validates", "this", "health", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/health/models/health_response.go#L34-L49
162,303
cilium/cilium
pkg/workloads/docker.go
networksMock
func networksMock() func(req *http.Request) (*http.Response, error) { return func(req *http.Request) (*http.Response, error) { if !strings.HasPrefix(req.URL.Path, "/v1.21/networks") { return nil, fmt.Errorf("Only expecting /v1.21/networks requests, got %s", req.URL.Path) } header := http.Header{} header.Set("Content-Type", "application/json") body, err := json.Marshal(&dTypes.NetworkResource{ Name: "12345", ID: "1234", Scope: "global", Driver: "cilium-net", EnableIPv6: true, IPAM: dNetwork.IPAM{}, Internal: false, // this map contains all endpoints except 259 Containers: map[string]dTypes.EndpointResource{ "603e047d2268a57f5a5f93f7f9e1263e9207e348a06654bf64948def00100256": { EndpointID: "93529fda8c401a071d21d6bd46fdf5499b9014dcb5a35f2e3efaa8d800200256", }, "603e047d2268a57f5a5f93f7f9e1263e9207e348a06654bf64948def00100257": { EndpointID: "93529fda8c401a071d21d6bd46fdf5499b9014dcb5a35f2e3efaa8d800200257", }, "603e047d2268a57f5a5f93f7f9e1263e9207e348a06654bf64948def00100258": { EndpointID: "93529fda8c401a071d21d6bd46fdf5499b9014dcb5a35f2e3efaa8d800100258", }, }, Options: map[string]string{}, Labels: map[string]string{}, }) if err != nil { return nil, err } return &http.Response{ StatusCode: 200, Body: ioutil.NopCloser(bytes.NewReader(body)), Header: header, }, nil } }
go
func networksMock() func(req *http.Request) (*http.Response, error) { return func(req *http.Request) (*http.Response, error) { if !strings.HasPrefix(req.URL.Path, "/v1.21/networks") { return nil, fmt.Errorf("Only expecting /v1.21/networks requests, got %s", req.URL.Path) } header := http.Header{} header.Set("Content-Type", "application/json") body, err := json.Marshal(&dTypes.NetworkResource{ Name: "12345", ID: "1234", Scope: "global", Driver: "cilium-net", EnableIPv6: true, IPAM: dNetwork.IPAM{}, Internal: false, // this map contains all endpoints except 259 Containers: map[string]dTypes.EndpointResource{ "603e047d2268a57f5a5f93f7f9e1263e9207e348a06654bf64948def00100256": { EndpointID: "93529fda8c401a071d21d6bd46fdf5499b9014dcb5a35f2e3efaa8d800200256", }, "603e047d2268a57f5a5f93f7f9e1263e9207e348a06654bf64948def00100257": { EndpointID: "93529fda8c401a071d21d6bd46fdf5499b9014dcb5a35f2e3efaa8d800200257", }, "603e047d2268a57f5a5f93f7f9e1263e9207e348a06654bf64948def00100258": { EndpointID: "93529fda8c401a071d21d6bd46fdf5499b9014dcb5a35f2e3efaa8d800100258", }, }, Options: map[string]string{}, Labels: map[string]string{}, }) if err != nil { return nil, err } return &http.Response{ StatusCode: 200, Body: ioutil.NopCloser(bytes.NewReader(body)), Header: header, }, nil } }
[ "func", "networksMock", "(", ")", "func", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "return", "func", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ...
// Helper function to mock docker calls to networks endpoint
[ "Helper", "function", "to", "mock", "docker", "calls", "to", "networks", "endpoint" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/workloads/docker.go#L159-L201
162,304
cilium/cilium
pkg/workloads/docker.go
GetAllInfraContainersPID
func (d *dockerClient) GetAllInfraContainersPID() (map[string]int, error) { timeoutCtx, cancel := ctx.WithTimeout(ctx.Background(), 10*time.Second) defer cancel() cList, err := Client().workloadIDsList(timeoutCtx) if err != nil { log.WithError(err).Error("Failed to retrieve the container list") return nil, err } pids := map[string]int{} for _, contID := range cList { cJSON, err := d.ContainerInspect(context.Background(), contID) if err != nil { continue } if cJSON.Config == nil || !utils.IsInfraContainer(cJSON.Config.Labels) { continue } if cJSON.State == nil || !cJSON.State.Running { continue } pids[cJSON.ID] = cJSON.State.Pid } return pids, nil }
go
func (d *dockerClient) GetAllInfraContainersPID() (map[string]int, error) { timeoutCtx, cancel := ctx.WithTimeout(ctx.Background(), 10*time.Second) defer cancel() cList, err := Client().workloadIDsList(timeoutCtx) if err != nil { log.WithError(err).Error("Failed to retrieve the container list") return nil, err } pids := map[string]int{} for _, contID := range cList { cJSON, err := d.ContainerInspect(context.Background(), contID) if err != nil { continue } if cJSON.Config == nil || !utils.IsInfraContainer(cJSON.Config.Labels) { continue } if cJSON.State == nil || !cJSON.State.Running { continue } pids[cJSON.ID] = cJSON.State.Pid } return pids, nil }
[ "func", "(", "d", "*", "dockerClient", ")", "GetAllInfraContainersPID", "(", ")", "(", "map", "[", "string", "]", "int", ",", "error", ")", "{", "timeoutCtx", ",", "cancel", ":=", "ctx", ".", "WithTimeout", "(", "ctx", ".", "Background", "(", ")", ",",...
// GetAllInfraContainersPID returns a map that maps container IDs to the PID // of that container.
[ "GetAllInfraContainersPID", "returns", "a", "map", "that", "maps", "container", "IDs", "to", "the", "PID", "of", "that", "container", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/workloads/docker.go#L544-L569
162,305
cilium/cilium
pkg/bpf/map.go
mapTypeToFeatureString
func mapTypeToFeatureString(mt MapType) string { var featureString string switch mt { case MapTypeLPMTrie: featureString = fmt.Sprintf("#define HAVE_LPM_MAP_TYPE") case MapTypeLRUHash: featureString = fmt.Sprintf("#define HAVE_LRU_MAP_TYPE") default: break } return featureString }
go
func mapTypeToFeatureString(mt MapType) string { var featureString string switch mt { case MapTypeLPMTrie: featureString = fmt.Sprintf("#define HAVE_LPM_MAP_TYPE") case MapTypeLRUHash: featureString = fmt.Sprintf("#define HAVE_LRU_MAP_TYPE") default: break } return featureString }
[ "func", "mapTypeToFeatureString", "(", "mt", "MapType", ")", "string", "{", "var", "featureString", "string", "\n", "switch", "mt", "{", "case", "MapTypeLPMTrie", ":", "featureString", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ")", "\n", "case", "MapTypeL...
// mapTypeToFeatureString maps a MapType into a string defined by run_probes.sh
[ "mapTypeToFeatureString", "maps", "a", "MapType", "into", "a", "string", "defined", "by", "run_probes", ".", "sh" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/map.go#L166-L177
162,306
cilium/cilium
pkg/workloads/defaults.go
EndpointCorrelationSleepTime
func EndpointCorrelationSleepTime(try int) time.Duration { return time.Duration(try) * time.Second }
go
func EndpointCorrelationSleepTime(try int) time.Duration { return time.Duration(try) * time.Second }
[ "func", "EndpointCorrelationSleepTime", "(", "try", "int", ")", "time", ".", "Duration", "{", "return", "time", ".", "Duration", "(", "try", ")", "*", "time", ".", "Second", "\n", "}" ]
// EndpointCorrelationSleepTime returns the sleep time between correlation // attempts
[ "EndpointCorrelationSleepTime", "returns", "the", "sleep", "time", "between", "correlation", "attempts" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/workloads/defaults.go#L37-L39
162,307
cilium/cilium
proxylib/memcached/text/parser.go
injectFromQueue
func (p *Parser) injectFromQueue() int { injected := 0 for _, rep := range p.replyQueue { if rep.denied { injected++ p.injectDeniedMessage() } else { break } } if injected > 0 { p.replyQueue = p.replyQueue[injected:] } return injected * len(DeniedMsg) }
go
func (p *Parser) injectFromQueue() int { injected := 0 for _, rep := range p.replyQueue { if rep.denied { injected++ p.injectDeniedMessage() } else { break } } if injected > 0 { p.replyQueue = p.replyQueue[injected:] } return injected * len(DeniedMsg) }
[ "func", "(", "p", "*", "Parser", ")", "injectFromQueue", "(", ")", "int", "{", "injected", ":=", "0", "\n", "for", "_", ",", "rep", ":=", "range", "p", ".", "replyQueue", "{", "if", "rep", ".", "denied", "{", "injected", "++", "\n", "p", ".", "in...
// returns injected bytes
[ "returns", "injected", "bytes" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/proxylib/memcached/text/parser.go#L305-L320
162,308
cilium/cilium
pkg/datapath/fake/node_addressing.go
NewIPv4OnlyNodeAddressing
func NewIPv4OnlyNodeAddressing() datapath.NodeAddressing { return &fakeNodeAddressing{ ipv4: addressFamily{ router: net.ParseIP("1.1.1.2"), primaryExternal: net.ParseIP("1.1.1.1"), allocCIDR: cidr.MustParseCIDR("1.1.1.0/24"), }, ipv6: addressFamily{}, } }
go
func NewIPv4OnlyNodeAddressing() datapath.NodeAddressing { return &fakeNodeAddressing{ ipv4: addressFamily{ router: net.ParseIP("1.1.1.2"), primaryExternal: net.ParseIP("1.1.1.1"), allocCIDR: cidr.MustParseCIDR("1.1.1.0/24"), }, ipv6: addressFamily{}, } }
[ "func", "NewIPv4OnlyNodeAddressing", "(", ")", "datapath", ".", "NodeAddressing", "{", "return", "&", "fakeNodeAddressing", "{", "ipv4", ":", "addressFamily", "{", "router", ":", "net", ".", "ParseIP", "(", "\"", "\"", ")", ",", "primaryExternal", ":", "net", ...
// NewIPv4OnlyNodeAddressing returns a new fake node addressing where IPv6 is // disabled
[ "NewIPv4OnlyNodeAddressing", "returns", "a", "new", "fake", "node", "addressing", "where", "IPv6", "is", "disabled" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/fake/node_addressing.go#L44-L53
162,309
cilium/cilium
pkg/datapath/fake/node_addressing.go
NewNodeAddressing
func NewNodeAddressing() datapath.NodeAddressing { return &fakeNodeAddressing{ ipv4: addressFamily{ router: net.ParseIP("1.1.1.2"), primaryExternal: net.ParseIP("1.1.1.1"), allocCIDR: cidr.MustParseCIDR("1.1.1.0/24"), }, ipv6: addressFamily{ router: net.ParseIP("cafe::2"), primaryExternal: net.ParseIP("cafe::1"), allocCIDR: cidr.MustParseCIDR("cafe::/96"), }, } }
go
func NewNodeAddressing() datapath.NodeAddressing { return &fakeNodeAddressing{ ipv4: addressFamily{ router: net.ParseIP("1.1.1.2"), primaryExternal: net.ParseIP("1.1.1.1"), allocCIDR: cidr.MustParseCIDR("1.1.1.0/24"), }, ipv6: addressFamily{ router: net.ParseIP("cafe::2"), primaryExternal: net.ParseIP("cafe::1"), allocCIDR: cidr.MustParseCIDR("cafe::/96"), }, } }
[ "func", "NewNodeAddressing", "(", ")", "datapath", ".", "NodeAddressing", "{", "return", "&", "fakeNodeAddressing", "{", "ipv4", ":", "addressFamily", "{", "router", ":", "net", ".", "ParseIP", "(", "\"", "\"", ")", ",", "primaryExternal", ":", "net", ".", ...
// NewNodeAddressing returns a new fake node addressing
[ "NewNodeAddressing", "returns", "a", "new", "fake", "node", "addressing" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/fake/node_addressing.go#L56-L69
162,310
cilium/cilium
api/v1/client/endpoint/get_endpoint_id_labels_parameters.go
WithTimeout
func (o *GetEndpointIDLabelsParams) WithTimeout(timeout time.Duration) *GetEndpointIDLabelsParams { o.SetTimeout(timeout) return o }
go
func (o *GetEndpointIDLabelsParams) WithTimeout(timeout time.Duration) *GetEndpointIDLabelsParams { o.SetTimeout(timeout) return o }
[ "func", "(", "o", "*", "GetEndpointIDLabelsParams", ")", "WithTimeout", "(", "timeout", "time", ".", "Duration", ")", "*", "GetEndpointIDLabelsParams", "{", "o", ".", "SetTimeout", "(", "timeout", ")", "\n", "return", "o", "\n", "}" ]
// WithTimeout adds the timeout to the get endpoint ID labels params
[ "WithTimeout", "adds", "the", "timeout", "to", "the", "get", "endpoint", "ID", "labels", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_labels_parameters.go#L88-L91
162,311
cilium/cilium
api/v1/client/endpoint/get_endpoint_id_labels_parameters.go
WithContext
func (o *GetEndpointIDLabelsParams) WithContext(ctx context.Context) *GetEndpointIDLabelsParams { o.SetContext(ctx) return o }
go
func (o *GetEndpointIDLabelsParams) WithContext(ctx context.Context) *GetEndpointIDLabelsParams { o.SetContext(ctx) return o }
[ "func", "(", "o", "*", "GetEndpointIDLabelsParams", ")", "WithContext", "(", "ctx", "context", ".", "Context", ")", "*", "GetEndpointIDLabelsParams", "{", "o", ".", "SetContext", "(", "ctx", ")", "\n", "return", "o", "\n", "}" ]
// WithContext adds the context to the get endpoint ID labels params
[ "WithContext", "adds", "the", "context", "to", "the", "get", "endpoint", "ID", "labels", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_labels_parameters.go#L99-L102
162,312
cilium/cilium
api/v1/client/endpoint/get_endpoint_id_labels_parameters.go
WithHTTPClient
func (o *GetEndpointIDLabelsParams) WithHTTPClient(client *http.Client) *GetEndpointIDLabelsParams { o.SetHTTPClient(client) return o }
go
func (o *GetEndpointIDLabelsParams) WithHTTPClient(client *http.Client) *GetEndpointIDLabelsParams { o.SetHTTPClient(client) return o }
[ "func", "(", "o", "*", "GetEndpointIDLabelsParams", ")", "WithHTTPClient", "(", "client", "*", "http", ".", "Client", ")", "*", "GetEndpointIDLabelsParams", "{", "o", ".", "SetHTTPClient", "(", "client", ")", "\n", "return", "o", "\n", "}" ]
// WithHTTPClient adds the HTTPClient to the get endpoint ID labels params
[ "WithHTTPClient", "adds", "the", "HTTPClient", "to", "the", "get", "endpoint", "ID", "labels", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_labels_parameters.go#L110-L113
162,313
cilium/cilium
api/v1/client/endpoint/get_endpoint_id_labels_parameters.go
WithID
func (o *GetEndpointIDLabelsParams) WithID(id string) *GetEndpointIDLabelsParams { o.SetID(id) return o }
go
func (o *GetEndpointIDLabelsParams) WithID(id string) *GetEndpointIDLabelsParams { o.SetID(id) return o }
[ "func", "(", "o", "*", "GetEndpointIDLabelsParams", ")", "WithID", "(", "id", "string", ")", "*", "GetEndpointIDLabelsParams", "{", "o", ".", "SetID", "(", "id", ")", "\n", "return", "o", "\n", "}" ]
// WithID adds the id to the get endpoint ID labels params
[ "WithID", "adds", "the", "id", "to", "the", "get", "endpoint", "ID", "labels", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_labels_parameters.go#L121-L124
162,314
cilium/cilium
api/v1/server/restapi/service/get_service_responses.go
WithPayload
func (o *GetServiceOK) WithPayload(payload []*models.Service) *GetServiceOK { o.Payload = payload return o }
go
func (o *GetServiceOK) WithPayload(payload []*models.Service) *GetServiceOK { o.Payload = payload return o }
[ "func", "(", "o", "*", "GetServiceOK", ")", "WithPayload", "(", "payload", "[", "]", "*", "models", ".", "Service", ")", "*", "GetServiceOK", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the get service o k response
[ "WithPayload", "adds", "the", "payload", "to", "the", "get", "service", "o", "k", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/service/get_service_responses.go#L38-L41
162,315
cilium/cilium
pkg/uuid/uuid.go
NewUUID
func NewUUID() uuid.UUID { uuidLock.Lock() defer uuidLock.Unlock() result := uuid.NewUUID() // The UUID package is naive and can generate identical UUIDs if the // time interval is quick enough. // The UUID uses 100 ns increments so it's short enough to actively // wait for a new value. for uuid.Equal(lastUUID, result) == true { result = uuid.NewUUID() } lastUUID = result return result }
go
func NewUUID() uuid.UUID { uuidLock.Lock() defer uuidLock.Unlock() result := uuid.NewUUID() // The UUID package is naive and can generate identical UUIDs if the // time interval is quick enough. // The UUID uses 100 ns increments so it's short enough to actively // wait for a new value. for uuid.Equal(lastUUID, result) == true { result = uuid.NewUUID() } lastUUID = result return result }
[ "func", "NewUUID", "(", ")", "uuid", ".", "UUID", "{", "uuidLock", ".", "Lock", "(", ")", "\n", "defer", "uuidLock", ".", "Unlock", "(", ")", "\n", "result", ":=", "uuid", ".", "NewUUID", "(", ")", "\n", "// The UUID package is naive and can generate identic...
// NewUUID returns a new UUID
[ "NewUUID", "returns", "a", "new", "UUID" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/uuid/uuid.go#L29-L42
162,316
cilium/cilium
api/v1/client/endpoint/patch_endpoint_id_config_parameters.go
WithTimeout
func (o *PatchEndpointIDConfigParams) WithTimeout(timeout time.Duration) *PatchEndpointIDConfigParams { o.SetTimeout(timeout) return o }
go
func (o *PatchEndpointIDConfigParams) WithTimeout(timeout time.Duration) *PatchEndpointIDConfigParams { o.SetTimeout(timeout) return o }
[ "func", "(", "o", "*", "PatchEndpointIDConfigParams", ")", "WithTimeout", "(", "timeout", "time", ".", "Duration", ")", "*", "PatchEndpointIDConfigParams", "{", "o", ".", "SetTimeout", "(", "timeout", ")", "\n", "return", "o", "\n", "}" ]
// WithTimeout adds the timeout to the patch endpoint ID config params
[ "WithTimeout", "adds", "the", "timeout", "to", "the", "patch", "endpoint", "ID", "config", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/patch_endpoint_id_config_parameters.go#L92-L95
162,317
cilium/cilium
api/v1/client/endpoint/patch_endpoint_id_config_parameters.go
WithContext
func (o *PatchEndpointIDConfigParams) WithContext(ctx context.Context) *PatchEndpointIDConfigParams { o.SetContext(ctx) return o }
go
func (o *PatchEndpointIDConfigParams) WithContext(ctx context.Context) *PatchEndpointIDConfigParams { o.SetContext(ctx) return o }
[ "func", "(", "o", "*", "PatchEndpointIDConfigParams", ")", "WithContext", "(", "ctx", "context", ".", "Context", ")", "*", "PatchEndpointIDConfigParams", "{", "o", ".", "SetContext", "(", "ctx", ")", "\n", "return", "o", "\n", "}" ]
// WithContext adds the context to the patch endpoint ID config params
[ "WithContext", "adds", "the", "context", "to", "the", "patch", "endpoint", "ID", "config", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/patch_endpoint_id_config_parameters.go#L103-L106
162,318
cilium/cilium
api/v1/client/endpoint/patch_endpoint_id_config_parameters.go
WithHTTPClient
func (o *PatchEndpointIDConfigParams) WithHTTPClient(client *http.Client) *PatchEndpointIDConfigParams { o.SetHTTPClient(client) return o }
go
func (o *PatchEndpointIDConfigParams) WithHTTPClient(client *http.Client) *PatchEndpointIDConfigParams { o.SetHTTPClient(client) return o }
[ "func", "(", "o", "*", "PatchEndpointIDConfigParams", ")", "WithHTTPClient", "(", "client", "*", "http", ".", "Client", ")", "*", "PatchEndpointIDConfigParams", "{", "o", ".", "SetHTTPClient", "(", "client", ")", "\n", "return", "o", "\n", "}" ]
// WithHTTPClient adds the HTTPClient to the patch endpoint ID config params
[ "WithHTTPClient", "adds", "the", "HTTPClient", "to", "the", "patch", "endpoint", "ID", "config", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/patch_endpoint_id_config_parameters.go#L114-L117
162,319
cilium/cilium
api/v1/client/endpoint/patch_endpoint_id_config_parameters.go
WithEndpointConfiguration
func (o *PatchEndpointIDConfigParams) WithEndpointConfiguration(endpointConfiguration *models.EndpointConfigurationSpec) *PatchEndpointIDConfigParams { o.SetEndpointConfiguration(endpointConfiguration) return o }
go
func (o *PatchEndpointIDConfigParams) WithEndpointConfiguration(endpointConfiguration *models.EndpointConfigurationSpec) *PatchEndpointIDConfigParams { o.SetEndpointConfiguration(endpointConfiguration) return o }
[ "func", "(", "o", "*", "PatchEndpointIDConfigParams", ")", "WithEndpointConfiguration", "(", "endpointConfiguration", "*", "models", ".", "EndpointConfigurationSpec", ")", "*", "PatchEndpointIDConfigParams", "{", "o", ".", "SetEndpointConfiguration", "(", "endpointConfigura...
// WithEndpointConfiguration adds the endpointConfiguration to the patch endpoint ID config params
[ "WithEndpointConfiguration", "adds", "the", "endpointConfiguration", "to", "the", "patch", "endpoint", "ID", "config", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/patch_endpoint_id_config_parameters.go#L125-L128
162,320
cilium/cilium
api/v1/client/endpoint/patch_endpoint_id_config_parameters.go
WithID
func (o *PatchEndpointIDConfigParams) WithID(id string) *PatchEndpointIDConfigParams { o.SetID(id) return o }
go
func (o *PatchEndpointIDConfigParams) WithID(id string) *PatchEndpointIDConfigParams { o.SetID(id) return o }
[ "func", "(", "o", "*", "PatchEndpointIDConfigParams", ")", "WithID", "(", "id", "string", ")", "*", "PatchEndpointIDConfigParams", "{", "o", ".", "SetID", "(", "id", ")", "\n", "return", "o", "\n", "}" ]
// WithID adds the id to the patch endpoint ID config params
[ "WithID", "adds", "the", "id", "to", "the", "patch", "endpoint", "ID", "config", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/patch_endpoint_id_config_parameters.go#L136-L139
162,321
cilium/cilium
pkg/k8s/client.go
createConfig
func createConfig(endpoint, kubeCfgPath string) (*rest.Config, error) { userAgent := fmt.Sprintf("Cilium %s", version.Version) // If the endpoint and the kubeCfgPath are empty then we can try getting // the rest.Config from the InClusterConfig if endpoint == "" && kubeCfgPath == "" { config, err := rest.InClusterConfig() if err != nil { return nil, err } config.UserAgent = userAgent return config, nil } if kubeCfgPath != "" { config, err := clientcmd.BuildConfigFromFlags("", kubeCfgPath) if err != nil { return nil, err } config.UserAgent = userAgent return config, nil } config := &rest.Config{Host: endpoint, UserAgent: userAgent} err := rest.SetKubernetesDefaults(config) return config, err }
go
func createConfig(endpoint, kubeCfgPath string) (*rest.Config, error) { userAgent := fmt.Sprintf("Cilium %s", version.Version) // If the endpoint and the kubeCfgPath are empty then we can try getting // the rest.Config from the InClusterConfig if endpoint == "" && kubeCfgPath == "" { config, err := rest.InClusterConfig() if err != nil { return nil, err } config.UserAgent = userAgent return config, nil } if kubeCfgPath != "" { config, err := clientcmd.BuildConfigFromFlags("", kubeCfgPath) if err != nil { return nil, err } config.UserAgent = userAgent return config, nil } config := &rest.Config{Host: endpoint, UserAgent: userAgent} err := rest.SetKubernetesDefaults(config) return config, err }
[ "func", "createConfig", "(", "endpoint", ",", "kubeCfgPath", "string", ")", "(", "*", "rest", ".", "Config", ",", "error", ")", "{", "userAgent", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "version", ".", "Version", ")", "\n\n", "// If the endpoi...
// CreateConfig creates a rest.Config for a given endpoint using a kubeconfig file.
[ "CreateConfig", "creates", "a", "rest", ".", "Config", "for", "a", "given", "endpoint", "using", "a", "kubeconfig", "file", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/client.go#L47-L74
162,322
cilium/cilium
pkg/k8s/client.go
CreateConfigFromAgentResponse
func CreateConfigFromAgentResponse(resp *models.DaemonConfiguration) (*rest.Config, error) { return createConfig(resp.Status.K8sEndpoint, resp.Status.K8sConfiguration) }
go
func CreateConfigFromAgentResponse(resp *models.DaemonConfiguration) (*rest.Config, error) { return createConfig(resp.Status.K8sEndpoint, resp.Status.K8sConfiguration) }
[ "func", "CreateConfigFromAgentResponse", "(", "resp", "*", "models", ".", "DaemonConfiguration", ")", "(", "*", "rest", ".", "Config", ",", "error", ")", "{", "return", "createConfig", "(", "resp", ".", "Status", ".", "K8sEndpoint", ",", "resp", ".", "Status...
// CreateConfigFromAgentResponse creates a client configuration from a // models.DaemonConfigurationResponse
[ "CreateConfigFromAgentResponse", "creates", "a", "client", "configuration", "from", "a", "models", ".", "DaemonConfigurationResponse" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/client.go#L78-L80
162,323
cilium/cilium
pkg/k8s/client.go
CreateClient
func CreateClient(config *rest.Config) (*kubernetes.Clientset, error) { cs, err := kubernetes.NewForConfig(config) if err != nil { return nil, err } stop := make(chan struct{}) timeout := time.NewTimer(time.Minute) defer timeout.Stop() wait.Until(func() { // FIXME: Use config.String() when we rebase to latest go-client log.WithField("host", config.Host).Info("Establishing connection to apiserver") err = isConnReady(cs) if err == nil { close(stop) return } select { case <-timeout.C: log.WithError(err).WithField(logfields.IPAddr, config.Host).Error("Unable to contact k8s api-server") close(stop) default: } }, 5*time.Second, stop) if err == nil { log.Info("Connected to apiserver") } return cs, err }
go
func CreateClient(config *rest.Config) (*kubernetes.Clientset, error) { cs, err := kubernetes.NewForConfig(config) if err != nil { return nil, err } stop := make(chan struct{}) timeout := time.NewTimer(time.Minute) defer timeout.Stop() wait.Until(func() { // FIXME: Use config.String() when we rebase to latest go-client log.WithField("host", config.Host).Info("Establishing connection to apiserver") err = isConnReady(cs) if err == nil { close(stop) return } select { case <-timeout.C: log.WithError(err).WithField(logfields.IPAddr, config.Host).Error("Unable to contact k8s api-server") close(stop) default: } }, 5*time.Second, stop) if err == nil { log.Info("Connected to apiserver") } return cs, err }
[ "func", "CreateClient", "(", "config", "*", "rest", ".", "Config", ")", "(", "*", "kubernetes", ".", "Clientset", ",", "error", ")", "{", "cs", ",", "err", ":=", "kubernetes", ".", "NewForConfig", "(", "config", ")", "\n", "if", "err", "!=", "nil", "...
// CreateClient creates a new client to access the Kubernetes API
[ "CreateClient", "creates", "a", "new", "client", "to", "access", "the", "Kubernetes", "API" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/client.go#L89-L116
162,324
cilium/cilium
pkg/k8s/client.go
isConnReady
func isConnReady(c *kubernetes.Clientset) error { _, err := c.CoreV1().ComponentStatuses().Get("controller-manager", metav1.GetOptions{}) return err }
go
func isConnReady(c *kubernetes.Clientset) error { _, err := c.CoreV1().ComponentStatuses().Get("controller-manager", metav1.GetOptions{}) return err }
[ "func", "isConnReady", "(", "c", "*", "kubernetes", ".", "Clientset", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "CoreV1", "(", ")", ".", "ComponentStatuses", "(", ")", ".", "Get", "(", "\"", "\"", ",", "metav1", ".", "GetOptions", "{", "}...
// isConnReady returns the err for the controller-manager status
[ "isConnReady", "returns", "the", "err", "for", "the", "controller", "-", "manager", "status" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/client.go#L119-L122
162,325
cilium/cilium
pkg/maps/lbmap/bpfservice.go
getBackendsV2
func (b *bpfService) getBackendsV2() map[BackendAddrID]ServiceValue { b.mutex.RLock() defer b.mutex.RUnlock() backends := make(map[BackendAddrID]ServiceValue, len(b.backendsV2)) for addrID, backend := range b.backendsV2 { backends[addrID] = backend } return backends }
go
func (b *bpfService) getBackendsV2() map[BackendAddrID]ServiceValue { b.mutex.RLock() defer b.mutex.RUnlock() backends := make(map[BackendAddrID]ServiceValue, len(b.backendsV2)) for addrID, backend := range b.backendsV2 { backends[addrID] = backend } return backends }
[ "func", "(", "b", "*", "bpfService", ")", "getBackendsV2", "(", ")", "map", "[", "BackendAddrID", "]", "ServiceValue", "{", "b", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "b", ".", "mutex", ".", "RUnlock", "(", ")", "\n\n", "backends", ":=...
// getBackendsV2 makes a copy of backendsV2, so that they are safe to use // after the bpfService lock has been released.
[ "getBackendsV2", "makes", "a", "copy", "of", "backendsV2", "so", "that", "they", "are", "safe", "to", "use", "after", "the", "bpfService", "lock", "has", "been", "released", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/bpfservice.go#L166-L176
162,326
cilium/cilium
pkg/maps/lbmap/bpfservice.go
restoreService
func (l *lbmapCache) restoreService(svc loadbalancer.LBSVC, v2Exists bool) error { l.mutex.Lock() defer l.mutex.Unlock() serviceKey, serviceValues, err := LBSVC2ServiceKeynValue(svc) if err != nil { return err } frontendID := serviceKey.String() bpfSvc, ok := l.entries[frontendID] if !ok { bpfSvc = newBpfService(serviceKey) l.entries[frontendID] = bpfSvc } if option.Config.EnableLegacyServices { for index, backend := range serviceValues { b := &bpfBackend{ id: backend.BackendAddrID(), bpfValue: backend, } if _, ok := bpfSvc.uniqueBackends[backend.BackendAddrID()]; ok { b.isHole = true } else { bpfSvc.uniqueBackends[backend.BackendAddrID()] = backend bpfSvc.slaveSlotByBackendAddrID[backend.BackendAddrID()] = index + 1 } bpfSvc.backendsByMapIndex[index+1] = b } } if !option.Config.EnableLegacyServices || v2Exists { for _, backend := range serviceValues { addrID := backend.BackendAddrID() if _, found := bpfSvc.backendsV2[addrID]; !found { l.addBackendV2Locked(addrID) } bpfSvc.backendsV2[addrID] = backend } } return nil }
go
func (l *lbmapCache) restoreService(svc loadbalancer.LBSVC, v2Exists bool) error { l.mutex.Lock() defer l.mutex.Unlock() serviceKey, serviceValues, err := LBSVC2ServiceKeynValue(svc) if err != nil { return err } frontendID := serviceKey.String() bpfSvc, ok := l.entries[frontendID] if !ok { bpfSvc = newBpfService(serviceKey) l.entries[frontendID] = bpfSvc } if option.Config.EnableLegacyServices { for index, backend := range serviceValues { b := &bpfBackend{ id: backend.BackendAddrID(), bpfValue: backend, } if _, ok := bpfSvc.uniqueBackends[backend.BackendAddrID()]; ok { b.isHole = true } else { bpfSvc.uniqueBackends[backend.BackendAddrID()] = backend bpfSvc.slaveSlotByBackendAddrID[backend.BackendAddrID()] = index + 1 } bpfSvc.backendsByMapIndex[index+1] = b } } if !option.Config.EnableLegacyServices || v2Exists { for _, backend := range serviceValues { addrID := backend.BackendAddrID() if _, found := bpfSvc.backendsV2[addrID]; !found { l.addBackendV2Locked(addrID) } bpfSvc.backendsV2[addrID] = backend } } return nil }
[ "func", "(", "l", "*", "lbmapCache", ")", "restoreService", "(", "svc", "loadbalancer", ".", "LBSVC", ",", "v2Exists", "bool", ")", "error", "{", "l", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "mutex", ".", "Unlock", "(", ")", "...
// restoreService restores service cache of the given legacy and v2 service.
[ "restoreService", "restores", "service", "cache", "of", "the", "given", "legacy", "and", "v2", "service", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/bpfservice.go#L202-L247
162,327
cilium/cilium
pkg/maps/lbmap/bpfservice.go
prepareUpdate
func (l *lbmapCache) prepareUpdate(fe ServiceKey, backends []ServiceValue) ( *bpfService, map[loadbalancer.BackendID]ServiceValue, []loadbalancer.BackendID, error) { l.mutex.Lock() defer l.mutex.Unlock() frontendID := fe.String() bpfSvc, ok := l.entries[frontendID] if !ok { bpfSvc = newBpfService(fe) l.entries[frontendID] = bpfSvc } newBackendsMap := createBackendsMap(backends) toRemoveBackendIDs := []loadbalancer.BackendID{} toAddBackendIDs := map[loadbalancer.BackendID]ServiceValue{} // Step 1: Delete all backends that no longer exist. This will not // actually remove the backends but overwrite all slave slots that // point to the removed backend with the backend that has the least // duplicated slots. if option.Config.EnableLegacyServices { for addrID, b := range bpfSvc.uniqueBackends { if _, ok := newBackendsMap[addrID]; !ok { bpfSvc.deleteBackend(b) delete(bpfSvc.slaveSlotByBackendAddrID, addrID) } } } // Step 2: Delete all backends that no longer exist in the service v2. for addrID := range bpfSvc.backendsV2 { if _, ok := newBackendsMap[addrID]; !ok { isLastInstanceRemoved, err := l.delBackendV2Locked(addrID) if err != nil { return nil, nil, nil, err } if isLastInstanceRemoved { toRemoveBackendIDs = append(toRemoveBackendIDs, l.backendIDByAddrID[addrID]) delete(l.backendIDByAddrID, addrID) } delete(bpfSvc.backendsV2, addrID) } } if option.Config.EnableLegacyServices { // Step 3: Add all backends that don't exist in the legacy service yet. for _, b := range backends { if _, ok := bpfSvc.uniqueBackends[b.BackendAddrID()]; !ok { addrID := b.BackendAddrID() pos := bpfSvc.addBackend(b) bpfSvc.slaveSlotByBackendAddrID[addrID] = pos } } } // Step 4: Add all backends that don't exist in the service v2 yet. for _, b := range backends { addrID := b.BackendAddrID() if _, ok := bpfSvc.backendsV2[addrID]; !ok { bpfSvc.backendsV2[addrID] = b isNew := l.addBackendV2Locked(addrID) if isNew { toAddBackendIDs[l.backendIDByAddrID[addrID]] = b } } } return bpfSvc, toAddBackendIDs, toRemoveBackendIDs, nil }
go
func (l *lbmapCache) prepareUpdate(fe ServiceKey, backends []ServiceValue) ( *bpfService, map[loadbalancer.BackendID]ServiceValue, []loadbalancer.BackendID, error) { l.mutex.Lock() defer l.mutex.Unlock() frontendID := fe.String() bpfSvc, ok := l.entries[frontendID] if !ok { bpfSvc = newBpfService(fe) l.entries[frontendID] = bpfSvc } newBackendsMap := createBackendsMap(backends) toRemoveBackendIDs := []loadbalancer.BackendID{} toAddBackendIDs := map[loadbalancer.BackendID]ServiceValue{} // Step 1: Delete all backends that no longer exist. This will not // actually remove the backends but overwrite all slave slots that // point to the removed backend with the backend that has the least // duplicated slots. if option.Config.EnableLegacyServices { for addrID, b := range bpfSvc.uniqueBackends { if _, ok := newBackendsMap[addrID]; !ok { bpfSvc.deleteBackend(b) delete(bpfSvc.slaveSlotByBackendAddrID, addrID) } } } // Step 2: Delete all backends that no longer exist in the service v2. for addrID := range bpfSvc.backendsV2 { if _, ok := newBackendsMap[addrID]; !ok { isLastInstanceRemoved, err := l.delBackendV2Locked(addrID) if err != nil { return nil, nil, nil, err } if isLastInstanceRemoved { toRemoveBackendIDs = append(toRemoveBackendIDs, l.backendIDByAddrID[addrID]) delete(l.backendIDByAddrID, addrID) } delete(bpfSvc.backendsV2, addrID) } } if option.Config.EnableLegacyServices { // Step 3: Add all backends that don't exist in the legacy service yet. for _, b := range backends { if _, ok := bpfSvc.uniqueBackends[b.BackendAddrID()]; !ok { addrID := b.BackendAddrID() pos := bpfSvc.addBackend(b) bpfSvc.slaveSlotByBackendAddrID[addrID] = pos } } } // Step 4: Add all backends that don't exist in the service v2 yet. for _, b := range backends { addrID := b.BackendAddrID() if _, ok := bpfSvc.backendsV2[addrID]; !ok { bpfSvc.backendsV2[addrID] = b isNew := l.addBackendV2Locked(addrID) if isNew { toAddBackendIDs[l.backendIDByAddrID[addrID]] = b } } } return bpfSvc, toAddBackendIDs, toRemoveBackendIDs, nil }
[ "func", "(", "l", "*", "lbmapCache", ")", "prepareUpdate", "(", "fe", "ServiceKey", ",", "backends", "[", "]", "ServiceValue", ")", "(", "*", "bpfService", ",", "map", "[", "loadbalancer", ".", "BackendID", "]", "ServiceValue", ",", "[", "]", "loadbalancer...
// prepareUpdate prepares the caches to reflect the changes in the given svc. // The given backends should not contain a service value of a master service.
[ "prepareUpdate", "prepares", "the", "caches", "to", "reflect", "the", "changes", "in", "the", "given", "svc", ".", "The", "given", "backends", "should", "not", "contain", "a", "service", "value", "of", "a", "master", "service", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/bpfservice.go#L251-L320
162,328
cilium/cilium
pkg/maps/lbmap/bpfservice.go
addBackendV2Locked
func (l *lbmapCache) addBackendV2Locked(addrID BackendAddrID) bool { l.backendRefCount[addrID]++ return l.backendRefCount[addrID] == 1 }
go
func (l *lbmapCache) addBackendV2Locked(addrID BackendAddrID) bool { l.backendRefCount[addrID]++ return l.backendRefCount[addrID] == 1 }
[ "func", "(", "l", "*", "lbmapCache", ")", "addBackendV2Locked", "(", "addrID", "BackendAddrID", ")", "bool", "{", "l", ".", "backendRefCount", "[", "addrID", "]", "++", "\n", "return", "l", ".", "backendRefCount", "[", "addrID", "]", "==", "1", "\n", "}"...
// addBackendV2Locked increments a ref count for the given backend and returns // whether any instance of the backend existed before.
[ "addBackendV2Locked", "increments", "a", "ref", "count", "for", "the", "given", "backend", "and", "returns", "whether", "any", "instance", "of", "the", "backend", "existed", "before", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/bpfservice.go#L348-L351
162,329
cilium/cilium
pkg/maps/lbmap/bpfservice.go
delBackendV2Locked
func (l *lbmapCache) delBackendV2Locked(addrID BackendAddrID) (bool, error) { count, found := l.backendRefCount[addrID] if !found { return false, fmt.Errorf("backend %s not found", addrID) } if count == 1 { delete(l.backendRefCount, addrID) return true, nil } l.backendRefCount[addrID]-- return false, nil }
go
func (l *lbmapCache) delBackendV2Locked(addrID BackendAddrID) (bool, error) { count, found := l.backendRefCount[addrID] if !found { return false, fmt.Errorf("backend %s not found", addrID) } if count == 1 { delete(l.backendRefCount, addrID) return true, nil } l.backendRefCount[addrID]-- return false, nil }
[ "func", "(", "l", "*", "lbmapCache", ")", "delBackendV2Locked", "(", "addrID", "BackendAddrID", ")", "(", "bool", ",", "error", ")", "{", "count", ",", "found", ":=", "l", ".", "backendRefCount", "[", "addrID", "]", "\n", "if", "!", "found", "{", "retu...
// delBackendV2Locked decrements a ref count for the given backend aand returns // whether there are any instance of the backend left.
[ "delBackendV2Locked", "decrements", "a", "ref", "count", "for", "the", "given", "backend", "aand", "returns", "whether", "there", "are", "any", "instance", "of", "the", "backend", "left", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/bpfservice.go#L355-L368
162,330
cilium/cilium
pkg/maps/lbmap/bpfservice.go
removeServiceV2
func (l *lbmapCache) removeServiceV2(svcKey ServiceKeyV2) ([]loadbalancer.BackendID, int, error) { l.mutex.Lock() defer l.mutex.Unlock() frontendID := svcKey.String() bpfSvc, ok := l.entries[frontendID] if !ok { return nil, 0, fmt.Errorf("Service %s not found", frontendID) } backendsToRemove := []loadbalancer.BackendID{} count := len(bpfSvc.backendsV2) for addrID := range bpfSvc.backendsV2 { isLastInstance, err := l.delBackendV2Locked(addrID) if err != nil { return nil, 0, err } if isLastInstance { backendsToRemove = append(backendsToRemove, l.backendIDByAddrID[addrID]) delete(l.backendIDByAddrID, addrID) } } // FIXME(brb) uncomment the following line after we have removed the support for // legacy svc. //delete(l.entries, frontendID) return backendsToRemove, count, nil }
go
func (l *lbmapCache) removeServiceV2(svcKey ServiceKeyV2) ([]loadbalancer.BackendID, int, error) { l.mutex.Lock() defer l.mutex.Unlock() frontendID := svcKey.String() bpfSvc, ok := l.entries[frontendID] if !ok { return nil, 0, fmt.Errorf("Service %s not found", frontendID) } backendsToRemove := []loadbalancer.BackendID{} count := len(bpfSvc.backendsV2) for addrID := range bpfSvc.backendsV2 { isLastInstance, err := l.delBackendV2Locked(addrID) if err != nil { return nil, 0, err } if isLastInstance { backendsToRemove = append(backendsToRemove, l.backendIDByAddrID[addrID]) delete(l.backendIDByAddrID, addrID) } } // FIXME(brb) uncomment the following line after we have removed the support for // legacy svc. //delete(l.entries, frontendID) return backendsToRemove, count, nil }
[ "func", "(", "l", "*", "lbmapCache", ")", "removeServiceV2", "(", "svcKey", "ServiceKeyV2", ")", "(", "[", "]", "loadbalancer", ".", "BackendID", ",", "int", ",", "error", ")", "{", "l", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "l", ".", ...
// removeServiceV2 removes the service v2 from the cache.
[ "removeServiceV2", "removes", "the", "service", "v2", "from", "the", "cache", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/bpfservice.go#L404-L433
162,331
cilium/cilium
pkg/maps/lbmap/bpfservice.go
removeBackendsWithRefCountZero
func (l *lbmapCache) removeBackendsWithRefCountZero() map[BackendAddrID]loadbalancer.BackendID { l.mutex.Lock() defer l.mutex.Unlock() removed := make(map[BackendAddrID]loadbalancer.BackendID) for addrID, id := range l.backendIDByAddrID { if l.backendRefCount[addrID] == 0 { delete(l.backendIDByAddrID, addrID) removed[addrID] = id } } return removed }
go
func (l *lbmapCache) removeBackendsWithRefCountZero() map[BackendAddrID]loadbalancer.BackendID { l.mutex.Lock() defer l.mutex.Unlock() removed := make(map[BackendAddrID]loadbalancer.BackendID) for addrID, id := range l.backendIDByAddrID { if l.backendRefCount[addrID] == 0 { delete(l.backendIDByAddrID, addrID) removed[addrID] = id } } return removed }
[ "func", "(", "l", "*", "lbmapCache", ")", "removeBackendsWithRefCountZero", "(", ")", "map", "[", "BackendAddrID", "]", "loadbalancer", ".", "BackendID", "{", "l", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "mutex", ".", "Unlock", "(",...
// removeBackendsWithRefCountZero removes backends from the cache which are not // used by any service.
[ "removeBackendsWithRefCountZero", "removes", "backends", "from", "the", "cache", "which", "are", "not", "used", "by", "any", "service", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/lbmap/bpfservice.go#L437-L451
162,332
cilium/cilium
api/v1/server/restapi/policy/get_fqdn_cache_id_parameters.go
bindCidr
func (o *GetFqdnCacheIDParams) bindCidr(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: false // AllowEmptyValue: false if raw == "" { // empty values pass all other validations return nil } o.Cidr = &raw return nil }
go
func (o *GetFqdnCacheIDParams) bindCidr(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] } // Required: false // AllowEmptyValue: false if raw == "" { // empty values pass all other validations return nil } o.Cidr = &raw return nil }
[ "func", "(", "o", "*", "GetFqdnCacheIDParams", ")", "bindCidr", "(", "rawData", "[", "]", "string", ",", "hasKey", "bool", ",", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "raw", "string", "\n", "if", "len", "(", "rawData", ")", ">"...
// bindCidr binds and validates parameter Cidr from query.
[ "bindCidr", "binds", "and", "validates", "parameter", "Cidr", "from", "query", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/get_fqdn_cache_id_parameters.go#L94-L109
162,333
cilium/cilium
pkg/envoy/accesslog_server.go
StartAccessLogServer
func StartAccessLogServer(stateDir string, xdsServer *XDSServer, endpointInfoRegistry logger.EndpointInfoRegistry) { accessLogPath := getAccessLogPath(stateDir) // Create the access log listener os.Remove(accessLogPath) // Remove/Unlink the old unix domain socket, if any. accessLogListener, err := net.ListenUnix("unixpacket", &net.UnixAddr{Name: accessLogPath, Net: "unixpacket"}) if err != nil { log.WithError(err).Fatalf("Envoy: Failed to open access log listen socket at %s", accessLogPath) } accessLogListener.SetUnlinkOnClose(true) // Make the socket accessible by non-root Envoy proxies, e.g. running in // sidecar containers. if err = os.Chmod(accessLogPath, 0777); err != nil { log.WithError(err).Fatalf("Envoy: Failed to change mode of access log listen socket at %s", accessLogPath) } server := accessLogServer{ xdsServer: xdsServer, endpointInfoRegistry: endpointInfoRegistry, } go func() { for { // Each Envoy listener opens a new connection over the Unix domain socket. // Multiple worker threads serving the listener share that same connection uc, err := accessLogListener.AcceptUnix() if err != nil { // These errors are expected when we are closing down if strings.Contains(err.Error(), "closed network connection") || strings.Contains(err.Error(), "invalid argument") { break } log.WithError(err).Warn("Envoy: Failed to accept access log connection") continue } log.Info("Envoy: Accepted access log connection") // Serve this access log socket in a goroutine, so we can serve multiple // connections concurrently. go server.accessLogger(uc) } }() }
go
func StartAccessLogServer(stateDir string, xdsServer *XDSServer, endpointInfoRegistry logger.EndpointInfoRegistry) { accessLogPath := getAccessLogPath(stateDir) // Create the access log listener os.Remove(accessLogPath) // Remove/Unlink the old unix domain socket, if any. accessLogListener, err := net.ListenUnix("unixpacket", &net.UnixAddr{Name: accessLogPath, Net: "unixpacket"}) if err != nil { log.WithError(err).Fatalf("Envoy: Failed to open access log listen socket at %s", accessLogPath) } accessLogListener.SetUnlinkOnClose(true) // Make the socket accessible by non-root Envoy proxies, e.g. running in // sidecar containers. if err = os.Chmod(accessLogPath, 0777); err != nil { log.WithError(err).Fatalf("Envoy: Failed to change mode of access log listen socket at %s", accessLogPath) } server := accessLogServer{ xdsServer: xdsServer, endpointInfoRegistry: endpointInfoRegistry, } go func() { for { // Each Envoy listener opens a new connection over the Unix domain socket. // Multiple worker threads serving the listener share that same connection uc, err := accessLogListener.AcceptUnix() if err != nil { // These errors are expected when we are closing down if strings.Contains(err.Error(), "closed network connection") || strings.Contains(err.Error(), "invalid argument") { break } log.WithError(err).Warn("Envoy: Failed to accept access log connection") continue } log.Info("Envoy: Accepted access log connection") // Serve this access log socket in a goroutine, so we can serve multiple // connections concurrently. go server.accessLogger(uc) } }() }
[ "func", "StartAccessLogServer", "(", "stateDir", "string", ",", "xdsServer", "*", "XDSServer", ",", "endpointInfoRegistry", "logger", ".", "EndpointInfoRegistry", ")", "{", "accessLogPath", ":=", "getAccessLogPath", "(", "stateDir", ")", "\n\n", "// Create the access lo...
// StartAccessLogServer starts the access log server.
[ "StartAccessLogServer", "starts", "the", "access", "log", "server", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/accesslog_server.go#L45-L88
162,334
cilium/cilium
pkg/bpf/stats_linux.go
Duration
func (d *DumpStats) Duration() time.Duration { return d.Finished.Sub(d.Started) }
go
func (d *DumpStats) Duration() time.Duration { return d.Finished.Sub(d.Started) }
[ "func", "(", "d", "*", "DumpStats", ")", "Duration", "(", ")", "time", ".", "Duration", "{", "return", "d", ".", "Finished", ".", "Sub", "(", "d", ".", "Started", ")", "\n", "}" ]
// Duration returns the duration of the dump.
[ "Duration", "returns", "the", "duration", "of", "the", "dump", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/bpf/stats_linux.go#L74-L76
162,335
cilium/cilium
pkg/policy/api/selector.go
LabelSelectorString
func (n *EndpointSelector) LabelSelectorString() string { if n != nil && n.LabelSelector == nil { return "<all>" } return metav1.FormatLabelSelector(n.LabelSelector) }
go
func (n *EndpointSelector) LabelSelectorString() string { if n != nil && n.LabelSelector == nil { return "<all>" } return metav1.FormatLabelSelector(n.LabelSelector) }
[ "func", "(", "n", "*", "EndpointSelector", ")", "LabelSelectorString", "(", ")", "string", "{", "if", "n", "!=", "nil", "&&", "n", ".", "LabelSelector", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "metav1", ".", "FormatLabelSelecto...
// LabelSelectorString returns a user-friendly string representation of // EndpointSelector.
[ "LabelSelectorString", "returns", "a", "user", "-", "friendly", "string", "representation", "of", "EndpointSelector", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L46-L51
162,336
cilium/cilium
pkg/policy/api/selector.go
String
func (n EndpointSelector) String() string { j, _ := n.MarshalJSON() return string(j) }
go
func (n EndpointSelector) String() string { j, _ := n.MarshalJSON() return string(j) }
[ "func", "(", "n", "EndpointSelector", ")", "String", "(", ")", "string", "{", "j", ",", "_", ":=", "n", ".", "MarshalJSON", "(", ")", "\n", "return", "string", "(", "j", ")", "\n", "}" ]
// String returns a string representation of EndpointSelector.
[ "String", "returns", "a", "string", "representation", "of", "EndpointSelector", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L54-L57
162,337
cilium/cilium
pkg/policy/api/selector.go
UnmarshalJSON
func (n *EndpointSelector) UnmarshalJSON(b []byte) error { n.LabelSelector = &metav1.LabelSelector{} err := json.Unmarshal(b, n.LabelSelector) if err != nil { return err } if n.MatchLabels != nil { ml := map[string]string{} for k, v := range n.MatchLabels { ml[labels.GetExtendedKeyFrom(k)] = v } n.MatchLabels = ml } if n.MatchExpressions != nil { newMatchExpr := make([]metav1.LabelSelectorRequirement, len(n.MatchExpressions)) for i, v := range n.MatchExpressions { v.Key = labels.GetExtendedKeyFrom(v.Key) newMatchExpr[i] = v } n.MatchExpressions = newMatchExpr } n.requirements = labelSelectorToRequirements(n.LabelSelector) return nil }
go
func (n *EndpointSelector) UnmarshalJSON(b []byte) error { n.LabelSelector = &metav1.LabelSelector{} err := json.Unmarshal(b, n.LabelSelector) if err != nil { return err } if n.MatchLabels != nil { ml := map[string]string{} for k, v := range n.MatchLabels { ml[labels.GetExtendedKeyFrom(k)] = v } n.MatchLabels = ml } if n.MatchExpressions != nil { newMatchExpr := make([]metav1.LabelSelectorRequirement, len(n.MatchExpressions)) for i, v := range n.MatchExpressions { v.Key = labels.GetExtendedKeyFrom(v.Key) newMatchExpr[i] = v } n.MatchExpressions = newMatchExpr } n.requirements = labelSelectorToRequirements(n.LabelSelector) return nil }
[ "func", "(", "n", "*", "EndpointSelector", ")", "UnmarshalJSON", "(", "b", "[", "]", "byte", ")", "error", "{", "n", ".", "LabelSelector", "=", "&", "metav1", ".", "LabelSelector", "{", "}", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",",...
// UnmarshalJSON unmarshals the endpoint selector from the byte array.
[ "UnmarshalJSON", "unmarshals", "the", "endpoint", "selector", "from", "the", "byte", "array", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L60-L83
162,338
cilium/cilium
pkg/policy/api/selector.go
MarshalJSON
func (n EndpointSelector) MarshalJSON() ([]byte, error) { ls := metav1.LabelSelector{} if n.LabelSelector == nil { return json.Marshal(ls) } if n.MatchLabels != nil { newLabels := map[string]string{} for k, v := range n.MatchLabels { newLabels[labels.GetCiliumKeyFrom(k)] = v } ls.MatchLabels = newLabels } if n.MatchExpressions != nil { newMatchExpr := make([]metav1.LabelSelectorRequirement, len(n.MatchExpressions)) for i, v := range n.MatchExpressions { v.Key = labels.GetCiliumKeyFrom(v.Key) newMatchExpr[i] = v } ls.MatchExpressions = newMatchExpr } return json.Marshal(ls) }
go
func (n EndpointSelector) MarshalJSON() ([]byte, error) { ls := metav1.LabelSelector{} if n.LabelSelector == nil { return json.Marshal(ls) } if n.MatchLabels != nil { newLabels := map[string]string{} for k, v := range n.MatchLabels { newLabels[labels.GetCiliumKeyFrom(k)] = v } ls.MatchLabels = newLabels } if n.MatchExpressions != nil { newMatchExpr := make([]metav1.LabelSelectorRequirement, len(n.MatchExpressions)) for i, v := range n.MatchExpressions { v.Key = labels.GetCiliumKeyFrom(v.Key) newMatchExpr[i] = v } ls.MatchExpressions = newMatchExpr } return json.Marshal(ls) }
[ "func", "(", "n", "EndpointSelector", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "ls", ":=", "metav1", ".", "LabelSelector", "{", "}", "\n\n", "if", "n", ".", "LabelSelector", "==", "nil", "{", "return", "json", ".",...
// MarshalJSON returns a JSON representation of the byte array.
[ "MarshalJSON", "returns", "a", "JSON", "representation", "of", "the", "byte", "array", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L86-L109
162,339
cilium/cilium
pkg/policy/api/selector.go
HasKeyPrefix
func (n EndpointSelector) HasKeyPrefix(prefix string) bool { for k := range n.MatchLabels { if strings.HasPrefix(k, prefix) { return true } } for _, v := range n.MatchExpressions { if strings.HasPrefix(v.Key, prefix) { return true } } return false }
go
func (n EndpointSelector) HasKeyPrefix(prefix string) bool { for k := range n.MatchLabels { if strings.HasPrefix(k, prefix) { return true } } for _, v := range n.MatchExpressions { if strings.HasPrefix(v.Key, prefix) { return true } } return false }
[ "func", "(", "n", "EndpointSelector", ")", "HasKeyPrefix", "(", "prefix", "string", ")", "bool", "{", "for", "k", ":=", "range", "n", ".", "MatchLabels", "{", "if", "strings", ".", "HasPrefix", "(", "k", ",", "prefix", ")", "{", "return", "true", "\n",...
// HasKeyPrefix checks if the endpoint selector contains the given key prefix in // its MatchLabels map and MatchExpressions slice.
[ "HasKeyPrefix", "checks", "if", "the", "endpoint", "selector", "contains", "the", "given", "key", "prefix", "in", "its", "MatchLabels", "map", "and", "MatchExpressions", "slice", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L113-L125
162,340
cilium/cilium
pkg/policy/api/selector.go
HasKey
func (n EndpointSelector) HasKey(key string) bool { if _, ok := n.MatchLabels[key]; ok { return true } for _, v := range n.MatchExpressions { if v.Key == key { return true } } return false }
go
func (n EndpointSelector) HasKey(key string) bool { if _, ok := n.MatchLabels[key]; ok { return true } for _, v := range n.MatchExpressions { if v.Key == key { return true } } return false }
[ "func", "(", "n", "EndpointSelector", ")", "HasKey", "(", "key", "string", ")", "bool", "{", "if", "_", ",", "ok", ":=", "n", ".", "MatchLabels", "[", "key", "]", ";", "ok", "{", "return", "true", "\n", "}", "\n", "for", "_", ",", "v", ":=", "r...
// HasKey checks if the endpoint selector contains the given key in // its MatchLabels map or in its MatchExpressions slice.
[ "HasKey", "checks", "if", "the", "endpoint", "selector", "contains", "the", "given", "key", "in", "its", "MatchLabels", "map", "or", "in", "its", "MatchExpressions", "slice", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L129-L139
162,341
cilium/cilium
pkg/policy/api/selector.go
GetMatch
func (n EndpointSelector) GetMatch(key string) ([]string, bool) { if value, ok := n.MatchLabels[key]; ok { return []string{value}, true } for _, v := range n.MatchExpressions { if v.Key == key && v.Operator == metav1.LabelSelectorOpIn { return v.Values, true } } return nil, false }
go
func (n EndpointSelector) GetMatch(key string) ([]string, bool) { if value, ok := n.MatchLabels[key]; ok { return []string{value}, true } for _, v := range n.MatchExpressions { if v.Key == key && v.Operator == metav1.LabelSelectorOpIn { return v.Values, true } } return nil, false }
[ "func", "(", "n", "EndpointSelector", ")", "GetMatch", "(", "key", "string", ")", "(", "[", "]", "string", ",", "bool", ")", "{", "if", "value", ",", "ok", ":=", "n", ".", "MatchLabels", "[", "key", "]", ";", "ok", "{", "return", "[", "]", "strin...
// GetMatch checks for a match on the specified key, and returns the value that // the key must match, and true. If a match cannot be found, returns nil, false.
[ "GetMatch", "checks", "for", "a", "match", "on", "the", "specified", "key", "and", "returns", "the", "value", "that", "the", "key", "must", "match", "and", "true", ".", "If", "a", "match", "cannot", "be", "found", "returns", "nil", "false", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L143-L153
162,342
cilium/cilium
pkg/policy/api/selector.go
NewESFromLabels
func NewESFromLabels(lbls ...labels.Label) EndpointSelector { ml := map[string]string{} for _, lbl := range lbls { ml[lbl.GetExtendedKey()] = lbl.Value } return NewESFromMatchRequirements(ml, nil) }
go
func NewESFromLabels(lbls ...labels.Label) EndpointSelector { ml := map[string]string{} for _, lbl := range lbls { ml[lbl.GetExtendedKey()] = lbl.Value } return NewESFromMatchRequirements(ml, nil) }
[ "func", "NewESFromLabels", "(", "lbls", "...", "labels", ".", "Label", ")", "EndpointSelector", "{", "ml", ":=", "map", "[", "string", "]", "string", "{", "}", "\n", "for", "_", ",", "lbl", ":=", "range", "lbls", "{", "ml", "[", "lbl", ".", "GetExten...
// NewESFromLabels creates a new endpoint selector from the given labels.
[ "NewESFromLabels", "creates", "a", "new", "endpoint", "selector", "from", "the", "given", "labels", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L179-L186
162,343
cilium/cilium
pkg/policy/api/selector.go
newReservedEndpointSelector
func newReservedEndpointSelector(ID string) EndpointSelector { reservedLabels := labels.NewLabel(ID, "", labels.LabelSourceReserved) return NewESFromLabels(reservedLabels) }
go
func newReservedEndpointSelector(ID string) EndpointSelector { reservedLabels := labels.NewLabel(ID, "", labels.LabelSourceReserved) return NewESFromLabels(reservedLabels) }
[ "func", "newReservedEndpointSelector", "(", "ID", "string", ")", "EndpointSelector", "{", "reservedLabels", ":=", "labels", ".", "NewLabel", "(", "ID", ",", "\"", "\"", ",", "labels", ".", "LabelSourceReserved", ")", "\n", "return", "NewESFromLabels", "(", "rese...
// newReservedEndpointSelector returns a selector that matches on all // endpoints with the specified reserved label.
[ "newReservedEndpointSelector", "returns", "a", "selector", "that", "matches", "on", "all", "endpoints", "with", "the", "specified", "reserved", "label", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L216-L219
162,344
cilium/cilium
pkg/policy/api/selector.go
NewESFromK8sLabelSelector
func NewESFromK8sLabelSelector(srcPrefix string, lss ...*metav1.LabelSelector) EndpointSelector { var ( matchLabels map[string]string matchExpressions []metav1.LabelSelectorRequirement ) for _, ls := range lss { if ls == nil { continue } if ls.MatchLabels != nil { if matchLabels == nil { matchLabels = map[string]string{} } for k, v := range ls.MatchLabels { matchLabels[srcPrefix+k] = v } } if ls.MatchExpressions != nil { if matchExpressions == nil { matchExpressions = make([]metav1.LabelSelectorRequirement, 0, len(ls.MatchExpressions)) } for _, v := range ls.MatchExpressions { v.Key = srcPrefix + v.Key matchExpressions = append(matchExpressions, v) } } } return NewESFromMatchRequirements(matchLabels, matchExpressions) }
go
func NewESFromK8sLabelSelector(srcPrefix string, lss ...*metav1.LabelSelector) EndpointSelector { var ( matchLabels map[string]string matchExpressions []metav1.LabelSelectorRequirement ) for _, ls := range lss { if ls == nil { continue } if ls.MatchLabels != nil { if matchLabels == nil { matchLabels = map[string]string{} } for k, v := range ls.MatchLabels { matchLabels[srcPrefix+k] = v } } if ls.MatchExpressions != nil { if matchExpressions == nil { matchExpressions = make([]metav1.LabelSelectorRequirement, 0, len(ls.MatchExpressions)) } for _, v := range ls.MatchExpressions { v.Key = srcPrefix + v.Key matchExpressions = append(matchExpressions, v) } } } return NewESFromMatchRequirements(matchLabels, matchExpressions) }
[ "func", "NewESFromK8sLabelSelector", "(", "srcPrefix", "string", ",", "lss", "...", "*", "metav1", ".", "LabelSelector", ")", "EndpointSelector", "{", "var", "(", "matchLabels", "map", "[", "string", "]", "string", "\n", "matchExpressions", "[", "]", "metav1", ...
// NewESFromK8sLabelSelector returns a new endpoint selector from the label // where it the given srcPrefix will be encoded in the label's keys.
[ "NewESFromK8sLabelSelector", "returns", "a", "new", "endpoint", "selector", "from", "the", "label", "where", "it", "the", "given", "srcPrefix", "will", "be", "encoded", "in", "the", "label", "s", "keys", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L236-L264
162,345
cilium/cilium
pkg/policy/api/selector.go
AddMatch
func (n *EndpointSelector) AddMatch(key, value string) { if n.MatchLabels == nil { n.MatchLabels = map[string]string{} } n.MatchLabels[key] = value n.requirements = labelSelectorToRequirements(n.LabelSelector) }
go
func (n *EndpointSelector) AddMatch(key, value string) { if n.MatchLabels == nil { n.MatchLabels = map[string]string{} } n.MatchLabels[key] = value n.requirements = labelSelectorToRequirements(n.LabelSelector) }
[ "func", "(", "n", "*", "EndpointSelector", ")", "AddMatch", "(", "key", ",", "value", "string", ")", "{", "if", "n", ".", "MatchLabels", "==", "nil", "{", "n", ".", "MatchLabels", "=", "map", "[", "string", "]", "string", "{", "}", "\n", "}", "\n",...
// AddMatch adds a match for 'key' == 'value' to the endpoint selector.
[ "AddMatch", "adds", "a", "match", "for", "key", "==", "value", "to", "the", "endpoint", "selector", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L267-L273
162,346
cilium/cilium
pkg/policy/api/selector.go
Matches
func (n *EndpointSelector) Matches(lblsToMatch k8sLbls.Labels) bool { // Try to update cached requirements for this EndpointSelector if possible. if n.requirements == nil { n.requirements = labelSelectorToRequirements(n.LabelSelector) // Nil indicates that requirements failed validation in some way, // so we cannot parse the labels for matching purposes; thus, we cannot // match if labels cannot be parsed, so return false. if n.requirements == nil { return false } } for k := range n.MatchLabels { if k == labels.LabelSourceReservedKeyPrefix+labels.IDNameAll { return true } } for _, req := range *n.requirements { if !req.Matches(lblsToMatch) { return false } } return true }
go
func (n *EndpointSelector) Matches(lblsToMatch k8sLbls.Labels) bool { // Try to update cached requirements for this EndpointSelector if possible. if n.requirements == nil { n.requirements = labelSelectorToRequirements(n.LabelSelector) // Nil indicates that requirements failed validation in some way, // so we cannot parse the labels for matching purposes; thus, we cannot // match if labels cannot be parsed, so return false. if n.requirements == nil { return false } } for k := range n.MatchLabels { if k == labels.LabelSourceReservedKeyPrefix+labels.IDNameAll { return true } } for _, req := range *n.requirements { if !req.Matches(lblsToMatch) { return false } } return true }
[ "func", "(", "n", "*", "EndpointSelector", ")", "Matches", "(", "lblsToMatch", "k8sLbls", ".", "Labels", ")", "bool", "{", "// Try to update cached requirements for this EndpointSelector if possible.", "if", "n", ".", "requirements", "==", "nil", "{", "n", ".", "req...
// Matches returns true if the endpoint selector Matches the `lblsToMatch`. // Returns always true if the endpoint selector contains the reserved label for // "all".
[ "Matches", "returns", "true", "if", "the", "endpoint", "selector", "Matches", "the", "lblsToMatch", ".", "Returns", "always", "true", "if", "the", "endpoint", "selector", "contains", "the", "reserved", "label", "for", "all", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L278-L303
162,347
cilium/cilium
pkg/policy/api/selector.go
IsWildcard
func (n *EndpointSelector) IsWildcard() bool { return n.LabelSelector != nil && len(n.LabelSelector.MatchLabels)+len(n.LabelSelector.MatchExpressions) == 0 }
go
func (n *EndpointSelector) IsWildcard() bool { return n.LabelSelector != nil && len(n.LabelSelector.MatchLabels)+len(n.LabelSelector.MatchExpressions) == 0 }
[ "func", "(", "n", "*", "EndpointSelector", ")", "IsWildcard", "(", ")", "bool", "{", "return", "n", ".", "LabelSelector", "!=", "nil", "&&", "len", "(", "n", ".", "LabelSelector", ".", "MatchLabels", ")", "+", "len", "(", "n", ".", "LabelSelector", "."...
// IsWildcard returns true if the endpoint selector selects all endpoints.
[ "IsWildcard", "returns", "true", "if", "the", "endpoint", "selector", "selects", "all", "endpoints", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L306-L309
162,348
cilium/cilium
pkg/policy/api/selector.go
ConvertToLabelSelectorRequirementSlice
func (n *EndpointSelector) ConvertToLabelSelectorRequirementSlice() []metav1.LabelSelectorRequirement { requirements := make([]metav1.LabelSelectorRequirement, 0, len(n.MatchExpressions)+len(n.MatchLabels)) // Append already existing match expressions. requirements = append(requirements, n.MatchExpressions...) // Convert each MatchLables to LabelSelectorRequirement. for key, value := range n.MatchLabels { requirementFromMatchLabels := metav1.LabelSelectorRequirement{ Key: key, Operator: metav1.LabelSelectorOpIn, Values: []string{value}, } requirements = append(requirements, requirementFromMatchLabels) } return requirements }
go
func (n *EndpointSelector) ConvertToLabelSelectorRequirementSlice() []metav1.LabelSelectorRequirement { requirements := make([]metav1.LabelSelectorRequirement, 0, len(n.MatchExpressions)+len(n.MatchLabels)) // Append already existing match expressions. requirements = append(requirements, n.MatchExpressions...) // Convert each MatchLables to LabelSelectorRequirement. for key, value := range n.MatchLabels { requirementFromMatchLabels := metav1.LabelSelectorRequirement{ Key: key, Operator: metav1.LabelSelectorOpIn, Values: []string{value}, } requirements = append(requirements, requirementFromMatchLabels) } return requirements }
[ "func", "(", "n", "*", "EndpointSelector", ")", "ConvertToLabelSelectorRequirementSlice", "(", ")", "[", "]", "metav1", ".", "LabelSelectorRequirement", "{", "requirements", ":=", "make", "(", "[", "]", "metav1", ".", "LabelSelectorRequirement", ",", "0", ",", "...
// ConvertToLabelSelectorRequirementSlice converts the MatchLabels and // MatchExpressions within the specified EndpointSelector into a list of // LabelSelectorRequirements.
[ "ConvertToLabelSelectorRequirementSlice", "converts", "the", "MatchLabels", "and", "MatchExpressions", "within", "the", "specified", "EndpointSelector", "into", "a", "list", "of", "LabelSelectorRequirements", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L314-L328
162,349
cilium/cilium
pkg/policy/api/selector.go
sanitize
func (n *EndpointSelector) sanitize() error { errList := validation.ValidateLabelSelector(n.LabelSelector, nil) if len(errList) > 0 { return fmt.Errorf("invalid label selector: %s", errList.ToAggregate().Error()) } return nil }
go
func (n *EndpointSelector) sanitize() error { errList := validation.ValidateLabelSelector(n.LabelSelector, nil) if len(errList) > 0 { return fmt.Errorf("invalid label selector: %s", errList.ToAggregate().Error()) } return nil }
[ "func", "(", "n", "*", "EndpointSelector", ")", "sanitize", "(", ")", "error", "{", "errList", ":=", "validation", ".", "ValidateLabelSelector", "(", "n", ".", "LabelSelector", ",", "nil", ")", "\n", "if", "len", "(", "errList", ")", ">", "0", "{", "re...
// sanitize returns an error if the EndpointSelector's LabelSelector is invalid.
[ "sanitize", "returns", "an", "error", "if", "the", "EndpointSelector", "s", "LabelSelector", "is", "invalid", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L331-L337
162,350
cilium/cilium
pkg/policy/api/selector.go
Matches
func (s EndpointSelectorSlice) Matches(ctx labels.LabelArray) bool { for _, selector := range s { if selector.Matches(ctx) { return true } } return false }
go
func (s EndpointSelectorSlice) Matches(ctx labels.LabelArray) bool { for _, selector := range s { if selector.Matches(ctx) { return true } } return false }
[ "func", "(", "s", "EndpointSelectorSlice", ")", "Matches", "(", "ctx", "labels", ".", "LabelArray", ")", "bool", "{", "for", "_", ",", "selector", ":=", "range", "s", "{", "if", "selector", ".", "Matches", "(", "ctx", ")", "{", "return", "true", "\n", ...
// Matches returns true if any of the EndpointSelectors in the slice match the // provided labels
[ "Matches", "returns", "true", "if", "any", "of", "the", "EndpointSelectors", "in", "the", "slice", "match", "the", "provided", "labels" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L354-L362
162,351
cilium/cilium
pkg/policy/api/selector.go
SelectsAllEndpoints
func (s EndpointSelectorSlice) SelectsAllEndpoints() bool { for _, selector := range s { if selector.IsWildcard() { return true } } return false }
go
func (s EndpointSelectorSlice) SelectsAllEndpoints() bool { for _, selector := range s { if selector.IsWildcard() { return true } } return false }
[ "func", "(", "s", "EndpointSelectorSlice", ")", "SelectsAllEndpoints", "(", ")", "bool", "{", "for", "_", ",", "selector", ":=", "range", "s", "{", "if", "selector", ".", "IsWildcard", "(", ")", "{", "return", "true", "\n", "}", "\n", "}", "\n", "retur...
// SelectsAllEndpoints returns whether the EndpointSelectorSlice selects all // endpoints, which is true if the wildcard endpoint selector is present in the // slice.
[ "SelectsAllEndpoints", "returns", "whether", "the", "EndpointSelectorSlice", "selects", "all", "endpoints", "which", "is", "true", "if", "the", "wildcard", "endpoint", "selector", "is", "present", "in", "the", "slice", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/selector.go#L367-L374
162,352
cilium/cilium
api/v1/server/restapi/daemon/get_map_name.go
NewGetMapName
func NewGetMapName(ctx *middleware.Context, handler GetMapNameHandler) *GetMapName { return &GetMapName{Context: ctx, Handler: handler} }
go
func NewGetMapName(ctx *middleware.Context, handler GetMapNameHandler) *GetMapName { return &GetMapName{Context: ctx, Handler: handler} }
[ "func", "NewGetMapName", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "GetMapNameHandler", ")", "*", "GetMapName", "{", "return", "&", "GetMapName", "{", "Context", ":", "ctx", ",", "Handler", ":", "handler", "}", "\n", "}" ]
// NewGetMapName creates a new http.Handler for the get map name operation
[ "NewGetMapName", "creates", "a", "new", "http", ".", "Handler", "for", "the", "get", "map", "name", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/daemon/get_map_name.go#L28-L30
162,353
cilium/cilium
pkg/completion/completion.go
NewWaitGroup
func NewWaitGroup(ctx context.Context) *WaitGroup { ctx2, cancel := context.WithCancel(ctx) return &WaitGroup{ctx: ctx2, cancel: cancel} }
go
func NewWaitGroup(ctx context.Context) *WaitGroup { ctx2, cancel := context.WithCancel(ctx) return &WaitGroup{ctx: ctx2, cancel: cancel} }
[ "func", "NewWaitGroup", "(", "ctx", "context", ".", "Context", ")", "*", "WaitGroup", "{", "ctx2", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "ctx", ")", "\n", "return", "&", "WaitGroup", "{", "ctx", ":", "ctx2", ",", "cancel", ":", "cance...
// NewWaitGroup returns a new WaitGroup using the given context.
[ "NewWaitGroup", "returns", "a", "new", "WaitGroup", "using", "the", "given", "context", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/completion/completion.go#L41-L44
162,354
cilium/cilium
pkg/completion/completion.go
Wait
func (wg *WaitGroup) Wait() error { wg.counterLocker.Lock() defer wg.counterLocker.Unlock() var err error Loop: for i, comp := range wg.pendingCompletions { select { case <-comp.Completed(): err = updateError(err, comp.Err()) // Keep the most severe error value we encounter continue Loop case <-wg.ctx.Done(): // Complete the remaining completions (if any) to make sure their completed // channels are closed. for _, comp := range wg.pendingCompletions[i:] { // 'comp' may have already completed on a different error compErr := comp.Complete(wg.ctx.Err()) err = updateError(err, compErr) // Keep the most severe error value we encounter } break Loop } } wg.pendingCompletions = nil return err }
go
func (wg *WaitGroup) Wait() error { wg.counterLocker.Lock() defer wg.counterLocker.Unlock() var err error Loop: for i, comp := range wg.pendingCompletions { select { case <-comp.Completed(): err = updateError(err, comp.Err()) // Keep the most severe error value we encounter continue Loop case <-wg.ctx.Done(): // Complete the remaining completions (if any) to make sure their completed // channels are closed. for _, comp := range wg.pendingCompletions[i:] { // 'comp' may have already completed on a different error compErr := comp.Complete(wg.ctx.Err()) err = updateError(err, compErr) // Keep the most severe error value we encounter } break Loop } } wg.pendingCompletions = nil return err }
[ "func", "(", "wg", "*", "WaitGroup", ")", "Wait", "(", ")", "error", "{", "wg", ".", "counterLocker", ".", "Lock", "(", ")", "\n", "defer", "wg", ".", "counterLocker", ".", "Unlock", "(", ")", "\n\n", "var", "err", "error", "\n", "Loop", ":", "for"...
// Wait blocks until all completions added by calling AddCompletion are // completed, or the context is canceled, whichever happens first. // Returns the context's error if it is cancelled, nil otherwise. // No callbacks of the completions in this wait group will be called after // this returns. // Returns the error value of one of the completions, if available, or the // error value of the Context otherwise.
[ "Wait", "blocks", "until", "all", "completions", "added", "by", "calling", "AddCompletion", "are", "completed", "or", "the", "context", "is", "canceled", "whichever", "happens", "first", ".", "Returns", "the", "context", "s", "error", "if", "it", "is", "cancel...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/completion/completion.go#L97-L121
162,355
cilium/cilium
pkg/completion/completion.go
Err
func (c *Completion) Err() error { c.lock.Lock() defer c.lock.Unlock() return c.err }
go
func (c *Completion) Err() error { c.lock.Lock() defer c.lock.Unlock() return c.err }
[ "func", "(", "c", "*", "Completion", ")", "Err", "(", ")", "error", "{", "c", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "lock", ".", "Unlock", "(", ")", "\n", "return", "c", ".", "err", "\n", "}" ]
// Err returns a non-nil error if the completion ended in error
[ "Err", "returns", "a", "non", "-", "nil", "error", "if", "the", "completion", "ended", "in", "error" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/completion/completion.go#L144-L148
162,356
cilium/cilium
pkg/completion/completion.go
Complete
func (c *Completion) Complete(err error) error { c.lock.Lock() select { case <-c.completed: err = c.err // return the error 'c' completed with default: c.err = err if c.callback != nil { // We must call the callbacks synchronously to guarantee // that they are actually called before Wait() returns. c.callback(err) } // Cancel the WaitGroup on failure if err != nil && c.cancel != nil { c.cancel() } close(c.completed) } c.lock.Unlock() return err }
go
func (c *Completion) Complete(err error) error { c.lock.Lock() select { case <-c.completed: err = c.err // return the error 'c' completed with default: c.err = err if c.callback != nil { // We must call the callbacks synchronously to guarantee // that they are actually called before Wait() returns. c.callback(err) } // Cancel the WaitGroup on failure if err != nil && c.cancel != nil { c.cancel() } close(c.completed) } c.lock.Unlock() return err }
[ "func", "(", "c", "*", "Completion", ")", "Complete", "(", "err", "error", ")", "error", "{", "c", ".", "lock", ".", "Lock", "(", ")", "\n", "select", "{", "case", "<-", "c", ".", "completed", ":", "err", "=", "c", ".", "err", "// return the error ...
// Complete notifies of the completion of the asynchronous computation. // Idempotent. // If the operation completed successfully 'err' is passed as nil. // Returns the error state the completion completed with, which is // gnerally different from 'err' if already completed.
[ "Complete", "notifies", "of", "the", "completion", "of", "the", "asynchronous", "computation", ".", "Idempotent", ".", "If", "the", "operation", "completed", "successfully", "err", "is", "passed", "as", "nil", ".", "Returns", "the", "error", "state", "the", "c...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/completion/completion.go#L155-L175
162,357
cilium/cilium
api/v1/server/restapi/policy/get_identity_responses.go
WithPayload
func (o *GetIdentityOK) WithPayload(payload []*models.Identity) *GetIdentityOK { o.Payload = payload return o }
go
func (o *GetIdentityOK) WithPayload(payload []*models.Identity) *GetIdentityOK { o.Payload = payload return o }
[ "func", "(", "o", "*", "GetIdentityOK", ")", "WithPayload", "(", "payload", "[", "]", "*", "models", ".", "Identity", ")", "*", "GetIdentityOK", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the get identity o k response
[ "WithPayload", "adds", "the", "payload", "to", "the", "get", "identity", "o", "k", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/get_identity_responses.go#L38-L41
162,358
cilium/cilium
api/v1/server/restapi/policy/get_identity_responses.go
WithPayload
func (o *GetIdentityUnreachable) WithPayload(payload models.Error) *GetIdentityUnreachable { o.Payload = payload return o }
go
func (o *GetIdentityUnreachable) WithPayload(payload models.Error) *GetIdentityUnreachable { o.Payload = payload return o }
[ "func", "(", "o", "*", "GetIdentityUnreachable", ")", "WithPayload", "(", "payload", "models", ".", "Error", ")", "*", "GetIdentityUnreachable", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the get identity unreachable response
[ "WithPayload", "adds", "the", "payload", "to", "the", "get", "identity", "unreachable", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/get_identity_responses.go#L109-L112
162,359
cilium/cilium
api/v1/server/restapi/policy/get_identity_responses.go
WithPayload
func (o *GetIdentityInvalidStorageFormat) WithPayload(payload models.Error) *GetIdentityInvalidStorageFormat { o.Payload = payload return o }
go
func (o *GetIdentityInvalidStorageFormat) WithPayload(payload models.Error) *GetIdentityInvalidStorageFormat { o.Payload = payload return o }
[ "func", "(", "o", "*", "GetIdentityInvalidStorageFormat", ")", "WithPayload", "(", "payload", "models", ".", "Error", ")", "*", "GetIdentityInvalidStorageFormat", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the get identity invalid storage format response
[ "WithPayload", "adds", "the", "payload", "to", "the", "get", "identity", "invalid", "storage", "format", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/get_identity_responses.go#L151-L154
162,360
cilium/cilium
api/v1/models/trace_selector.go
Validate
func (m *TraceSelector) Validate(formats strfmt.Registry) error { var res []error if err := m.validateFrom(formats); err != nil { res = append(res, err) } if err := m.validateTo(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *TraceSelector) Validate(formats strfmt.Registry) error { var res []error if err := m.validateFrom(formats); err != nil { res = append(res, err) } if err := m.validateTo(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "TraceSelector", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateFrom", "(", "formats", ")", ";", "err", "!=", "nil",...
// Validate validates this trace selector
[ "Validate", "validates", "this", "trace", "selector" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/trace_selector.go#L31-L46
162,361
cilium/cilium
proxylib/r2d2/r2d2parser.go
ruleParser
func ruleParser(rule *cilium.PortNetworkPolicyRule) []proxylib.L7NetworkPolicyRule { l7Rules := rule.GetL7Rules() var rules []proxylib.L7NetworkPolicyRule if l7Rules == nil { return rules } for _, l7Rule := range l7Rules.GetL7Rules() { var rr r2d2Rule for k, v := range l7Rule.Rule { switch k { case "cmd": rr.cmdExact = v case "file": if v != "" { rr.fileRegexCompiled = regexp.MustCompile(v) } default: proxylib.ParseError(fmt.Sprintf("Unsupported key: %s", k), rule) } } if rr.cmdExact != "" && rr.cmdExact != "READ" && rr.cmdExact != "WRITE" && rr.cmdExact != "HALT" && rr.cmdExact != "RESET" { proxylib.ParseError(fmt.Sprintf("Unable to parse L7 r2d2 rule with invalid cmd: '%s'", rr.cmdExact), rule) } if (rr.fileRegexCompiled != nil) && !(rr.cmdExact == "" || rr.cmdExact == "READ" || rr.cmdExact == "WRITE") { proxylib.ParseError(fmt.Sprintf("Unable to parse L7 r2d2 rule, cmd '%s' is not compatible with 'file'", rr.cmdExact), rule) } regexStr := "" if rr.fileRegexCompiled != nil { regexStr = rr.fileRegexCompiled.String() } log.Infof("Parsed rule '%s' '%s'", rr.cmdExact, regexStr) rules = append(rules, &rr) } return rules }
go
func ruleParser(rule *cilium.PortNetworkPolicyRule) []proxylib.L7NetworkPolicyRule { l7Rules := rule.GetL7Rules() var rules []proxylib.L7NetworkPolicyRule if l7Rules == nil { return rules } for _, l7Rule := range l7Rules.GetL7Rules() { var rr r2d2Rule for k, v := range l7Rule.Rule { switch k { case "cmd": rr.cmdExact = v case "file": if v != "" { rr.fileRegexCompiled = regexp.MustCompile(v) } default: proxylib.ParseError(fmt.Sprintf("Unsupported key: %s", k), rule) } } if rr.cmdExact != "" && rr.cmdExact != "READ" && rr.cmdExact != "WRITE" && rr.cmdExact != "HALT" && rr.cmdExact != "RESET" { proxylib.ParseError(fmt.Sprintf("Unable to parse L7 r2d2 rule with invalid cmd: '%s'", rr.cmdExact), rule) } if (rr.fileRegexCompiled != nil) && !(rr.cmdExact == "" || rr.cmdExact == "READ" || rr.cmdExact == "WRITE") { proxylib.ParseError(fmt.Sprintf("Unable to parse L7 r2d2 rule, cmd '%s' is not compatible with 'file'", rr.cmdExact), rule) } regexStr := "" if rr.fileRegexCompiled != nil { regexStr = rr.fileRegexCompiled.String() } log.Infof("Parsed rule '%s' '%s'", rr.cmdExact, regexStr) rules = append(rules, &rr) } return rules }
[ "func", "ruleParser", "(", "rule", "*", "cilium", ".", "PortNetworkPolicyRule", ")", "[", "]", "proxylib", ".", "L7NetworkPolicyRule", "{", "l7Rules", ":=", "rule", ".", "GetL7Rules", "(", ")", "\n", "var", "rules", "[", "]", "proxylib", ".", "L7NetworkPolic...
// ruleParser parses protobuf L7 rules to enforcement objects // May panic
[ "ruleParser", "parses", "protobuf", "L7", "rules", "to", "enforcement", "objects", "May", "panic" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/proxylib/r2d2/r2d2parser.go#L89-L127
162,362
cilium/cilium
pkg/client/identity.go
IdentityGet
func (c *Client) IdentityGet(id string) (*models.Identity, error) { params := policy.NewGetIdentityIDParams().WithID(id).WithTimeout(api.ClientTimeout) resp, err := c.Policy.GetIdentityID(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
go
func (c *Client) IdentityGet(id string) (*models.Identity, error) { params := policy.NewGetIdentityIDParams().WithID(id).WithTimeout(api.ClientTimeout) resp, err := c.Policy.GetIdentityID(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
[ "func", "(", "c", "*", "Client", ")", "IdentityGet", "(", "id", "string", ")", "(", "*", "models", ".", "Identity", ",", "error", ")", "{", "params", ":=", "policy", ".", "NewGetIdentityIDParams", "(", ")", ".", "WithID", "(", "id", ")", ".", "WithTi...
// IdentityGet returns a security identity.
[ "IdentityGet", "returns", "a", "security", "identity", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/identity.go#L24-L32
162,363
cilium/cilium
pkg/datapath/linux/utils.go
defineUint32
func defineUint32(name string, value uint32) string { return fmt.Sprintf("DEFINE_U32(%s, %#08x);\t/* %d */\n#define %s fetch_u32(%s)\n", name, value, value, name, name) }
go
func defineUint32(name string, value uint32) string { return fmt.Sprintf("DEFINE_U32(%s, %#08x);\t/* %d */\n#define %s fetch_u32(%s)\n", name, value, value, name, name) }
[ "func", "defineUint32", "(", "name", "string", ",", "value", "uint32", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\\t", "\\n", "\\n", "\"", ",", "name", ",", "value", ",", "value", ",", "name", ",", "name", ")", "\n", "}" ]
// defineUint32 writes the C definition for an unsigned 32-bit value.
[ "defineUint32", "writes", "the", "C", "definition", "for", "an", "unsigned", "32", "-", "bit", "value", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/linux/utils.go#L50-L53
162,364
cilium/cilium
pkg/datapath/linux/utils.go
defineIPv4
func defineIPv4(name string, addr []byte) string { if len(addr) != net.IPv4len { return fmt.Sprintf("/* BUG: bad ip define %s %s */\n", name, goArray2C(addr)) } nboAddr := byteorder.HostSliceToNetwork(addr, reflect.Uint32).(uint32) return defineUint32(name, nboAddr) }
go
func defineIPv4(name string, addr []byte) string { if len(addr) != net.IPv4len { return fmt.Sprintf("/* BUG: bad ip define %s %s */\n", name, goArray2C(addr)) } nboAddr := byteorder.HostSliceToNetwork(addr, reflect.Uint32).(uint32) return defineUint32(name, nboAddr) }
[ "func", "defineIPv4", "(", "name", "string", ",", "addr", "[", "]", "byte", ")", "string", "{", "if", "len", "(", "addr", ")", "!=", "net", ".", "IPv4len", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "name", ",", "goArray2C",...
// defineIPv4 writes the C definition for the given IPv4 address.
[ "defineIPv4", "writes", "the", "C", "definition", "for", "the", "given", "IPv4", "address", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/linux/utils.go#L56-L62
162,365
cilium/cilium
pkg/datapath/linux/utils.go
defineIPv6
func defineIPv6(name string, addr []byte) string { if len(addr) != net.IPv6len { return fmt.Sprintf("/* BUG: bad ip define %s %s */\n", name, goArray2C(addr)) } return fmt.Sprintf("DEFINE_IPV6(%s, %s);\n", name, goArray2C(addr)) }
go
func defineIPv6(name string, addr []byte) string { if len(addr) != net.IPv6len { return fmt.Sprintf("/* BUG: bad ip define %s %s */\n", name, goArray2C(addr)) } return fmt.Sprintf("DEFINE_IPV6(%s, %s);\n", name, goArray2C(addr)) }
[ "func", "defineIPv6", "(", "name", "string", ",", "addr", "[", "]", "byte", ")", "string", "{", "if", "len", "(", "addr", ")", "!=", "net", ".", "IPv6len", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "name", ",", "goArray2C",...
// defineIPv6 writes the C definition for the given IPv6 address.
[ "defineIPv6", "writes", "the", "C", "definition", "for", "the", "given", "IPv6", "address", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/linux/utils.go#L65-L70
162,366
cilium/cilium
pkg/datapath/linux/utils.go
defineMAC
func defineMAC(name string, addr []byte) string { if len(addr) != 6 { /* MAC len */ return fmt.Sprintf("/* BUG: bad mac define %s %s */\n", name, goArray2C(addr)) } return fmt.Sprintf("DEFINE_MAC(%s, %s);\n#define %s fetch_mac(%s)\n", name, goArray2C(addr), name, name) }
go
func defineMAC(name string, addr []byte) string { if len(addr) != 6 { /* MAC len */ return fmt.Sprintf("/* BUG: bad mac define %s %s */\n", name, goArray2C(addr)) } return fmt.Sprintf("DEFINE_MAC(%s, %s);\n#define %s fetch_mac(%s)\n", name, goArray2C(addr), name, name) }
[ "func", "defineMAC", "(", "name", "string", ",", "addr", "[", "]", "byte", ")", "string", "{", "if", "len", "(", "addr", ")", "!=", "6", "{", "/* MAC len */", "return", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "name", ",", "goArray2C", "...
// defineMAC writes the C definition for the given MAC name and addr.
[ "defineMAC", "writes", "the", "C", "definition", "for", "the", "given", "MAC", "name", "and", "addr", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/linux/utils.go#L73-L79
162,367
cilium/cilium
pkg/endpoint/events.go
Handle
func (ev *EndpointRegenerationEvent) Handle(res chan interface{}) { e := ev.ep owner := ev.owner regenContext := ev.regenContext err := e.RLockAlive() if err != nil { e.LogDisconnectedMutexAction(err, "before regeneration") res <- &EndpointRegenerationResult{ err: err, } return } e.RUnlock() // We should only queue the request after we use all the endpoint's // lock/unlock. Otherwise this can get a deadlock if the endpoint is // being deleted at the same time. More info PR-1777. doneFunc, err := owner.QueueEndpointBuild(regenContext.parentContext, uint64(e.ID)) if err != nil { e.getLogger().WithError(err).Warning("unable to queue endpoint build") } else if doneFunc != nil { e.getLogger().Debug("Dequeued endpoint from build queue") regenContext.DoneFunc = doneFunc err = ev.ep.regenerate(ev.owner, ev.regenContext) doneFunc() e.notifyEndpointRegeneration(owner, err) } else { // If another build has been queued for the endpoint, that means that // that build will be able to take care of all of the work needed to // regenerate the endpoint at this current point in time; queueing // another build is a waste of resources. e.getLogger().Debug("build not queued for endpoint because another build has already been queued") } res <- &EndpointRegenerationResult{ err: err, } return }
go
func (ev *EndpointRegenerationEvent) Handle(res chan interface{}) { e := ev.ep owner := ev.owner regenContext := ev.regenContext err := e.RLockAlive() if err != nil { e.LogDisconnectedMutexAction(err, "before regeneration") res <- &EndpointRegenerationResult{ err: err, } return } e.RUnlock() // We should only queue the request after we use all the endpoint's // lock/unlock. Otherwise this can get a deadlock if the endpoint is // being deleted at the same time. More info PR-1777. doneFunc, err := owner.QueueEndpointBuild(regenContext.parentContext, uint64(e.ID)) if err != nil { e.getLogger().WithError(err).Warning("unable to queue endpoint build") } else if doneFunc != nil { e.getLogger().Debug("Dequeued endpoint from build queue") regenContext.DoneFunc = doneFunc err = ev.ep.regenerate(ev.owner, ev.regenContext) doneFunc() e.notifyEndpointRegeneration(owner, err) } else { // If another build has been queued for the endpoint, that means that // that build will be able to take care of all of the work needed to // regenerate the endpoint at this current point in time; queueing // another build is a waste of resources. e.getLogger().Debug("build not queued for endpoint because another build has already been queued") } res <- &EndpointRegenerationResult{ err: err, } return }
[ "func", "(", "ev", "*", "EndpointRegenerationEvent", ")", "Handle", "(", "res", "chan", "interface", "{", "}", ")", "{", "e", ":=", "ev", ".", "ep", "\n", "owner", ":=", "ev", ".", "owner", "\n", "regenContext", ":=", "ev", ".", "regenContext", "\n\n",...
// Handle handles the regeneration event for the endpoint.
[ "Handle", "handles", "the", "regeneration", "event", "for", "the", "endpoint", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/events.go#L29-L72
162,368
cilium/cilium
pkg/endpoint/events.go
Handle
func (ev *EndpointRevisionBumpEvent) Handle(res chan interface{}) { // TODO: if the endpoint is not in a 'ready' state that means that // we cannot set the policy revision, as something else has // changed endpoint state which necessitates regeneration, // *or* the endpoint is in a not-ready state (i.e., a prior // regeneration failed, so there is no way that we can // realize the policy revision yet. Should this be signaled // to the routine waiting for the result of this event? ev.ep.SetPolicyRevision(ev.Rev) res <- struct{}{} }
go
func (ev *EndpointRevisionBumpEvent) Handle(res chan interface{}) { // TODO: if the endpoint is not in a 'ready' state that means that // we cannot set the policy revision, as something else has // changed endpoint state which necessitates regeneration, // *or* the endpoint is in a not-ready state (i.e., a prior // regeneration failed, so there is no way that we can // realize the policy revision yet. Should this be signaled // to the routine waiting for the result of this event? ev.ep.SetPolicyRevision(ev.Rev) res <- struct{}{} }
[ "func", "(", "ev", "*", "EndpointRevisionBumpEvent", ")", "Handle", "(", "res", "chan", "interface", "{", "}", ")", "{", "// TODO: if the endpoint is not in a 'ready' state that means that", "// we cannot set the policy revision, as something else has", "// changed endpoint state w...
// Handle handles the revision bump event for the Endpoint.
[ "Handle", "handles", "the", "revision", "bump", "event", "for", "the", "Endpoint", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/events.go#L87-L97
162,369
cilium/cilium
pkg/endpoint/events.go
PolicyRevisionBumpEvent
func (e *Endpoint) PolicyRevisionBumpEvent(rev uint64) { epBumpEvent := eventqueue.NewEvent(&EndpointRevisionBumpEvent{Rev: rev, ep: e}) // Don't care about policy revision event results - it is best effort. _ = e.EventQueue.Enqueue(epBumpEvent) }
go
func (e *Endpoint) PolicyRevisionBumpEvent(rev uint64) { epBumpEvent := eventqueue.NewEvent(&EndpointRevisionBumpEvent{Rev: rev, ep: e}) // Don't care about policy revision event results - it is best effort. _ = e.EventQueue.Enqueue(epBumpEvent) }
[ "func", "(", "e", "*", "Endpoint", ")", "PolicyRevisionBumpEvent", "(", "rev", "uint64", ")", "{", "epBumpEvent", ":=", "eventqueue", ".", "NewEvent", "(", "&", "EndpointRevisionBumpEvent", "{", "Rev", ":", "rev", ",", "ep", ":", "e", "}", ")", "\n", "//...
// PolicyRevisionBumpEvent queues an event for the given endpoint to set its // realized policy revision to rev. This may block depending on if events have // been queued up for the given endpoint. It blocks until the event has // succeeded, or if the event has been cancelled.
[ "PolicyRevisionBumpEvent", "queues", "an", "event", "for", "the", "given", "endpoint", "to", "set", "its", "realized", "policy", "revision", "to", "rev", ".", "This", "may", "block", "depending", "on", "if", "events", "have", "been", "queued", "up", "for", "...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/events.go#L103-L107
162,370
cilium/cilium
pkg/revert/revert.go
Push
func (s *RevertStack) Push(revertFunc RevertFunc) { if revertFunc != nil { s.revertFuncs = append(s.revertFuncs, revertFunc) } }
go
func (s *RevertStack) Push(revertFunc RevertFunc) { if revertFunc != nil { s.revertFuncs = append(s.revertFuncs, revertFunc) } }
[ "func", "(", "s", "*", "RevertStack", ")", "Push", "(", "revertFunc", "RevertFunc", ")", "{", "if", "revertFunc", "!=", "nil", "{", "s", ".", "revertFuncs", "=", "append", "(", "s", ".", "revertFuncs", ",", "revertFunc", ")", "\n", "}", "\n", "}" ]
// Push pushes the given RevertFunc on top of this stack. If the function is // nil, it is ignored.
[ "Push", "pushes", "the", "given", "RevertFunc", "on", "top", "of", "this", "stack", ".", "If", "the", "function", "is", "nil", "it", "is", "ignored", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/revert/revert.go#L34-L38
162,371
cilium/cilium
pkg/revert/revert.go
Revert
func (s *RevertStack) Revert() error { for i := len(s.revertFuncs) - 1; i >= 0; i-- { if err := s.revertFuncs[i](); err != nil { return fmt.Errorf("failed to execute revert function; skipping %d revert functions: %s", i, err) } } return nil }
go
func (s *RevertStack) Revert() error { for i := len(s.revertFuncs) - 1; i >= 0; i-- { if err := s.revertFuncs[i](); err != nil { return fmt.Errorf("failed to execute revert function; skipping %d revert functions: %s", i, err) } } return nil }
[ "func", "(", "s", "*", "RevertStack", ")", "Revert", "(", ")", "error", "{", "for", "i", ":=", "len", "(", "s", ".", "revertFuncs", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", "{", "if", "err", ":=", "s", ".", "revertFuncs", "[", "i",...
// Revert executes all the RevertFuncs in the given stack in the reverse order // they were pushed.
[ "Revert", "executes", "all", "the", "RevertFuncs", "in", "the", "given", "stack", "in", "the", "reverse", "order", "they", "were", "pushed", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/revert/revert.go#L42-L49
162,372
cilium/cilium
api/v1/models/l4_policy.go
Validate
func (m *L4Policy) Validate(formats strfmt.Registry) error { var res []error if err := m.validateEgress(formats); err != nil { res = append(res, err) } if err := m.validateIngress(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *L4Policy) Validate(formats strfmt.Registry) error { var res []error if err := m.validateEgress(formats); err != nil { res = append(res, err) } if err := m.validateIngress(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "L4Policy", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateEgress", "(", "formats", ")", ";", "err", "!=", "nil", ...
// Validate validates this l4 policy
[ "Validate", "validates", "this", "l4", "policy" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/l4_policy.go#L29-L44
162,373
cilium/cilium
api/v1/server/restapi/daemon/get_map_responses.go
WithPayload
func (o *GetMapOK) WithPayload(payload *models.BPFMapList) *GetMapOK { o.Payload = payload return o }
go
func (o *GetMapOK) WithPayload(payload *models.BPFMapList) *GetMapOK { o.Payload = payload return o }
[ "func", "(", "o", "*", "GetMapOK", ")", "WithPayload", "(", "payload", "*", "models", ".", "BPFMapList", ")", "*", "GetMapOK", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the get map o k response
[ "WithPayload", "adds", "the", "payload", "to", "the", "get", "map", "o", "k", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/daemon/get_map_responses.go#L38-L41
162,374
cilium/cilium
api/v1/server/restapi/service/get_service_id_responses.go
WithPayload
func (o *GetServiceIDOK) WithPayload(payload *models.Service) *GetServiceIDOK { o.Payload = payload return o }
go
func (o *GetServiceIDOK) WithPayload(payload *models.Service) *GetServiceIDOK { o.Payload = payload return o }
[ "func", "(", "o", "*", "GetServiceIDOK", ")", "WithPayload", "(", "payload", "*", "models", ".", "Service", ")", "*", "GetServiceIDOK", "{", "o", ".", "Payload", "=", "payload", "\n", "return", "o", "\n", "}" ]
// WithPayload adds the payload to the get service Id o k response
[ "WithPayload", "adds", "the", "payload", "to", "the", "get", "service", "Id", "o", "k", "response" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/service/get_service_id_responses.go#L38-L41
162,375
cilium/cilium
pkg/client/policy.go
PolicyPut
func (c *Client) PolicyPut(policyJSON string) (*models.Policy, error) { params := policy.NewPutPolicyParams().WithPolicy(policyJSON).WithTimeout(api.ClientTimeout) resp, err := c.Policy.PutPolicy(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
go
func (c *Client) PolicyPut(policyJSON string) (*models.Policy, error) { params := policy.NewPutPolicyParams().WithPolicy(policyJSON).WithTimeout(api.ClientTimeout) resp, err := c.Policy.PutPolicy(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
[ "func", "(", "c", "*", "Client", ")", "PolicyPut", "(", "policyJSON", "string", ")", "(", "*", "models", ".", "Policy", ",", "error", ")", "{", "params", ":=", "policy", ".", "NewPutPolicyParams", "(", ")", ".", "WithPolicy", "(", "policyJSON", ")", "....
// PolicyPut inserts the `policyJSON`
[ "PolicyPut", "inserts", "the", "policyJSON" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/policy.go#L24-L31
162,376
cilium/cilium
pkg/client/policy.go
PolicyGet
func (c *Client) PolicyGet(labels []string) (*models.Policy, error) { params := policy.NewGetPolicyParams().WithLabels(labels).WithTimeout(api.ClientTimeout) resp, err := c.Policy.GetPolicy(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
go
func (c *Client) PolicyGet(labels []string) (*models.Policy, error) { params := policy.NewGetPolicyParams().WithLabels(labels).WithTimeout(api.ClientTimeout) resp, err := c.Policy.GetPolicy(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
[ "func", "(", "c", "*", "Client", ")", "PolicyGet", "(", "labels", "[", "]", "string", ")", "(", "*", "models", ".", "Policy", ",", "error", ")", "{", "params", ":=", "policy", ".", "NewGetPolicyParams", "(", ")", ".", "WithLabels", "(", "labels", ")"...
// PolicyGet returns policy rules
[ "PolicyGet", "returns", "policy", "rules" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/policy.go#L34-L41
162,377
cilium/cilium
pkg/client/policy.go
PolicyDelete
func (c *Client) PolicyDelete(labels []string) (*models.Policy, error) { params := policy.NewDeletePolicyParams().WithLabels(labels).WithTimeout(api.ClientTimeout) resp, err := c.Policy.DeletePolicy(params) if err != nil { return nil, Hint(err) } return resp.Payload, Hint(err) }
go
func (c *Client) PolicyDelete(labels []string) (*models.Policy, error) { params := policy.NewDeletePolicyParams().WithLabels(labels).WithTimeout(api.ClientTimeout) resp, err := c.Policy.DeletePolicy(params) if err != nil { return nil, Hint(err) } return resp.Payload, Hint(err) }
[ "func", "(", "c", "*", "Client", ")", "PolicyDelete", "(", "labels", "[", "]", "string", ")", "(", "*", "models", ".", "Policy", ",", "error", ")", "{", "params", ":=", "policy", ".", "NewDeletePolicyParams", "(", ")", ".", "WithLabels", "(", "labels",...
// PolicyDelete deletes policy rules
[ "PolicyDelete", "deletes", "policy", "rules" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/policy.go#L44-L51
162,378
cilium/cilium
pkg/client/policy.go
PolicyResolveGet
func (c *Client) PolicyResolveGet(traceSelector *models.TraceSelector) (*models.PolicyTraceResult, error) { params := policy.NewGetPolicyResolveParams().WithTraceSelector(traceSelector).WithTimeout(api.ClientTimeout) resp, err := c.Policy.GetPolicyResolve(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
go
func (c *Client) PolicyResolveGet(traceSelector *models.TraceSelector) (*models.PolicyTraceResult, error) { params := policy.NewGetPolicyResolveParams().WithTraceSelector(traceSelector).WithTimeout(api.ClientTimeout) resp, err := c.Policy.GetPolicyResolve(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
[ "func", "(", "c", "*", "Client", ")", "PolicyResolveGet", "(", "traceSelector", "*", "models", ".", "TraceSelector", ")", "(", "*", "models", ".", "PolicyTraceResult", ",", "error", ")", "{", "params", ":=", "policy", ".", "NewGetPolicyResolveParams", "(", "...
// PolicyResolveGet resolves policy for a Trace Selector with source and destination identity.
[ "PolicyResolveGet", "resolves", "policy", "for", "a", "Trace", "Selector", "with", "source", "and", "destination", "identity", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/policy.go#L54-L61
162,379
cilium/cilium
pkg/k8s/client/listers/cilium.io/v2/ciliumnetworkpolicy.go
List
func (s *ciliumNetworkPolicyLister) List(selector labels.Selector) (ret []*v2.CiliumNetworkPolicy, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { ret = append(ret, m.(*v2.CiliumNetworkPolicy)) }) return ret, err }
go
func (s *ciliumNetworkPolicyLister) List(selector labels.Selector) (ret []*v2.CiliumNetworkPolicy, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { ret = append(ret, m.(*v2.CiliumNetworkPolicy)) }) return ret, err }
[ "func", "(", "s", "*", "ciliumNetworkPolicyLister", ")", "List", "(", "selector", "labels", ".", "Selector", ")", "(", "ret", "[", "]", "*", "v2", ".", "CiliumNetworkPolicy", ",", "err", "error", ")", "{", "err", "=", "cache", ".", "ListAll", "(", "s",...
// List lists all CiliumNetworkPolicies in the indexer.
[ "List", "lists", "all", "CiliumNetworkPolicies", "in", "the", "indexer", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/client/listers/cilium.io/v2/ciliumnetworkpolicy.go#L46-L51
162,380
cilium/cilium
pkg/k8s/client/listers/cilium.io/v2/ciliumnetworkpolicy.go
CiliumNetworkPolicies
func (s *ciliumNetworkPolicyLister) CiliumNetworkPolicies(namespace string) CiliumNetworkPolicyNamespaceLister { return ciliumNetworkPolicyNamespaceLister{indexer: s.indexer, namespace: namespace} }
go
func (s *ciliumNetworkPolicyLister) CiliumNetworkPolicies(namespace string) CiliumNetworkPolicyNamespaceLister { return ciliumNetworkPolicyNamespaceLister{indexer: s.indexer, namespace: namespace} }
[ "func", "(", "s", "*", "ciliumNetworkPolicyLister", ")", "CiliumNetworkPolicies", "(", "namespace", "string", ")", "CiliumNetworkPolicyNamespaceLister", "{", "return", "ciliumNetworkPolicyNamespaceLister", "{", "indexer", ":", "s", ".", "indexer", ",", "namespace", ":",...
// CiliumNetworkPolicies returns an object that can list and get CiliumNetworkPolicies.
[ "CiliumNetworkPolicies", "returns", "an", "object", "that", "can", "list", "and", "get", "CiliumNetworkPolicies", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/client/listers/cilium.io/v2/ciliumnetworkpolicy.go#L54-L56
162,381
cilium/cilium
pkg/k8s/client/listers/cilium.io/v2/ciliumnetworkpolicy.go
List
func (s ciliumNetworkPolicyNamespaceLister) List(selector labels.Selector) (ret []*v2.CiliumNetworkPolicy, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { ret = append(ret, m.(*v2.CiliumNetworkPolicy)) }) return ret, err }
go
func (s ciliumNetworkPolicyNamespaceLister) List(selector labels.Selector) (ret []*v2.CiliumNetworkPolicy, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { ret = append(ret, m.(*v2.CiliumNetworkPolicy)) }) return ret, err }
[ "func", "(", "s", "ciliumNetworkPolicyNamespaceLister", ")", "List", "(", "selector", "labels", ".", "Selector", ")", "(", "ret", "[", "]", "*", "v2", ".", "CiliumNetworkPolicy", ",", "err", "error", ")", "{", "err", "=", "cache", ".", "ListAllByNamespace", ...
// List lists all CiliumNetworkPolicies in the indexer for a given namespace.
[ "List", "lists", "all", "CiliumNetworkPolicies", "in", "the", "indexer", "for", "a", "given", "namespace", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/client/listers/cilium.io/v2/ciliumnetworkpolicy.go#L75-L80
162,382
cilium/cilium
cilium/cmd/helpers.go
expandNestedJSON
func expandNestedJSON(result bytes.Buffer) (bytes.Buffer, error) { reStringWithJSON := regexp.MustCompile(`"[^"\\{]*{.*[^\\]"`) reJSON := regexp.MustCompile(`{.*}`) for { var ( loc []int indent string ) // Search for nested JSON; if we don't find any, then break. resBytes := result.Bytes() if loc = reStringWithJSON.FindIndex(resBytes); loc == nil { break } // Determine the current indentation for i := 0; i < loc[0]-1; i++ { idx := loc[0] - i - 1 if resBytes[idx] != ' ' { break } indent = fmt.Sprintf("\t%s\t", indent) } stringStart := loc[0] stringEnd := loc[1] // Unquote the string with the nested json. quotedBytes := resBytes[stringStart:stringEnd] unquoted, err := strconv.Unquote(string(quotedBytes)) if err != nil { return bytes.Buffer{}, fmt.Errorf("Failed to Unquote string: %s\n%s", err.Error(), string(quotedBytes)) } // Find the JSON within the quoted string. nestedStart := 0 nestedEnd := 0 if locs := reJSON.FindAllStringIndex(unquoted, -1); locs != nil { // The last match is the longest one. last := len(locs) - 1 nestedStart = locs[last][0] nestedEnd = locs[last][1] } else if reJSON.Match(quotedBytes) { // The entire string is JSON nestedEnd = len(unquoted) } // Decode the nested JSON decoded := "" if nestedEnd != 0 { m := make(map[string]interface{}) nested := bytes.NewBufferString(unquoted[nestedStart:nestedEnd]) if err := json.NewDecoder(nested).Decode(&m); err != nil { return bytes.Buffer{}, fmt.Errorf("Failed to decode nested JSON: %s", err.Error()) } decodedBytes, err := json.MarshalIndent(m, indent, " ") if err != nil { return bytes.Buffer{}, fmt.Errorf("Cannot marshal nested JSON: %s", err.Error()) } decoded = string(decodedBytes) } // Serialize nextResult := bytes.Buffer{} nextResult.Write(resBytes[0:stringStart]) nextResult.WriteString(string(unquoted[:nestedStart])) nextResult.WriteString(string(decoded)) nextResult.WriteString(string(unquoted[nestedEnd:])) nextResult.Write(resBytes[stringEnd:]) result = nextResult } return result, nil }
go
func expandNestedJSON(result bytes.Buffer) (bytes.Buffer, error) { reStringWithJSON := regexp.MustCompile(`"[^"\\{]*{.*[^\\]"`) reJSON := regexp.MustCompile(`{.*}`) for { var ( loc []int indent string ) // Search for nested JSON; if we don't find any, then break. resBytes := result.Bytes() if loc = reStringWithJSON.FindIndex(resBytes); loc == nil { break } // Determine the current indentation for i := 0; i < loc[0]-1; i++ { idx := loc[0] - i - 1 if resBytes[idx] != ' ' { break } indent = fmt.Sprintf("\t%s\t", indent) } stringStart := loc[0] stringEnd := loc[1] // Unquote the string with the nested json. quotedBytes := resBytes[stringStart:stringEnd] unquoted, err := strconv.Unquote(string(quotedBytes)) if err != nil { return bytes.Buffer{}, fmt.Errorf("Failed to Unquote string: %s\n%s", err.Error(), string(quotedBytes)) } // Find the JSON within the quoted string. nestedStart := 0 nestedEnd := 0 if locs := reJSON.FindAllStringIndex(unquoted, -1); locs != nil { // The last match is the longest one. last := len(locs) - 1 nestedStart = locs[last][0] nestedEnd = locs[last][1] } else if reJSON.Match(quotedBytes) { // The entire string is JSON nestedEnd = len(unquoted) } // Decode the nested JSON decoded := "" if nestedEnd != 0 { m := make(map[string]interface{}) nested := bytes.NewBufferString(unquoted[nestedStart:nestedEnd]) if err := json.NewDecoder(nested).Decode(&m); err != nil { return bytes.Buffer{}, fmt.Errorf("Failed to decode nested JSON: %s", err.Error()) } decodedBytes, err := json.MarshalIndent(m, indent, " ") if err != nil { return bytes.Buffer{}, fmt.Errorf("Cannot marshal nested JSON: %s", err.Error()) } decoded = string(decodedBytes) } // Serialize nextResult := bytes.Buffer{} nextResult.Write(resBytes[0:stringStart]) nextResult.WriteString(string(unquoted[:nestedStart])) nextResult.WriteString(string(decoded)) nextResult.WriteString(string(unquoted[nestedEnd:])) nextResult.Write(resBytes[stringEnd:]) result = nextResult } return result, nil }
[ "func", "expandNestedJSON", "(", "result", "bytes", ".", "Buffer", ")", "(", "bytes", ".", "Buffer", ",", "error", ")", "{", "reStringWithJSON", ":=", "regexp", ".", "MustCompile", "(", "`\"[^\"\\\\{]*{.*[^\\\\]\"`", ")", "\n", "reJSON", ":=", "regexp", ".", ...
// Search 'result' for strings with escaped JSON inside, and expand the JSON.
[ "Search", "result", "for", "strings", "with", "escaped", "JSON", "inside", "and", "expand", "the", "JSON", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/cilium/cmd/helpers.go#L122-L195
162,383
cilium/cilium
cilium/cmd/helpers.go
parseTrafficString
func parseTrafficString(td string) (trafficdirection.TrafficDirection, error) { lowered := strings.ToLower(td) switch lowered { case "ingress": return trafficdirection.Ingress, nil case "egress": return trafficdirection.Egress, nil default: return trafficdirection.Invalid, fmt.Errorf("invalid direction %q provided", td) } }
go
func parseTrafficString(td string) (trafficdirection.TrafficDirection, error) { lowered := strings.ToLower(td) switch lowered { case "ingress": return trafficdirection.Ingress, nil case "egress": return trafficdirection.Egress, nil default: return trafficdirection.Invalid, fmt.Errorf("invalid direction %q provided", td) } }
[ "func", "parseTrafficString", "(", "td", "string", ")", "(", "trafficdirection", ".", "TrafficDirection", ",", "error", ")", "{", "lowered", ":=", "strings", ".", "ToLower", "(", "td", ")", "\n\n", "switch", "lowered", "{", "case", "\"", "\"", ":", "return...
// parseTrafficString converts the provided string to its corresponding // TrafficDirection. If the string does not correspond to a valid TrafficDirection // type, returns Invalid and a corresponding error.
[ "parseTrafficString", "converts", "the", "provided", "string", "to", "its", "corresponding", "TrafficDirection", ".", "If", "the", "string", "does", "not", "correspond", "to", "a", "valid", "TrafficDirection", "type", "returns", "Invalid", "and", "a", "corresponding...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/cilium/cmd/helpers.go#L221-L233
162,384
cilium/cilium
cilium/cmd/helpers.go
updatePolicyKey
func updatePolicyKey(pa *PolicyUpdateArgs, add bool) { // The map needs not to be transparently initialized here even if // it's not present for some reason. Triggering map recreation with // OpenOrCreate when some map attribute had changed would be much worse. policyMap, err := policymap.Open(pa.path) if err != nil { Fatalf("Cannot open policymap %q : %s", pa.path, err) } for _, proto := range pa.protocols { u8p := u8proto.U8proto(proto) entry := fmt.Sprintf("%d %d/%s", pa.label, pa.port, u8p.String()) if add { var proxyPort uint16 if err := policyMap.Allow(pa.label, pa.port, u8p, pa.trafficDirection, proxyPort); err != nil { Fatalf("Cannot add policy key '%s': %s\n", entry, err) } } else { if err := policyMap.Delete(pa.label, pa.port, u8p, pa.trafficDirection); err != nil { Fatalf("Cannot delete policy key '%s': %s\n", entry, err) } } } }
go
func updatePolicyKey(pa *PolicyUpdateArgs, add bool) { // The map needs not to be transparently initialized here even if // it's not present for some reason. Triggering map recreation with // OpenOrCreate when some map attribute had changed would be much worse. policyMap, err := policymap.Open(pa.path) if err != nil { Fatalf("Cannot open policymap %q : %s", pa.path, err) } for _, proto := range pa.protocols { u8p := u8proto.U8proto(proto) entry := fmt.Sprintf("%d %d/%s", pa.label, pa.port, u8p.String()) if add { var proxyPort uint16 if err := policyMap.Allow(pa.label, pa.port, u8p, pa.trafficDirection, proxyPort); err != nil { Fatalf("Cannot add policy key '%s': %s\n", entry, err) } } else { if err := policyMap.Delete(pa.label, pa.port, u8p, pa.trafficDirection); err != nil { Fatalf("Cannot delete policy key '%s': %s\n", entry, err) } } } }
[ "func", "updatePolicyKey", "(", "pa", "*", "PolicyUpdateArgs", ",", "add", "bool", ")", "{", "// The map needs not to be transparently initialized here even if", "// it's not present for some reason. Triggering map recreation with", "// OpenOrCreate when some map attribute had changed woul...
// updatePolicyKey updates an entry in the PolicyMap for the provided // PolicyUpdateArgs argument. // Adds the entry to the PolicyMap if add is true, otherwise the entry is // deleted.
[ "updatePolicyKey", "updates", "an", "entry", "in", "the", "PolicyMap", "for", "the", "provided", "PolicyUpdateArgs", "argument", ".", "Adds", "the", "entry", "to", "the", "PolicyMap", "if", "add", "is", "true", "otherwise", "the", "entry", "is", "deleted", "."...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/cilium/cmd/helpers.go#L327-L350
162,385
cilium/cilium
cilium/cmd/helpers.go
dumpConfig
func dumpConfig(Opts map[string]string) { opts := []string{} for k := range Opts { opts = append(opts, k) } sort.Strings(opts) for _, k := range opts { // XXX: Reuse the format function from *option.Library value = Opts[k] if enabled, err := option.NormalizeBool(value); err != nil { // If it cannot be parsed as a bool, just format the value. fmt.Printf("%-24s %s\n", k, color.Green(value)) } else if enabled == option.OptionDisabled { fmt.Printf("%-24s %s\n", k, color.Red("Disabled")) } else { fmt.Printf("%-24s %s\n", k, color.Green("Enabled")) } } }
go
func dumpConfig(Opts map[string]string) { opts := []string{} for k := range Opts { opts = append(opts, k) } sort.Strings(opts) for _, k := range opts { // XXX: Reuse the format function from *option.Library value = Opts[k] if enabled, err := option.NormalizeBool(value); err != nil { // If it cannot be parsed as a bool, just format the value. fmt.Printf("%-24s %s\n", k, color.Green(value)) } else if enabled == option.OptionDisabled { fmt.Printf("%-24s %s\n", k, color.Red("Disabled")) } else { fmt.Printf("%-24s %s\n", k, color.Green("Enabled")) } } }
[ "func", "dumpConfig", "(", "Opts", "map", "[", "string", "]", "string", ")", "{", "opts", ":=", "[", "]", "string", "{", "}", "\n", "for", "k", ":=", "range", "Opts", "{", "opts", "=", "append", "(", "opts", ",", "k", ")", "\n", "}", "\n", "sor...
// dumpConfig pretty prints boolean options
[ "dumpConfig", "pretty", "prints", "boolean", "options" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/cilium/cmd/helpers.go#L353-L372
162,386
cilium/cilium
pkg/envoy/server.go
RemoveListener
func (s *XDSServer) RemoveListener(name string, wg *completion.WaitGroup) xds.AckingResourceMutatorRevertFunc { log.Debugf("Envoy: removeListener %s", name) var listenerRevertFunc func(*completion.Completion) s.mutex.Lock() listener, ok := s.listeners[name] if ok && listener != nil { listener.count-- if listener.count == 0 { delete(s.listeners, name) listenerRevertFunc = s.listenerMutator.Delete(ListenerTypeURL, name, []string{"127.0.0.1"}, wg.AddCompletion()) } } else { // Bail out if this listener does not exist log.Fatalf("Envoy: Attempt to remove non-existent listener: %s", name) } s.mutex.Unlock() return func(completion *completion.Completion) { s.mutex.Lock() if listenerRevertFunc != nil { listenerRevertFunc(completion) } listener.count++ s.listeners[name] = listener s.mutex.Unlock() } }
go
func (s *XDSServer) RemoveListener(name string, wg *completion.WaitGroup) xds.AckingResourceMutatorRevertFunc { log.Debugf("Envoy: removeListener %s", name) var listenerRevertFunc func(*completion.Completion) s.mutex.Lock() listener, ok := s.listeners[name] if ok && listener != nil { listener.count-- if listener.count == 0 { delete(s.listeners, name) listenerRevertFunc = s.listenerMutator.Delete(ListenerTypeURL, name, []string{"127.0.0.1"}, wg.AddCompletion()) } } else { // Bail out if this listener does not exist log.Fatalf("Envoy: Attempt to remove non-existent listener: %s", name) } s.mutex.Unlock() return func(completion *completion.Completion) { s.mutex.Lock() if listenerRevertFunc != nil { listenerRevertFunc(completion) } listener.count++ s.listeners[name] = listener s.mutex.Unlock() } }
[ "func", "(", "s", "*", "XDSServer", ")", "RemoveListener", "(", "name", "string", ",", "wg", "*", "completion", ".", "WaitGroup", ")", "xds", ".", "AckingResourceMutatorRevertFunc", "{", "log", ".", "Debugf", "(", "\"", "\"", ",", "name", ")", "\n\n", "v...
// RemoveListener removes an existing Envoy Listener.
[ "RemoveListener", "removes", "an", "existing", "Envoy", "Listener", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/server.go#L404-L432
162,387
cilium/cilium
pkg/envoy/server.go
getNetworkPolicy
func getNetworkPolicy(name string, id identity.NumericIdentity, conntrackName string, policy *policy.L4Policy, ingressPolicyEnforced, egressPolicyEnforced bool, labelsMap, deniedIngressIdentities, deniedEgressIdentities cache.IdentityCache) *cilium.NetworkPolicy { p := &cilium.NetworkPolicy{ Name: name, Policy: uint64(id), ConntrackMapName: conntrackName, } // If no policy, deny all traffic. Otherwise, convert the policies for ingress and egress. if policy != nil { p.IngressPerPortPolicies = getDirectionNetworkPolicy(policy.Ingress, ingressPolicyEnforced, labelsMap, deniedIngressIdentities) p.EgressPerPortPolicies = getDirectionNetworkPolicy(policy.Egress, egressPolicyEnforced, labelsMap, deniedEgressIdentities) } return p }
go
func getNetworkPolicy(name string, id identity.NumericIdentity, conntrackName string, policy *policy.L4Policy, ingressPolicyEnforced, egressPolicyEnforced bool, labelsMap, deniedIngressIdentities, deniedEgressIdentities cache.IdentityCache) *cilium.NetworkPolicy { p := &cilium.NetworkPolicy{ Name: name, Policy: uint64(id), ConntrackMapName: conntrackName, } // If no policy, deny all traffic. Otherwise, convert the policies for ingress and egress. if policy != nil { p.IngressPerPortPolicies = getDirectionNetworkPolicy(policy.Ingress, ingressPolicyEnforced, labelsMap, deniedIngressIdentities) p.EgressPerPortPolicies = getDirectionNetworkPolicy(policy.Egress, egressPolicyEnforced, labelsMap, deniedEgressIdentities) } return p }
[ "func", "getNetworkPolicy", "(", "name", "string", ",", "id", "identity", ".", "NumericIdentity", ",", "conntrackName", "string", ",", "policy", "*", "policy", ".", "L4Policy", ",", "ingressPolicyEnforced", ",", "egressPolicyEnforced", "bool", ",", "labelsMap", ",...
// getNetworkPolicy converts a network policy into a cilium.NetworkPolicy.
[ "getNetworkPolicy", "converts", "a", "network", "policy", "into", "a", "cilium", ".", "NetworkPolicy", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/server.go#L728-L744
162,388
cilium/cilium
pkg/envoy/server.go
RemoveNetworkPolicy
func (s *XDSServer) RemoveNetworkPolicy(ep logger.EndpointInfoSource) { s.mutex.Lock() defer s.mutex.Unlock() if ep.GetIPv6Address() != "" { name := ep.GetIPv6Address() s.networkPolicyCache.Delete(NetworkPolicyTypeURL, name, false) delete(s.networkPolicyEndpoints, name) } if ep.GetIPv4Address() != "" { name := ep.GetIPv4Address() s.networkPolicyCache.Delete(NetworkPolicyTypeURL, name, false) delete(s.networkPolicyEndpoints, name) } }
go
func (s *XDSServer) RemoveNetworkPolicy(ep logger.EndpointInfoSource) { s.mutex.Lock() defer s.mutex.Unlock() if ep.GetIPv6Address() != "" { name := ep.GetIPv6Address() s.networkPolicyCache.Delete(NetworkPolicyTypeURL, name, false) delete(s.networkPolicyEndpoints, name) } if ep.GetIPv4Address() != "" { name := ep.GetIPv4Address() s.networkPolicyCache.Delete(NetworkPolicyTypeURL, name, false) delete(s.networkPolicyEndpoints, name) } }
[ "func", "(", "s", "*", "XDSServer", ")", "RemoveNetworkPolicy", "(", "ep", "logger", ".", "EndpointInfoSource", ")", "{", "s", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "if", "ep", ".", ...
// RemoveNetworkPolicy removes network policies relevant to the specified // endpoint from the set published to L7 proxies, and stops listening for // acks for policies on this endpoint.
[ "RemoveNetworkPolicy", "removes", "network", "policies", "relevant", "to", "the", "specified", "endpoint", "from", "the", "set", "published", "to", "L7", "proxies", "and", "stops", "listening", "for", "acks", "for", "policies", "on", "this", "endpoint", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/server.go#L874-L888
162,389
cilium/cilium
pkg/envoy/server.go
GetNetworkPolicies
func (s *XDSServer) GetNetworkPolicies(resourceNames []string) (map[string]*cilium.NetworkPolicy, error) { resources, err := s.networkPolicyCache.GetResources(context.Background(), NetworkPolicyTypeURL, 0, nil, resourceNames) if err != nil { return nil, err } networkPolicies := make(map[string]*cilium.NetworkPolicy, len(resources.Resources)) for _, res := range resources.Resources { networkPolicy := res.(*cilium.NetworkPolicy) networkPolicies[networkPolicy.Name] = networkPolicy } return networkPolicies, nil }
go
func (s *XDSServer) GetNetworkPolicies(resourceNames []string) (map[string]*cilium.NetworkPolicy, error) { resources, err := s.networkPolicyCache.GetResources(context.Background(), NetworkPolicyTypeURL, 0, nil, resourceNames) if err != nil { return nil, err } networkPolicies := make(map[string]*cilium.NetworkPolicy, len(resources.Resources)) for _, res := range resources.Resources { networkPolicy := res.(*cilium.NetworkPolicy) networkPolicies[networkPolicy.Name] = networkPolicy } return networkPolicies, nil }
[ "func", "(", "s", "*", "XDSServer", ")", "GetNetworkPolicies", "(", "resourceNames", "[", "]", "string", ")", "(", "map", "[", "string", "]", "*", "cilium", ".", "NetworkPolicy", ",", "error", ")", "{", "resources", ",", "err", ":=", "s", ".", "network...
// GetNetworkPolicies returns the current version of the network policies with // the given names. // If resourceNames is empty, all resources are returned.
[ "GetNetworkPolicies", "returns", "the", "current", "version", "of", "the", "network", "policies", "with", "the", "given", "names", ".", "If", "resourceNames", "is", "empty", "all", "resources", "are", "returned", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/server.go#L899-L910
162,390
cilium/cilium
pkg/envoy/server.go
getLocalEndpoint
func (s *XDSServer) getLocalEndpoint(networkPolicyName string) logger.EndpointUpdater { s.mutex.RLock() defer s.mutex.RUnlock() return s.networkPolicyEndpoints[networkPolicyName] }
go
func (s *XDSServer) getLocalEndpoint(networkPolicyName string) logger.EndpointUpdater { s.mutex.RLock() defer s.mutex.RUnlock() return s.networkPolicyEndpoints[networkPolicyName] }
[ "func", "(", "s", "*", "XDSServer", ")", "getLocalEndpoint", "(", "networkPolicyName", "string", ")", "logger", ".", "EndpointUpdater", "{", "s", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "RUnlock", "(", ")", "\n\n", ...
// getLocalEndpoint returns the endpoint info for the local endpoint on which // the network policy of the given name if enforced, or nil if not found.
[ "getLocalEndpoint", "returns", "the", "endpoint", "info", "for", "the", "local", "endpoint", "on", "which", "the", "network", "policy", "of", "the", "given", "name", "if", "enforced", "or", "nil", "if", "not", "found", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/server.go#L914-L919
162,391
cilium/cilium
pkg/policy/api/utils.go
Equal
func (h *PortRuleHTTP) Equal(o PortRuleHTTP) bool { if h.Path != o.Path || h.Method != o.Method || h.Host != o.Host || len(h.Headers) != len(o.Headers) { return false } for i, value := range h.Headers { if o.Headers[i] != value { return false } } return true }
go
func (h *PortRuleHTTP) Equal(o PortRuleHTTP) bool { if h.Path != o.Path || h.Method != o.Method || h.Host != o.Host || len(h.Headers) != len(o.Headers) { return false } for i, value := range h.Headers { if o.Headers[i] != value { return false } } return true }
[ "func", "(", "h", "*", "PortRuleHTTP", ")", "Equal", "(", "o", "PortRuleHTTP", ")", "bool", "{", "if", "h", ".", "Path", "!=", "o", ".", "Path", "||", "h", ".", "Method", "!=", "o", ".", "Method", "||", "h", ".", "Host", "!=", "o", ".", "Host",...
// Equal returns true if both HTTP rules are equal
[ "Equal", "returns", "true", "if", "both", "HTTP", "rules", "are", "equal" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/utils.go#L34-L48
162,392
cilium/cilium
pkg/policy/api/utils.go
Exists
func (d *PortRuleDNS) Exists(rules L7Rules) bool { for _, existingRule := range rules.DNS { if d.Equal(existingRule) { return true } } return false }
go
func (d *PortRuleDNS) Exists(rules L7Rules) bool { for _, existingRule := range rules.DNS { if d.Equal(existingRule) { return true } } return false }
[ "func", "(", "d", "*", "PortRuleDNS", ")", "Exists", "(", "rules", "L7Rules", ")", "bool", "{", "for", "_", ",", "existingRule", ":=", "range", "rules", ".", "DNS", "{", "if", "d", ".", "Equal", "(", "existingRule", ")", "{", "return", "true", "\n", ...
// Exists returns true if the DNS rule already exists in the list of rules
[ "Exists", "returns", "true", "if", "the", "DNS", "rule", "already", "exists", "in", "the", "list", "of", "rules" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/utils.go#L62-L70
162,393
cilium/cilium
pkg/policy/api/utils.go
Exists
func (h *PortRuleL7) Exists(rules L7Rules) bool { for _, existingRule := range rules.L7 { if h.Equal(existingRule) { return true } } return false }
go
func (h *PortRuleL7) Exists(rules L7Rules) bool { for _, existingRule := range rules.L7 { if h.Equal(existingRule) { return true } } return false }
[ "func", "(", "h", "*", "PortRuleL7", ")", "Exists", "(", "rules", "L7Rules", ")", "bool", "{", "for", "_", ",", "existingRule", ":=", "range", "rules", ".", "L7", "{", "if", "h", ".", "Equal", "(", "existingRule", ")", "{", "return", "true", "\n", ...
// Exists returns true if the L7 rule already exists in the list of rules
[ "Exists", "returns", "true", "if", "the", "L7", "rule", "already", "exists", "in", "the", "list", "of", "rules" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/utils.go#L79-L87
162,394
cilium/cilium
pkg/policy/api/utils.go
Equal
func (h *PortRuleL7) Equal(o PortRuleL7) bool { if len(*h) != len(o) { return false } for k, v := range *h { if v2, ok := o[k]; !ok || v2 != v { return false } } return true }
go
func (h *PortRuleL7) Equal(o PortRuleL7) bool { if len(*h) != len(o) { return false } for k, v := range *h { if v2, ok := o[k]; !ok || v2 != v { return false } } return true }
[ "func", "(", "h", "*", "PortRuleL7", ")", "Equal", "(", "o", "PortRuleL7", ")", "bool", "{", "if", "len", "(", "*", "h", ")", "!=", "len", "(", "o", ")", "{", "return", "false", "\n", "}", "\n", "for", "k", ",", "v", ":=", "range", "*", "h", ...
// Equal returns true if both L7 rules are equal
[ "Equal", "returns", "true", "if", "both", "L7", "rules", "are", "equal" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/utils.go#L95-L105
162,395
cilium/cilium
pkg/policy/api/utils.go
Validate
func (l4 L4Proto) Validate() error { switch l4 { case ProtoAny, ProtoTCP, ProtoUDP: default: return fmt.Errorf("invalid protocol %q, must be { tcp | udp | any }", l4) } return nil }
go
func (l4 L4Proto) Validate() error { switch l4 { case ProtoAny, ProtoTCP, ProtoUDP: default: return fmt.Errorf("invalid protocol %q, must be { tcp | udp | any }", l4) } return nil }
[ "func", "(", "l4", "L4Proto", ")", "Validate", "(", ")", "error", "{", "switch", "l4", "{", "case", "ProtoAny", ",", "ProtoTCP", ",", "ProtoUDP", ":", "default", ":", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "l4", ")", "\n", "}", "\n\n...
// Validate returns an error if the layer 4 protocol is not valid
[ "Validate", "returns", "an", "error", "if", "the", "layer", "4", "protocol", "is", "not", "valid" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/utils.go#L108-L116
162,396
cilium/cilium
pkg/policy/api/utils.go
ParseL4Proto
func ParseL4Proto(proto string) (L4Proto, error) { if proto == "" { return ProtoAny, nil } p := L4Proto(strings.ToUpper(proto)) return p, p.Validate() }
go
func ParseL4Proto(proto string) (L4Proto, error) { if proto == "" { return ProtoAny, nil } p := L4Proto(strings.ToUpper(proto)) return p, p.Validate() }
[ "func", "ParseL4Proto", "(", "proto", "string", ")", "(", "L4Proto", ",", "error", ")", "{", "if", "proto", "==", "\"", "\"", "{", "return", "ProtoAny", ",", "nil", "\n", "}", "\n\n", "p", ":=", "L4Proto", "(", "strings", ".", "ToUpper", "(", "proto"...
// ParseL4Proto parses a string as layer 4 protocol
[ "ParseL4Proto", "parses", "a", "string", "as", "layer", "4", "protocol" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/api/utils.go#L119-L126
162,397
cilium/cilium
pkg/datapath/maps/map.go
removeDatapathMapping
func (gw *realEPManager) removeDatapathMapping(endpointID uint16) error { return policymap.RemoveGlobalMapping(uint32(endpointID)) }
go
func (gw *realEPManager) removeDatapathMapping(endpointID uint16) error { return policymap.RemoveGlobalMapping(uint32(endpointID)) }
[ "func", "(", "gw", "*", "realEPManager", ")", "removeDatapathMapping", "(", "endpointID", "uint16", ")", "error", "{", "return", "policymap", ".", "RemoveGlobalMapping", "(", "uint32", "(", "endpointID", ")", ")", "\n", "}" ]
// removeDatapathMapping unlinks the endpointID from the global policy map, preventing // packets that arrive on this node from being forwarded to the endpoint that // used to exist with the specified ID.
[ "removeDatapathMapping", "unlinks", "the", "endpointID", "from", "the", "global", "policy", "map", "preventing", "packets", "that", "arrive", "on", "this", "node", "from", "being", "forwarded", "to", "the", "endpoint", "that", "used", "to", "exist", "with", "the...
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/maps/map.go#L68-L70
162,398
cilium/cilium
pkg/datapath/maps/map.go
removeMapPath
func (gw *realEPManager) removeMapPath(path string) { if err := os.RemoveAll(path); err != nil { log.WithError(err).WithField(logfields.Path, path).Warn("Error while deleting stale map file") } else { log.WithField(logfields.Path, path).Info("Removed stale bpf map") } }
go
func (gw *realEPManager) removeMapPath(path string) { if err := os.RemoveAll(path); err != nil { log.WithError(err).WithField(logfields.Path, path).Warn("Error while deleting stale map file") } else { log.WithField(logfields.Path, path).Info("Removed stale bpf map") } }
[ "func", "(", "gw", "*", "realEPManager", ")", "removeMapPath", "(", "path", "string", ")", "{", "if", "err", ":=", "os", ".", "RemoveAll", "(", "path", ")", ";", "err", "!=", "nil", "{", "log", ".", "WithError", "(", "err", ")", ".", "WithField", "...
// removeMapPath removes the specified path from the filesystem.
[ "removeMapPath", "removes", "the", "specified", "path", "from", "the", "filesystem", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/maps/map.go#L73-L79
162,399
cilium/cilium
pkg/datapath/maps/map.go
deleteMapIfStale
func (ms *mapSweeper) deleteMapIfStale(path string, filename string, endpointID string) { if tmp, err := strconv.ParseUint(endpointID, 10, 16); err == nil { epID := uint16(tmp) if ms.endpointExists(epID) { prefix := strings.TrimSuffix(filename, endpointID) if filename != bpf.LocalMapName(prefix, epID) { ms.removeMapPath(path) } } else { err2 := ms.removeDatapathMapping(epID) if err2 != nil { log.WithError(err2).Debugf("Failed to remove ID %d from global policy map", tmp) } ms.removeMapPath(path) } } }
go
func (ms *mapSweeper) deleteMapIfStale(path string, filename string, endpointID string) { if tmp, err := strconv.ParseUint(endpointID, 10, 16); err == nil { epID := uint16(tmp) if ms.endpointExists(epID) { prefix := strings.TrimSuffix(filename, endpointID) if filename != bpf.LocalMapName(prefix, epID) { ms.removeMapPath(path) } } else { err2 := ms.removeDatapathMapping(epID) if err2 != nil { log.WithError(err2).Debugf("Failed to remove ID %d from global policy map", tmp) } ms.removeMapPath(path) } } }
[ "func", "(", "ms", "*", "mapSweeper", ")", "deleteMapIfStale", "(", "path", "string", ",", "filename", "string", ",", "endpointID", "string", ")", "{", "if", "tmp", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "endpointID", ",", "10", ",", "16", ...
// deleteMapIfStale uses the endpointManager implementation to determine for // the given path whether it should be deleted, and if so deletes the path.
[ "deleteMapIfStale", "uses", "the", "endpointManager", "implementation", "to", "determine", "for", "the", "given", "path", "whether", "it", "should", "be", "deleted", "and", "if", "so", "deletes", "the", "path", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/maps/map.go#L98-L114