Exemplo n.º 1
0
 public KubernetesServiceInstance(
     string instanceId,
     string serviceId,
     V1EndpointAddress endpointAddress,
     Corev1EndpointPort endpointPort,
     IDictionary <string, string> metadata,
     bool isSecure)
 {
     InstanceId       = instanceId;
     ServiceId        = serviceId;
     _endpointAddress = endpointAddress;
     _endpointPort    = endpointPort;
     IsSecure         = isSecure;
     Metadata         = metadata;
 }
Exemplo n.º 2
0
 private static bool MatchesPort(V1EndpointPort port1, V1ServiceBackendPort port2)
 {
     if (port1 == null || port2 == null)
     {
         return(false);
     }
     if (port2.Number != null && port2.Number == port1.Port)
     {
         return(true);
     }
     if (port2.Name != null && string.Equals(port2.Name, port1.Name, StringComparison.Ordinal))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
 private static bool MatchesPort(V1EndpointPort port1, IntstrIntOrString port2)
 {
     if (port1 == null || port2 == null)
     {
         return(false);
     }
     if (int.TryParse(port2, out var port2Number) && port2Number == port1.Port)
     {
         return(true);
     }
     if (string.Equals(port2, port1.Name, StringComparison.OrdinalIgnoreCase))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
        private KubernetesServiceInstance AssertServiceInstance(bool secure)
        {
            var address = new V1EndpointAddress {
                Ip = "1.2.3.4"
            };
            var port = new V1EndpointPort {
                Port = 8080
            };
            var instance = new KubernetesServiceInstance("123", "myString", address, port, new Dictionary <string, string>(), secure);

            Assert.Equal(expected: "123", actual: instance.InstanceId);
            Assert.Equal(expected: "myString", actual: instance.ServiceId);
            Assert.Equal(expected: "1.2.3.4", actual: instance.Host);
            Assert.Equal(expected: 8080, actual: instance.Port);
            Assert.Equal(expected: secure, actual: instance.IsSecure);
            Assert.Equal(expected: secure ? "https" : "http", actual: instance.GetScheme());
            return(instance);
        }