fn create_test_slice()

in nfm-controller/src/kubernetes/kubernetes_metadata_collector.rs [804:855]


    fn create_test_slice(address: IpAddr) -> EndpointSlice {
        let mut endpoints = vec![];
        endpoints.push(k8s_openapi::api::discovery::v1::Endpoint {
            addresses: vec![address.to_string()],
            conditions: None,
            hostname: None,
            target_ref: Some(ObjectReference {
                api_version: Some("v1".to_string()),
                kind: Some("pod".to_string()),
                name: Some(adress_to_podname(address)),
                namespace: Some("default".to_string()),
                ..Default::default()
            }),
            node_name: None,
            zone: None,
            hints: None,
            deprecated_topology: None,
        });

        EndpointSlice {
            metadata: ObjectMeta {
                namespace: Some("default".to_string()),
                owner_references: Some(vec![OwnerReference {
                    name: "test-service".to_string(),
                    ..Default::default()
                }]),
                ..Default::default()
            },
            address_type: "IPv4".to_string(),
            endpoints,
            ports: Some(vec![
                k8s_openapi::api::discovery::v1::EndpointPort {
                    name: Some("test-port".to_string()),
                    port: Some(TEST_POD_PORT),
                    protocol: Some("TCP".to_string()),
                    app_protocol: None,
                },
                k8s_openapi::api::discovery::v1::EndpointPort {
                    name: Some("test-port2".to_string()),
                    port: Some(TEST_POD_PORT),
                    protocol: Some("UDP".to_string()), // UDP should be disregarded, for now at least
                    app_protocol: None,
                },
                k8s_openapi::api::discovery::v1::EndpointPort {
                    name: Some("test-port2".to_string()),
                    port: Some(TEST_POD_PORT + 1),
                    protocol: Some("UDP".to_string()), // UDP should be disregarded, for now at least
                    app_protocol: None,
                },
            ]),
        }
    }