internal CommandContext(ILogger logger, IAzure azure, VssConnection devops, INamingTemplates naming)
 {
     Logger = logger;
     Azure  = azure;
     Devops = devops;
     Naming = naming;
 }
 public AggregatorMappings(VssConnection devops, IAzure azure, ILogger logger, INamingTemplates naming)
 {
     this.devops = devops;
     this.azure  = azure;
     this.logger = logger;
     this.naming = naming;
 }
예제 #3
0
        internal async Task <CommandContext> BuildAsync(CancellationToken cancellationToken)
        {
            IAzure        azure  = null;
            VssConnection devops = null;

            if (azureLogon)
            {
                logger.WriteVerbose($"Authenticating to Azure...");
                var(connection, reason) = AzureLogon.Load();
                if (reason != LogonResult.Succeeded)
                {
                    string msg = TranslateResult(reason);
                    throw new InvalidOperationException(string.Format(msg, "Azure", "logon.azure"));
                }

                azure = connection.Logon();
                logger.WriteInfo($"Connected to subscription {azure.SubscriptionId}");
            }

            if (devopsLogon)
            {
                logger.WriteVerbose($"Authenticating to Azure DevOps...");
                var(connection, reason) = DevOpsLogon.Load();
                if (reason != LogonResult.Succeeded)
                {
                    string msg = TranslateResult(reason);
                    throw new InvalidOperationException(string.Format(msg, "Azure DevOps", "logon.ado"));
                }

                devops = await connection.LogonAsync(cancellationToken);

                logger.WriteInfo($"Connected to {devops.Uri.Host}");
            }

            INamingTemplates naming = null;

            switch (namingTemplate.ToLower())
            {
            case "builtin":
                goto case "";

            case "":
                naming = new BuiltInNamingTemplates();
                break;

            default:
                // implement custom Naming Templates, e.g. reading from a file
                naming = new FileNamingTemplates(File.ReadAllText(namingTemplate));
                break;
            }

            return(new CommandContext(logger, azure, devops, naming));
        }
 public AggregatorInstances(IAzure azure, ILogger logger, INamingTemplates naming)
     : base(azure, logger)
 {
     this.naming = naming;
 }