Exemple #1
0
        public async static Task Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .ReadFrom.Configuration(Configuration)
                         .Enrich.FromLogContext()
                         .CreateLogger();

            try
            {
                Log.Information("Host is starting...");

                var host = CreateHostBuilder(args).Build();

                await MigrationRepository.MigrateDatabase(host.Services);

                await MigrationRepository.SeedInitialData(host.Services);

                host.Run();

                Log.Information("Host is stopping...");
            }
            catch (Exception ex)
            {
                Log.Fatal(ex, "Host terminated unexpectedly");
            }
            finally
            {
                Log.CloseAndFlush();
            }
        }
Exemple #2
0
        public OctopusAsyncRepository(IOctopusAsyncClient client, RepositoryScope repositoryScope = null)
        {
            Client                    = client;
            Scope                     = repositoryScope ?? RepositoryScope.Unspecified();
            Accounts                  = new AccountRepository(this);
            ActionTemplates           = new ActionTemplateRepository(this);
            Artifacts                 = new ArtifactRepository(this);
            Backups                   = new BackupRepository(this);
            BuiltInPackageRepository  = new BuiltInPackageRepositoryRepository(this);
            CertificateConfiguration  = new CertificateConfigurationRepository(this);
            Certificates              = new CertificateRepository(this);
            Channels                  = new ChannelRepository(this);
            CommunityActionTemplates  = new CommunityActionTemplateRepository(this);
            Configuration             = new ConfigurationRepository(this);
            DashboardConfigurations   = new DashboardConfigurationRepository(this);
            Dashboards                = new DashboardRepository(this);
            Defects                   = new DefectsRepository(this);
            DeploymentProcesses       = new DeploymentProcessRepository(this);
            Deployments               = new DeploymentRepository(this);
            Environments              = new EnvironmentRepository(this);
            Events                    = new EventRepository(this);
            FeaturesConfiguration     = new FeaturesConfigurationRepository(this);
            Feeds                     = new FeedRepository(this);
            Interruptions             = new InterruptionRepository(this);
            LibraryVariableSets       = new LibraryVariableSetRepository(this);
            Lifecycles                = new LifecyclesRepository(this);
            MachinePolicies           = new MachinePolicyRepository(this);
            MachineRoles              = new MachineRoleRepository(this);
            Machines                  = new MachineRepository(this);
            Migrations                = new MigrationRepository(this);
            OctopusServerNodes        = new OctopusServerNodeRepository(this);
            PerformanceConfiguration  = new PerformanceConfigurationRepository(this);
            PackageMetadataRepository = new PackageMetadataRepository(this);
            ProjectGroups             = new ProjectGroupRepository(this);
            Projects                  = new ProjectRepository(this);
            ProjectTriggers           = new ProjectTriggerRepository(this);
            Proxies                   = new ProxyRepository(this);
            Releases                  = new ReleaseRepository(this);
            RetentionPolicies         = new RetentionPolicyRepository(this);
            Schedulers                = new SchedulerRepository(this);
            ServerStatus              = new ServerStatusRepository(this);
            Spaces                    = new SpaceRepository(this);
            Subscriptions             = new SubscriptionRepository(this);
            TagSets                   = new TagSetRepository(this);
            Tasks                     = new TaskRepository(this);
            Teams                     = new TeamsRepository(this);
            Tenants                   = new TenantRepository(this);
            TenantVariables           = new TenantVariablesRepository(this);
            UserInvites               = new UserInvitesRepository(this);
            UserRoles                 = new UserRolesRepository(this);
            Users                     = new UserRepository(this);
            VariableSets              = new VariableSetRepository(this);
            Workers                   = new WorkerRepository(this);
            WorkerPools               = new WorkerPoolRepository(this);
            ScopedUserRoles           = new ScopedUserRoleRepository(this);
            UserPermissions           = new UserPermissionsRepository(this);

            loadRootResource      = new Lazy <Task <RootResource> >(LoadRootDocumentInner, true);
            loadSpaceRootResource = new Lazy <Task <SpaceRootResource> >(LoadSpaceRootDocumentInner, true);
        }
 public Task <int> Interceptor(
     InterceptorExecutionDelegate next, CancellationToken cancellationToken,
     JiraApiSettings jiraApiSettings, WorkspaceSettings workspaceSettings)
 {
     _jiraContext         = new JiraContext(jiraApiSettings, workspaceSettings, cancellationToken);
     _migrationRepository = new MigrationRepository(_jiraContext.LocalDirs);
     return(next());
 }
Exemple #4
0
        /// <summary>
        /// Constructor for Migration Worker to store the connection string and Database Name
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="databaseName"></param>
        public MigrationWorker(string connectionString, string databaseName)
        {
            _connectionString = connectionString;
            _databaseName     = databaseName;

            conn = new MySqlConnectionFactory(_connectionString, _databaseName);

            _repository = new MigrationRepository(conn);
        }
        public void SetUp()
        {
            _dir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            _database = MockRepository.GenerateStub <IDatabase>();
            _target   = new MigrationRepository(_dir, Encoding.UTF8, _database);

            Directory.CreateDirectory(_dir);
        }
        public void SetUp()
        {
            _dir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            _database = MockRepository.GenerateStub<IDatabase>();
            _target = new MigrationRepository(_dir, Encoding.UTF8, _database);

            Directory.CreateDirectory(_dir);
        }
Exemple #7
0
 public Repositories(string connectionString)
 {
     MigrationRepository    = new MigrationRepository(connectionString);
     UserRepository         = new UserRepository(connectionString);
     UserRoleRepository     = new UserRoleRepository(connectionString);
     UserRoleUserRepository = new UserRoleUserRepository(connectionString);
     PostRepository         = new PostRepository(connectionString);
     CommentRepository      = new CommentRepository(connectionString);
 }
        public OctopusAsyncRepository(IOctopusAsyncClient client)
        {
            this.Client = client;

            Accounts                 = new AccountRepository(client);
            ActionTemplates          = new ActionTemplateRepository(client);
            Artifacts                = new ArtifactRepository(client);
            Backups                  = new BackupRepository(client);
            BuiltInPackageRepository = new BuiltInPackageRepositoryRepository(client);
            CertificateConfiguration = new CertificateConfigurationRepository(client);
            Certificates             = new CertificateRepository(client);
            Channels                 = new ChannelRepository(client);
            CommunityActionTemplates = new CommunityActionTemplateRepository(client);
            Configuration            = new ConfigurationRepository(client);
            DashboardConfigurations  = new DashboardConfigurationRepository(client);
            Dashboards               = new DashboardRepository(client);
            Defects                  = new DefectsRepository(client);
            DeploymentProcesses      = new DeploymentProcessRepository(client);
            Deployments              = new DeploymentRepository(client);
            Environments             = new EnvironmentRepository(client);
            Events = new EventRepository(client);
            FeaturesConfiguration = new FeaturesConfigurationRepository(client);
            Feeds                    = new FeedRepository(client);
            Interruptions            = new InterruptionRepository(client);
            LibraryVariableSets      = new LibraryVariableSetRepository(client);
            Lifecycles               = new LifecyclesRepository(client);
            MachinePolicies          = new MachinePolicyRepository(client);
            MachineRoles             = new MachineRoleRepository(client);
            Machines                 = new MachineRepository(client);
            Migrations               = new MigrationRepository(client);
            OctopusServerNodes       = new OctopusServerNodeRepository(client);
            PerformanceConfiguration = new PerformanceConfigurationRepository(client);
            ProjectGroups            = new ProjectGroupRepository(client);
            Projects                 = new ProjectRepository(client);
            ProjectTriggers          = new ProjectTriggerRepository(client);
            Proxies                  = new ProxyRepository(client);
            Releases                 = new ReleaseRepository(client);
            RetentionPolicies        = new RetentionPolicyRepository(client);
            Schedulers               = new SchedulerRepository(client);
            ServerStatus             = new ServerStatusRepository(client);
            Subscriptions            = new SubscriptionRepository(client);
            TagSets                  = new TagSetRepository(client);
            Tasks                    = new TaskRepository(client);
            Teams                    = new TeamsRepository(client);
            Tenants                  = new TenantRepository(client);
            TenantVariables          = new TenantVariablesRepository(client);
            UserRoles                = new UserRolesRepository(client);
            Users                    = new UserRepository(client);
            VariableSets             = new VariableSetRepository(client);
            Workers                  = new WorkerRepository(client);
            WorkerPools              = new WorkerPoolRepository(client);
        }
        public async Task Get_MigrationValue()
        {
            var config = new SystemDataLayerConfig
            {
                SurveillanceAuroraConnectionString =
                    "server=127.0.0.1; port=3306;uid=root;pwd='drunkrabbit101';database=dev_surveillance; Allow User Variables=True"
            };
            var repository = new MigrationRepository(new ConnectionStringFactory(config), this._logger);

            var version = await repository.LatestMigrationVersion();

            Assert.AreEqual(version, 0);
        }
Exemple #10
0
        public WorkItemImporter(bool force, MigrationRepository migrationRepository, AdoContext adoContext,
                                JiraContext jiraContext, StatusCsvMapper statusMapper, IssueTypeCsvMapper issueTypeCsvMapper)
        {
            // TODO: interface for the mappers to alternate mapping strategies

            _force = force;
            _migrationRepository = migrationRepository ?? throw new ArgumentNullException(nameof(migrationRepository));
            _adoContext          = adoContext ?? throw new ArgumentNullException(nameof(adoContext));
            _jiraContext         = jiraContext ?? throw new ArgumentNullException(nameof(jiraContext));
            _statusMapper        = statusMapper ?? throw new ArgumentNullException(nameof(statusMapper));
            _issueTypeCsvMapper  = issueTypeCsvMapper ?? throw new ArgumentNullException(nameof(issueTypeCsvMapper));

            _adoApi  = _adoContext.Api;
            _jiraApi = _jiraContext.Api;
        }
Exemple #11
0
        public Task <int> Intercept(
            InterceptorExecutionDelegate next,
            AdoApiSettings adoApiSettings, WorkspaceSettings workspaceSettings, JiraApiSettings jiraApiSettings)
        {
            _adoContext = new AdoContext(adoApiSettings, _cancellationToken);
            if (!_adoContext.TryConnect())
            {
                _console.Out.WriteLine("Unable to connect to TFS");
                return(Task.FromResult(1));
            }
            _jiraContext              = new JiraContext(jiraApiSettings, workspaceSettings, _cancellationToken);
            _migrationRepository      = new MigrationRepository(_jiraContext.LocalDirs);
            _migrationMetaDataService = new MigrationMetaDataService(_jiraContext);

            return(next());
        }
        protected override void ConfigureWebHost(IWebHostBuilder builder)
        {
            builder.ConfigureServices(services =>
            {
                // Remove the app's ApplicationDbContext registration.
                var descriptor = services.SingleOrDefault(
                    d => d.ServiceType ==
                    typeof(DbContextOptions <ApplicationDbContext>));

                if (descriptor != null)
                {
                    services.Remove(descriptor);
                }

                // Add ApplicationDbContext using a test database for testing
                services.AddDbContext <ApplicationDbContext>(options =>
                                                             options.UseSqlServer(
                                                                 TestConstants.DbConnection,
                                                                 b => b.MigrationsAssembly(typeof(ApplicationDbContext).Assembly.FullName))
                                                             );

                services.AddAuthentication("Test")
                .AddScheme <AuthenticationSchemeOptions, TestAuthenticationHandler>(
                    "Test", options => { });

                // Build the service provider.
                var serviceProvider = services.BuildServiceProvider();

                // wait for migration data
                MigrationRepository.MigrateDatabase(serviceProvider).Wait();
                MigrationRepository.SeedInitialData(serviceProvider).Wait();

                // seed some sample data
                PrepareSampleData(serviceProvider);
            })
            .UseEnvironment("Test");
        }
 public void SetUp()
 {
     _repository = MockRepository.GenerateStub<MigrationRepository>("", Encoding.UTF8, null);
     _database = MockRepository.GenerateStub<IDatabase>();
     _target = new MigrationFilter(_repository, _database);
 }
Exemple #14
0
 public void SetUp()
 {
     _repository = MockRepository.GenerateStub <MigrationRepository>("", Encoding.UTF8, null);
     _database   = MockRepository.GenerateStub <IDatabase>();
     _target     = new MigrationFilter(_repository, _database);
 }
        public OctopusRepository(IOctopusClient client, RepositoryScope repositoryScope = null)
        {
#if FULL_FRAMEWORK
            LocationChecker.CheckAssemblyLocation();
#endif
            Client                           = client;
            Scope                            = repositoryScope ?? RepositoryScope.Unspecified();
            Accounts                         = new AccountRepository(this);
            ActionTemplates                  = new ActionTemplateRepository(this);
            Artifacts                        = new ArtifactRepository(this);
            Backups                          = new BackupRepository(this);
            BuiltInPackageRepository         = new BuiltInPackageRepositoryRepository(this);
            BuildInformationRepository       = new BuildInformationRepository(this);
            CertificateConfiguration         = new CertificateConfigurationRepository(this);
            Certificates                     = new CertificateRepository(this);
            Channels                         = new ChannelRepository(this);
            CommunityActionTemplates         = new CommunityActionTemplateRepository(this);
            Configuration                    = new ConfigurationRepository(this);
            DashboardConfigurations          = new DashboardConfigurationRepository(this);
            Dashboards                       = new DashboardRepository(this);
            Defects                          = new DefectsRepository(this);
            DeploymentProcesses              = new DeploymentProcessRepository(this);
            DeploymentSettings               = new DeploymentSettingsRepository(this);
            Deployments                      = new DeploymentRepository(this);
            Environments                     = new EnvironmentRepository(this);
            Events                           = new EventRepository(this);
            FeaturesConfiguration            = new FeaturesConfigurationRepository(this);
            Feeds                            = new FeedRepository(this);
            Interruptions                    = new InterruptionRepository(this);
            LibraryVariableSets              = new LibraryVariableSetRepository(this);
            Lifecycles                       = new LifecyclesRepository(this);
            Licenses                         = new LicensesRepository(this);
            MachinePolicies                  = new MachinePolicyRepository(this);
            MachineRoles                     = new MachineRoleRepository(this);
            Machines                         = new MachineRepository(this);
            Migrations                       = new MigrationRepository(this);
            OctopusServerNodes               = new OctopusServerNodeRepository(this);
            PerformanceConfiguration         = new PerformanceConfigurationRepository(this);
            ProjectGroups                    = new ProjectGroupRepository(this);
            Projects                         = new ProjectRepository(this);
            Runbooks                         = new RunbookRepository(this);
            RunbookProcesses                 = new RunbookProcessRepository(this);
            RunbookSnapshots                 = new RunbookSnapshotRepository(this);
            RunbookRuns                      = new RunbookRunRepository(this);
            ProjectTriggers                  = new ProjectTriggerRepository(this);
            Proxies                          = new ProxyRepository(this);
            Releases                         = new ReleaseRepository(this);
            RetentionPolicies                = new RetentionPolicyRepository(this);
            Schedulers                       = new SchedulerRepository(this);
            ServerStatus                     = new ServerStatusRepository(this);
            Spaces                           = new SpaceRepository(this);
            Subscriptions                    = new SubscriptionRepository(this);
            TagSets                          = new TagSetRepository(this);
            Tasks                            = new TaskRepository(this);
            Teams                            = new TeamsRepository(this);
            TelemetryConfigurationRepository = new TelemetryConfigurationRepository(this);
            Tenants                          = new TenantRepository(this);
            TenantVariables                  = new TenantVariablesRepository(this);
            UserRoles                        = new UserRolesRepository(this);
            Users                            = new UserRepository(this);
            VariableSets                     = new VariableSetRepository(this);
            Workers                          = new WorkerRepository(this);
            WorkerPools                      = new WorkerPoolRepository(this);
            ScopedUserRoles                  = new ScopedUserRoleRepository(this);
            UserPermissions                  = new UserPermissionsRepository(this);
            UserTeams                        = new UserTeamsRepository(this);
            UserInvites                      = new UserInvitesRepository(this);
            UpgradeConfiguration             = new UpgradeConfigurationRepository(this);
            loadRootResource                 = new Lazy <RootResource>(LoadRootDocumentInner, true);
            loadSpaceRootResource            = new Lazy <SpaceRootResource>(LoadSpaceRootDocumentInner, true);
        }