public override int Execute(string[] commandLineArguments)
        {
            Options.Parse(commandLineArguments);

            Guard.NotNullOrWhiteSpace(packageFile, "No package file was specified. Please pass -cspkg YourPackage.cspkg");

            if (!File.Exists(packageFile))
                throw new CommandException("Could not find package file: " + packageFile);    

            var variables = new CalamariVariableDictionary();
            variables.Set(SpecialVariables.Action.Azure.CloudServicePackagePath, packageFile);
            variables.Set(SpecialVariables.OriginalPackageDirectoryPath, !string.IsNullOrWhiteSpace(destinationDirectory) ? destinationDirectory : Path.GetDirectoryName(packageFile));

            var fileSystem = new WindowsPhysicalFileSystem();

            var conventions = new List<IConvention>
            {
                new EnsureCloudServicePackageIsCtpFormatConvention(fileSystem),
                new ExtractAzureCloudServicePackageConvention(fileSystem),
            };

            var deployment = new RunningDeployment(packageFile, variables);
            var conventionRunner = new ConventionProcessor(deployment, conventions);
            conventionRunner.RunConventions();

            return 0;
        }
 public void SetUp()
 {
     variables = new CalamariVariableDictionary();
     variables.Set(SpecialVariables.OriginalPackageDirectoryPath, stagingDirectory);
     fileSystem = Substitute.For<ICalamariFileSystem>();
     deployment = new RunningDeployment(packageFilePath, variables);
 }
Ejemplo n.º 3
0
 private CalamariVariableDictionary GetDictionaryWithSecret()
 {
     var cd = new CalamariVariableDictionary();
     cd.Set("foo", "bar");
     cd.SetSensitive("mysecrect", "KingKong");
     return cd;
 }
        public void SetUp()
        {
            fileSystem = Substitute.For<ICalamariFileSystem>();
            packageUploader = Substitute.For<IAzurePackageUploader>();
            credentialsFactory = Substitute.For<ISubscriptionCloudCredentialsFactory>();
            credentialsFactory.GetCredentials(azureSubscriptionId, certificateThumbprint, certificateBytes)
                .Returns(new FakeSubscriptionCloudCredentials(azureSubscriptionId));

            variables = new CalamariVariableDictionary();
            variables.Set(SpecialVariables.OriginalPackageDirectoryPath, stagingDirectory);
            variables.Set(SpecialVariables.Action.Azure.SubscriptionId, azureSubscriptionId);
            variables.Set(SpecialVariables.Action.Azure.CertificateThumbprint, certificateThumbprint);
            variables.Set(SpecialVariables.Action.Azure.CertificateBytes, certificateBytes);
            variables.Set(SpecialVariables.Action.Azure.StorageAccountName, storageAccountName);
            deployment = new RunningDeployment(stagingDirectory, variables);

            convention = new UploadAzureCloudServicePackageConvention(fileSystem, packageUploader, credentialsFactory);
        }
        public void SetUp()
        {
            fileSystem = Substitute.For<ICalamariFileSystem>();
            variables = new CalamariVariableDictionary();
            variables.Set(SpecialVariables.OriginalPackageDirectoryPath, StagingDirectory);
            deployment = new RunningDeployment(StagingDirectory, variables);

            convention = new ChooseCloudServiceConfigurationFileConvention(fileSystem);
        }
        public void SetUp()
        {
            fileSystem = Substitute.For<ICalamariFileSystem>();
            configurationTransformer = Substitute.For<IConfigurationTransformer>();

            variables = new CalamariVariableDictionary();
            variables.Set(SpecialVariables.OriginalPackageDirectoryPath, stagingDirectory);

            deployment = new RunningDeployment("C:\\packages", variables);
        }
        public void SetUp()
        {
            fileSystem = new WindowsPhysicalFileSystem();
            configurationTransformer = Substitute.For<IConfigurationTransformer>();

            var deployDirectory = BuildConfigPath(null);

            variables = new CalamariVariableDictionary();
            variables.Set(SpecialVariables.OriginalPackageDirectoryPath, deployDirectory);

            deployment = new RunningDeployment(deployDirectory, variables);
        }
        public void SetUp()
        {
            fileSystem = Substitute.For<ICalamariFileSystem>();
            scriptEngine = Substitute.For<IScriptEngine>();
            commandLineRunner = Substitute.For<ICommandLineRunner>();

            scriptEngine.GetSupportedExtensions().Returns(new string[] { "ps1" });

            variables = new CalamariVariableDictionary();
            variables.Set(SpecialVariables.Package.EnabledFeatures, SpecialVariables.Features.CustomScripts);

            deployment = new RunningDeployment("C:\\packages", variables) { StagingDirectory = stagingDirectory };
        }
Ejemplo n.º 9
0
        public CommandResult ExecuteScript(IScriptEngine scriptEngine, string scriptFile, CalamariVariableDictionary variables, ICommandLineRunner commandLineRunner)
        {
            var workingDirectory = Path.GetDirectoryName(scriptFile);
            variables.Set("OctopusAzureTargetScript", scriptFile);

            // If the Azure PowerShell module to use has not been explicitly configured, then default to the version
            // bundled with Calamari
            SetOutputVariable(SpecialVariables.Action.Azure.Output.ModulePath,
                variables.Get(SpecialVariables.Action.Azure.PowerShellModulePath, BuiltInAzurePowershellModulePath), variables);

            SetOutputVariable(SpecialVariables.Action.Azure.Output.SubscriptionId, variables.Get(SpecialVariables.Action.Azure.SubscriptionId), variables);
            SetOutputVariable(SpecialVariables.Action.Azure.Output.SubscriptionName, variables.Get(SpecialVariables.Account.Name), variables);

            using (new TemporaryFile(CreateAzureCertificate(workingDirectory, variables)))
            using (var contextScriptFile = new TemporaryFile(CreateContextScriptFile(workingDirectory)))
            {
                return scriptEngine.Execute(contextScriptFile.FilePath, variables, commandLineRunner);
            }
        }
        public void SetUp()
        {
            result = null;

            fileSystem = Substitute.For<ICalamariFileSystem>();
            credentialsFactory = Substitute.For<ISubscriptionCloudCredentialsFactory>();
            configurationRetriever = Substitute.For<IAzureCloudServiceConfigurationRetriever>(); 
            variables = new CalamariVariableDictionary();
            variables.Set(SpecialVariables.OriginalPackageDirectoryPath, StagingDirectory);
            deployment = new RunningDeployment(StagingDirectory, variables);

            variables.Set(SpecialVariables.Action.Azure.SubscriptionId, AzureSubscriptionId);
            variables.Set(SpecialVariables.Action.Azure.CertificateThumbprint, CertificateThumbprint);
            variables.Set(SpecialVariables.Action.Azure.CertificateBytes, CertificateBytes);
            variables.Set(SpecialVariables.Action.Azure.CloudServiceName, CloudServiceName);
            variables.Set(SpecialVariables.Action.Azure.Slot, DeploymentSlot.ToString());

            credentialsFactory.GetCredentials(AzureSubscriptionId, CertificateThumbprint, CertificateBytes)
                .Returns(new FakeSubscriptionCloudCredentials(AzureSubscriptionId));

            convention = new ConfigureAzureCloudServiceConvention(fileSystem, credentialsFactory, configurationRetriever);
        }