protected void DoDiscovery(AwsAuthenticationDetails authenticationDetails)
        {
            var scope = new TargetDiscoveryScope("TestSpace",
                                                 "Staging",
                                                 "testProject",
                                                 null,
                                                 new[] { "discovery-role" },
                                                 "WorkerPools-1");

            var targetDiscoveryContext =
                new TargetDiscoveryContext <AwsAuthenticationDetails>(scope,
                                                                      authenticationDetails);

            var result =
                ExecuteDiscoveryCommand(targetDiscoveryContext,
                                        new[] { "Calamari.Aws" }
                                        );

            result.AssertSuccess();
        }
示例#2
0
        public void DiscoverKubernetesClusterWithAzureServicePrincipalAccount()
        {
            var serviceMessageCollectorLog = new ServiceMessageCollectorLog();

            Log = serviceMessageCollectorLog;

            var scope = new TargetDiscoveryScope("TestSpace",
                                                 "Staging",
                                                 "testProject",
                                                 null,
                                                 new[] { "discovery-role" },
                                                 "WorkerPool-1");

            var account = new ServicePrincipalAccount(
                ExternalVariables.Get(ExternalVariable.AzureSubscriptionId),
                ExternalVariables.Get(ExternalVariable.AzureSubscriptionClientId),
                ExternalVariables.Get(ExternalVariable.AzureSubscriptionTenantId),
                ExternalVariables.Get(ExternalVariable.AzureSubscriptionPassword),
                null,
                null,
                null);

            var authenticationDetails =
                new AccountAuthenticationDetails <ServicePrincipalAccount>(
                    "Azure",
                    "Accounts-1",
                    account);

            var targetDiscoveryContext =
                new TargetDiscoveryContext <AccountAuthenticationDetails <ServicePrincipalAccount> >(scope,
                                                                                                     authenticationDetails);

            var result =
                ExecuteDiscoveryCommand(targetDiscoveryContext,
                                        new[] { "Calamari.Azure" }
                                        );

            result.AssertSuccess();

            var targetName             = $"aks/{azureSubscriptionId}/{azurermResourceGroup}/{aksClusterName}";
            var expectedServiceMessage = new ServiceMessage(
                KubernetesDiscoveryCommand.CreateKubernetesTargetServiceMessageName,
                new Dictionary <string, string>
            {
                { "name", targetName },
                { "clusterName", aksClusterName },
                { "clusterResourceGroup", azurermResourceGroup },
                { "skipTlsVerification", bool.TrueString },
                { "octopusDefaultWorkerPoolIdOrName", scope.WorkerPoolId },
                { "octopusAccountIdOrName", "Accounts-1" },
                { "octopusRoles", "discovery-role" },
                { "updateIfExisting", bool.TrueString },
                { "isDynamic", bool.TrueString },
                { "awsUseWorkerCredentials", bool.FalseString },
                { "awsAssumeRole", bool.FalseString },
            });

            serviceMessageCollectorLog.ServiceMessages.Should()
            .ContainSingle(s => s.Properties["name"] == targetName)
            .Which.Should()
            .BeEquivalentTo(expectedServiceMessage);
        }
 protected CalamariResult ExecuteDiscoveryCommand <TAuthenticationDetails>(
     TargetDiscoveryContext <TAuthenticationDetails> discoveryContext,
     IEnumerable <string> extensions,
     params (string key, string value)[] otherVariables)