Revision b9098e6b25f97b4af51ebec3c24f5cf6ad48551f authored by Gilberto Bertin on 29 February 2024, 07:36:40 UTC, committed by Martynas Pumputis on 29 February 2024, 15:47:00 UTC
currently some functions in policy.h reference POLICY_MAP, assuming it's always defined. This prevents including this header in a context where the POLICY_MAP is not defined. To overcome this, remove all the POLICY_MAP references from these functions and always pass the map explicitly in the caller. No functional changes are introduced. Signed-off-by: Gilberto Bertin <jibi@cilium.io>
1 parent d7dba5e
endpoint.go
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package egressgateway
import (
"fmt"
"net/netip"
"k8s.io/apimachinery/pkg/types"
k8sTypes "github.com/cilium/cilium/pkg/k8s/types"
"github.com/cilium/cilium/pkg/labels"
)
// endpointMetadata stores relevant metadata associated with a endpoint that's updated during endpoint
// add/update events
type endpointMetadata struct {
// Endpoint labels
labels map[string]string
// Endpoint ID
id endpointID
// ips are endpoint's unique IPs
ips []netip.Addr
}
// endpointID is based on endpoint's UID
type endpointID = types.UID
func getEndpointMetadata(endpoint *k8sTypes.CiliumEndpoint, identityLabels labels.Labels) (*endpointMetadata, error) {
var addrs []netip.Addr
if endpoint.UID == "" {
// this can happen when CiliumEndpointSlices are in use - which is not supported in the EGW yet
return nil, fmt.Errorf("endpoint has empty UID")
}
if endpoint.Networking == nil {
return nil, fmt.Errorf("endpoint has no networking metadata")
}
if len(endpoint.Networking.Addressing) == 0 {
return nil, fmt.Errorf("failed to get valid endpoint IPs")
}
for _, pair := range endpoint.Networking.Addressing {
if pair.IPV4 != "" {
addr, err := netip.ParseAddr(pair.IPV4)
if err != nil || !addr.Is4() {
continue
}
addrs = append(addrs, addr)
}
}
if endpoint.Identity == nil {
return nil, fmt.Errorf("endpoint has no identity metadata")
}
data := &endpointMetadata{
ips: addrs,
labels: identityLabels.K8sStringMap(),
id: endpoint.UID,
}
return data, nil
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...