本文整理匯總了Golang中github.com/cilium/cilium/pkg/endpoint.Endpoint.DeepCopy方法的典型用法代碼示例。如果您正苦於以下問題:Golang Endpoint.DeepCopy方法的具體用法?Golang Endpoint.DeepCopy怎麽用?Golang Endpoint.DeepCopy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cilium/cilium/pkg/endpoint.Endpoint
的用法示例。
在下文中一共展示了Endpoint.DeepCopy方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setEndpointSecLabel
// Sets the given secLabel on the endpoint with the given endpointID. Returns a pointer of
// a copy endpoint if the endpoint was found, nil otherwise.
func (d *Daemon) setEndpointSecLabel(endpointID *uint16, dockerID, dockerEPID string, labels *labels.SecCtxLabel) *endpoint.Endpoint {
var (
ep *endpoint.Endpoint
ok bool
)
setIfNotEmpty := func(receiver *string, provider string) {
if receiver != nil && *receiver == "" && provider != "" {
*receiver = provider
}
}
setIfNotEmptyUint16 := func(receiver *uint16, provider *uint16) {
if receiver != nil && *receiver == 0 && provider != nil && *provider != 0 {
*receiver = *provider
}
}
d.endpointsMU.Lock()
defer d.endpointsMU.Unlock()
if endpointID != nil {
ep, ok = d.endpoints[*endpointID]
} else if dockerID != "" {
ep, ok = d.endpointsDocker[dockerID]
} else if dockerEPID != "" {
ep, ok = d.endpointsDockerEP[dockerEPID]
} else {
return nil
}
if ok {
setIfNotEmpty(&ep.DockerID, dockerID)
setIfNotEmpty(&ep.DockerEndpointID, dockerEPID)
setIfNotEmptyUint16(&ep.ID, endpointID)
ep.SetSecLabel(labels)
// Update all IDs in respective MAPs
d.insertEndpoint(ep)
return ep.DeepCopy()
}
return nil
}