Exemple #1
0
        /// <summary>
        /// HTTP ONLY
        /// </summary>
        /// <param name="url"></param>
        public static RpcClient Initialize(Uri url, string cerFilePath = null, WebProxy proxy = null)
        {
            var iocContainer = new TinyIoC.TinyIoCContainer();

            iocContainer.Register <IWsDataSerializer, ProtoBufRpcDataSerializer>(new ProtoBufRpcDataSerializer(), "default");
            iocContainer.Register <IRpcDataSerializer, HttpMultipartSerializer>(new HttpMultipartSerializer(), "default");
            iocContainer.Register <IRpcHeadSerializer, JsonRpcHeadSerializer>(new JsonRpcHeadSerializer(), "default");

            var _proxyFactory   = new RpcDynamicProxyFactory(url, proxy, iocContainer);
            var websocketServer = "";
            var client          = new RpcClient(_proxyFactory, proxy, iocContainer);

            if (!string.IsNullOrEmpty(cerFilePath))
            {
                if (!System.IO.File.Exists(cerFilePath))
                {
                    throw new Exception("the cer file you provided is not exists. " + Path.GetFileName(cerFilePath));
                }
                client.AddCertForHttps(cerFilePath);
            }
            if (url.Scheme == ("https"))
            {
                websocketServer = url.AbsoluteUri.Replace("https://", "wss://");
                if (!Certs.Any())
                {
                    throw new Exception("you should provide a cert when using https.");
                }
            }
            else
            {
                websocketServer = url.AbsoluteUri.Replace("http://", "ws://");
            }
            var cb = new RemoteCertificateValidationCallback(client.RemoteCertificateValidationCallback);

            _proxyFactory.ServerCertificateValidationCallback = cb;
            _proxyFactory.websocketServer = websocketServer;
            return(client);
        }
Exemple #2
0
        public override void WriteYaml(StreamWriter writer, AssetManager assetManager, ILoggerFactory loggerFactory,
                                       int indent = 0)
        {
            var spaces = "".PadLeft(indent);

            writer.Write($"{spaces}aks:\n");
            spaces = "".PadLeft(indent + 2);
            writer.Write($"{spaces}clusterName: {ClusterName}\n");
            writer.Write($"{spaces}dnsPrefix: {DnsPrefix}\n");
            writer.Write($"{spaces}version: {Version}\n");
            writer.Write($"{spaces}vmSize: {VmSize}\n");
            writer.Write($"{spaces}nodeCount: {NodeCount}\n");
            writer.Write($"{spaces}ownerUpn: {AksOwnerAadUpn}\n");

            writer.Write($"{spaces}access:\n");

            if (Readers?.Any() == true)
            {
                spaces = "".PadLeft(indent + 4);
                writer.Write($"{spaces}readers:");

                spaces = "".PadLeft(indent + 6);
                foreach (var aadIdentity in Readers)
                {
                    writer.Write($"{spaces}name: {aadIdentity.Name}\n");
                    writer.Write($"{spaces}type: {aadIdentity.Type}\n");
                }
            }

            if (Contributors?.Any() == true)
            {
                spaces = "".PadLeft(indent + 4);
                writer.Write($"{spaces}contributors:");

                spaces = "".PadLeft(indent + 6);
                foreach (var aadIdentity in Contributors)
                {
                    writer.Write($"{spaces}name: {aadIdentity.Name}\n");
                    writer.Write($"{spaces}type: {aadIdentity.Type}\n");
                }
            }

            if (Owners?.Any() == true)
            {
                spaces = "".PadLeft(indent + 4);
                writer.Write($"{spaces}owners:");

                spaces = "".PadLeft(indent + 6);
                foreach (var aadIdentity in Owners)
                {
                    writer.Write($"{spaces}name: {aadIdentity.Name}\n");
                    writer.Write($"{spaces}type: {aadIdentity.Type}\n");
                }
            }

            spaces = "".PadLeft(indent + 2);
            writer.Write($"{spaces}useDevSpaces: {UseDevSpaces}\n");
            writer.Write($"{spaces}useTerraform: {UseTerraform}\n");
            writer.Write($"{spaces}useIstio: {UseIstio}\n");
            writer.Write($"{spaces}useCertManager: {UseCertManager}\n");

            if (KeyVaultAccess?.Any() == true)
            {
                spaces = "".PadLeft(indent + 2);
                writer.Write($"{spaces}keyVaultAccess:\n");

                foreach (var option in KeyVaultAccess)
                {
                    spaces = "".PadLeft(indent + 4);
                    writer.Write($"{spaces}- {option}\n");
                }
            }

            if (Metrics?.Any() == true)
            {
                spaces = "".PadLeft(indent + 2);
                writer.Write($"{spaces}metrics:\n");

                foreach (var option in Metrics)
                {
                    spaces = "".PadLeft(indent + 4);
                    writer.Write($"{spaces}- {option}\n");
                }
            }

            if (Logging?.Any() == true)
            {
                spaces = "".PadLeft(indent + 2);
                writer.Write($"{spaces}logging:\n");

                foreach (var option in Logging)
                {
                    spaces = "".PadLeft(indent + 4);
                    writer.Write($"{spaces}- {option}\n");
                }
            }

            if (Tracing?.Any() == true)
            {
                spaces = "".PadLeft(indent + 2);
                writer.Write($"{spaces}tracing:\n");

                foreach (var option in Tracing)
                {
                    spaces = "".PadLeft(indent + 4);
                    writer.Write($"{spaces}- {option}\n");
                }
            }

            if (Ingress?.Any() == true)
            {
                spaces = "".PadLeft(indent + 2);
                writer.Write($"{spaces}ingress:\n");

                foreach (var option in Ingress)
                {
                    spaces = "".PadLeft(indent + 4);
                    writer.Write($"{spaces}- {option}\n");
                }
            }

            if (Certs?.Any() == true)
            {
                spaces = "".PadLeft(indent + 2);
                writer.Write($"{spaces}certs:\n");

                foreach (var cert in Certs)
                {
                    spaces = "".PadLeft(indent + 4);
                    writer.Write($"{spaces}- name: {cert.Name}\n");
                    if (!string.IsNullOrEmpty(cert.Type))
                    {
                        writer.Write($"{spaces}  type: {cert.Type}\n");
                    }
                }
            }

            if (Secrets != null)
            {
                spaces = "".PadLeft(indent + 2);
                writer.Write($"{spaces}secrets:\n");

                spaces = "".PadLeft(indent + 4);
                writer.Write($"{spaces}addContainerRegistryAccess: {Secrets.AddContainerRegistryAccess}\n");
                writer.Write($"{spaces}addKeyVaultAccess: {Secrets.AddKeyVaultAccess}\n");
                writer.Write($"{spaces}addAppInsightsKey: {Secrets.AddAppInsightsKey}\n");
            }
        }