Exemple #1
0
        protected override void ConfigureContainer(ContainerBuilder builder, CommonOptions options)
        {
            // Setting extensions here as in the new Modularity world we don't register extensions
            // and GetAllAssembliesToRegister doesn't get passed CommonOptions
            extensions = options.Extensions;

            base.ConfigureContainer(builder, options);

            builder.RegisterType <CalamariCertificateStore>().As <ICertificateStore>().SingleInstance();
            builder.RegisterType <DeploymentJournalWriter>().As <IDeploymentJournalWriter>().SingleInstance();
            builder.RegisterType <PackageStore>().As <IPackageStore>().SingleInstance();

            builder.RegisterAssemblyTypes(GetAllAssembliesToRegister().ToArray())
            .AssignableTo <ICommandWithArgs>()
            .WithMetadataFrom <CommandAttribute>()
            .As <ICommandWithArgs>();

            builder.RegisterAssemblyTypes(GetProgramAssemblyToRegister())
            .Where(x => typeof(ILaunchTool).IsAssignableFrom(x) && !x.IsAbstract && !x.IsInterface)
            .WithMetadataFrom <LaunchToolAttribute>()
            .As <ILaunchTool>();
        }
Exemple #2
0
        protected override void ConfigureContainer(ContainerBuilder builder, CommonOptions options)
        {
            // Setting extensions here as in the new Modularity world we don't register extensions
            // and GetAllAssembliesToRegister doesn't get passed CommonOptions
            extensions = options.Extensions;

            base.ConfigureContainer(builder, options);

            builder.RegisterType <CalamariCertificateStore>().As <ICertificateStore>().SingleInstance();
            builder.RegisterType <DeploymentJournalWriter>().As <IDeploymentJournalWriter>().SingleInstance();
            builder.RegisterType <PackageStore>().As <IPackageStore>().SingleInstance();

            builder.RegisterAssemblyTypes(GetExtensionAssemblies().ToArray())
            .AssignableTo <IDoesDeploymentTargetTypeHealthChecks>()
            .As <IDoesDeploymentTargetTypeHealthChecks>()
            .SingleInstance();

            builder.RegisterAssemblyTypes(GetAllAssembliesToRegister().ToArray())
            .AssignableTo <ICommandWithArgs>()
            .Where(t => t.GetCustomAttribute <CommandAttribute>().Name
                   .Equals(options.Command, StringComparison.OrdinalIgnoreCase))
            .As <ICommandWithArgs>();
        }
Exemple #3
0
        protected virtual int Run(string[] args)
        {
            try
            {
                SecurityProtocols.EnableAllSecurityProtocols();
                var options = CommonOptions.Parse(args);

                log.Verbose($"Calamari Version: {this.GetType().Assembly.GetInformationalVersion()}");

                if (options.Command.Equals("version", StringComparison.OrdinalIgnoreCase))
                {
                    return(0);
                }

                var envInfo = string.Join($"{Environment.NewLine}  ",
                                          EnvironmentHelper.SafelyGetEnvironmentInformation());
                log.Verbose($"Environment Information: {Environment.NewLine}  {envInfo}");

                EnvironmentHelper.SetEnvironmentVariable("OctopusCalamariWorkingDirectory",
                                                         Environment.CurrentDirectory);
                ProxyInitializer.InitializeDefaultProxy();

                var builder = new ContainerBuilder();
                ConfigureContainer(builder, options);
                using (var container = builder.Build())
                {
                    container.Resolve <VariableLogger>().LogVariables();

                    return(ResolveAndExecuteCommand(container, options));
                }
            }
            catch (Exception ex)
            {
                return(ConsoleFormatter.PrintError(ConsoleLog.Instance, ex));
            }
        }