Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/api-e2e-mssql-multitenant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
- name: Copy admin api common folder to docker context
run: cp -r ../EdFi.Ods.AdminApi.Common ../../Docker/Application

- name: Copy Instance Management Provisioner folder to docker context
run: cp -r ../EdFi.AdminConsole.InstanceMgrWorker.Provisioner ../../Docker/Application

- name: Copy nuget config to docker context
run: cp ../NuGet.Config ../../Docker/Application

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/api-e2e-mssql-singletenant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
- name: Copy admin api common folder to docker context
run: cp -r ../EdFi.Ods.AdminApi.Common ../../Docker/Application

- name: Copy Instance Management Provisioner folder to docker context
run: cp -r ../EdFi.AdminConsole.InstanceMgrWorker.Provisioner ../../Docker/Application

- name: Copy nuget config to docker context
run: cp ../NuGet.Config ../../Docker/Application

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/api-e2e-pgsql-multitenant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
- name: Copy admin api common folder to docker context
run: cp -r ../EdFi.Ods.AdminApi.Common ../../Docker/Application

- name: Copy Instance Management Provisioner folder to docker context
run: cp -r ../EdFi.AdminConsole.InstanceMgrWorker.Provisioner ../../Docker/Application

- name: Copy nuget config to docker context
run: cp ../NuGet.Config ../../Docker/Application

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/api-e2e-pgsql-singletenant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
cp -r ../EdFi.Ods.AdminApi ../../Docker/Application
cp -r ../EdFi.Ods.AdminApi.AdminConsole ../../Docker/Application
cp -r ../EdFi.Ods.AdminApi.Common ../../Docker/Application
cp -r ../EdFi.AdminConsole.InstanceMgrWorker.Provisioner ../../Docker/Application

- name: Copy nuget config to docker context
run: cp ../NuGet.Config ../../Docker/Application
Expand Down
24 changes: 22 additions & 2 deletions Application/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<!-- JSON -->
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="NJsonSchema" Version="11.0.2" />
<PackageVersion Include="System.Text.Json" Version="9.0.0" />
<PackageVersion Include="System.Text.Json" Version="9.0.3" />

<!-- PostgreSQL -->
<PackageVersion Include="Npgsql" Version="8.0.6" />
Expand All @@ -78,6 +78,26 @@
<PackageVersion Include="Swashbuckle.AspNetCore.Filters" Version="8.0.2" />

<!-- System -->
<PackageVersion Include="System.Formats.Asn1" Version="9.0.0" />
<PackageVersion Include="System.Formats.Asn1" Version="9.0.3" />

<!-- Instance Management Worker -->
<PackageVersion Include="Dapper" Version="2.1.66" />
<PackageVersion Include="EdFi.Ods.Common" Version="5.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.4" />
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.3" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.3" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="9.0.1" />
<PackageVersion Include="Serilog" Version="4.2.0" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="9.0.1" />
<PackageVersion Include="System.Data.SqlClient" Version="4.9.0" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="9.0.3" />
<PackageVersion Include="Polly" Version="8.5.2" />
<PackageVersion Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageVersion Include="Quartz" Version="3.14.0" />
<PackageVersion Include="Quartz.Extensions.DependencyInjection" Version="3.14.0" />
<PackageVersion Include="Quartz.Extensions.Hosting" Version="3.14.0" />
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions Application/Ed-Fi-ODS-AdminApi.sln
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EdFi.Ods.AdminApi.Common.Un
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EdFi.Ods.AdminApi.AdminConsole.UnitTests", "EdFi.Ods.AdminApi.AdminConsole.UnitTests\EdFi.Ods.AdminApi.AdminConsole.UnitTests.csproj", "{7C919128-B651-4756-8625-A8F7882FA9A4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EdFi.AdminConsole.InstanceMgrWorker.Configuration", "EdFi.AdminConsole.InstanceMgrWorker.Provisioner\EdFi.AdminConsole.InstanceMgrWorker.Configuration.csproj", "{1370EB3F-F4B7-4396-8BBD-B8572908A6B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -102,6 +104,14 @@ Global
{7C919128-B651-4756-8625-A8F7882FA9A4}.Release|Any CPU.Build.0 = Release|Any CPU
{7C919128-B651-4756-8625-A8F7882FA9A4}.Release|x64.ActiveCfg = Release|Any CPU
{7C919128-B651-4756-8625-A8F7882FA9A4}.Release|x64.Build.0 = Release|Any CPU
{1370EB3F-F4B7-4396-8BBD-B8572908A6B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1370EB3F-F4B7-4396-8BBD-B8572908A6B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1370EB3F-F4B7-4396-8BBD-B8572908A6B3}.Debug|x64.ActiveCfg = Debug|Any CPU
{1370EB3F-F4B7-4396-8BBD-B8572908A6B3}.Debug|x64.Build.0 = Debug|Any CPU
{1370EB3F-F4B7-4396-8BBD-B8572908A6B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1370EB3F-F4B7-4396-8BBD-B8572908A6B3}.Release|Any CPU.Build.0 = Release|Any CPU
{1370EB3F-F4B7-4396-8BBD-B8572908A6B3}.Release|x64.ActiveCfg = Release|Any CPU
{1370EB3F-F4B7-4396-8BBD-B8572908A6B3}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
5 changes: 5 additions & 0 deletions Application/Ed-Fi-ODS-AdminApi.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ See the LICENSE and NOTICES files in the project root for more information.</s:S
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=LocalConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=15b5b1f1_002D457c_002D4ca6_002Db278_002D5615aedc07d3/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static readonly fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=53eecf85_002Dd821_002D40e8_002Dac97_002Dfdb734542b84/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Instance fields (not private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=70345118_002D4b40_002D4ece_002D937c_002Dbbeb7a0b2e70/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static fields (not private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=a4f433b8_002Dabcd_002D4e55_002Da08f_002D82e78cef0f0c/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Any" AccessRightKinds="Any" Description="Local constants"&gt;&lt;ElementKinds&gt;&lt;Kind Name="LOCAL_CONSTANT" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FCONSTANT/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FFUNCTION/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FVARIABLE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
Expand Down Expand Up @@ -188,6 +192,7 @@ See the LICENSE and NOTICES files in the project root for more information.</s:S
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=edfi/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Encryptor/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>c0ecdf69-7e69-4ccf-9854-b82da0d9e253</UserSecretsId>
<Configurations>Debug;Release</Configurations>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity"/>
<PackageReference Include="Dapper" />
<PackageReference Include="EdFi.Ods.Common" />
<PackageReference Include="EdFi.Suite3.Admin.DataAccess" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="Npgsql" />
<PackageReference Include="Serilog" />
<PackageReference Include="SonarAnalyzer.CSharp" >
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Data.SqlClient" />
<PackageReference Include="System.Net.Http" />
<PackageReference Include="System.Text.RegularExpressions" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: Apache-2.0
// Licensed to the Ed-Fi Alliance under one or more agreements.
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
// See the LICENSE and NOTICES files in the project root for more information.

using Microsoft.Extensions.Configuration;

namespace EdFi.AdminConsole.InstanceMgrWorker.Configuration.Provisioners
{
public class ConfigConnectionStringsProvider(IConfiguration config) : IMgrWorkerConfigConnectionStringsProvider
{
private string _tenant = string.Empty;
private readonly IConfiguration _config = config;

public int Count => ConnectionStringProviderByName.Keys.Count;

public IDictionary<string, string> ConnectionStringProviderByName
{
get
{
#pragma warning disable CS8619 // Nullability of reference types in value doesn't match target type.
if (!string.IsNullOrEmpty(_tenant) && !_tenant.Equals("default", StringComparison.OrdinalIgnoreCase))
return _config.GetSection($"Tenants:{_tenant}:ConnectionStrings")
.GetChildren()
.ToDictionary(k => k.Key, v => v.Value);
else
return _config.GetSection("ConnectionStrings")
.GetChildren()
.ToDictionary(k => k.Key, v => v.Value);
#pragma warning restore CS8619 // Nullability of reference types in value doesn't match target type.
}
}

public void SetTenant(string tenant) => _tenant = tenant;

public string GetConnectionString(string name) => ConnectionStringProviderByName[name];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: Apache-2.0
// Licensed to the Ed-Fi Alliance under one or more agreements.
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
// See the LICENSE and NOTICES files in the project root for more information.

namespace EdFi.AdminConsole.InstanceMgrWorker.Configuration.Provisioners
{
public enum DbInstanceType
{
Minimal,
Sample
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: Apache-2.0
// Licensed to the Ed-Fi Alliance under one or more agreements.
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
// See the LICENSE and NOTICES files in the project root for more information.

namespace EdFi.AdminConsole.InstanceMgrWorker.Configuration.Provisioners
{
public interface IInstanceProvisioner
{
void AddDbInstance(string instanceName, DbInstanceType instanceType);

void AddDbInstance(string instanceName, DbInstanceType instanceType, bool useSuffix);

void DeleteDbInstances(params string[] deletedClientKeys);

void RenameDbInstances(string oldName, string newName);

InstanceStatus GetDbInstanceStatus(string clientKey);

void ResetDemoDbInstance();

string[] GetInstancesDatabases();

string GetOdsConnectionString(string instanceName);

string Tenant { get; set; }

Task AddDbInstanceAsync(string instanceName, DbInstanceType instanceType);

Task AddDbInstanceAsync(string instanceName, DbInstanceType instanceType, bool useSuffix);

Task DeleteDbInstancesAsync(params string[] deletedClientKeys);

Task RenameDbInstancesAsync(string oldName, string newName);

Task<InstanceStatus> GetDbInstanceStatusAsync(string clientKey);

Task ResetDemoDbInstanceAsync();

Task<string[]> GetInstancesDatabasesAsync();

Task CopyDbInstanceAsync(string originalDatabaseName, string newDatabaseName);

Task<bool> CheckDatabaseExists(string instanceName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: Apache-2.0
// Licensed to the Ed-Fi Alliance under one or more agreements.
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
// See the LICENSE and NOTICES files in the project root for more information.

using EdFi.Ods.Common.Configuration;

namespace EdFi.AdminConsole.InstanceMgrWorker.Configuration.Provisioners;

public interface IMgrWorkerConfigConnectionStringsProvider : IConfigConnectionStringsProvider
{
void SetTenant(string tenant);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: Apache-2.0
// Licensed to the Ed-Fi Alliance under one or more agreements.
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
// See the LICENSE and NOTICES files in the project root for more information.

using EdFi.Admin.DataAccess.Utils;

namespace EdFi.AdminConsole.InstanceMgrWorker.Configuration.Provisioners;

public interface IMgrWorkerIDatabaseNameBuilder : IDatabaseNameBuilder
{
string OdsDatabaseName(string? tenant, string databaseName);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// SPDX-License-Identifier: Apache-2.0
// Licensed to the Ed-Fi Alliance under one or more agreements.
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
// See the LICENSE and NOTICES files in the project root for more information.

using EdFi.Ods.Common.Database;
using EdFi.Ods.Common.Extensions;

namespace EdFi.AdminConsole.InstanceMgrWorker.Configuration.Provisioners
{
public class InstanceDatabaseNameBuilder : IMgrWorkerIDatabaseNameBuilder
{
private const string TemplatePrefix = "Ods_";
private const string TemplateMinimalDatabase = TemplatePrefix + "Minimal_Template";

private string? _tenant { get; set; }
private readonly Lazy<string> _databaseNameTemplate;

public InstanceDatabaseNameBuilder(IMgrWorkerConfigConnectionStringsProvider connectionStringsProvider,
IDbConnectionStringBuilderAdapterFactory connectionStringBuilderFactory)
{
_databaseNameTemplate = new Lazy<string>(
() =>
{
if (!string.IsNullOrEmpty(_tenant))
connectionStringsProvider.SetTenant(_tenant);

if (!connectionStringsProvider.ConnectionStringProviderByName.ContainsKey("EdFi_Ods"))
{
return string.Empty;
}

var connectionStringBuilder = connectionStringBuilderFactory.Get();

connectionStringBuilder.ConnectionString = connectionStringsProvider.GetConnectionString("EdFi_Ods");

return connectionStringBuilder.DatabaseName;
});
}

public string DemoSandboxDatabase
{
get => "EdFi_Ods";
}

public string EmptyDatabase => throw new NotImplementedException();

public string MinimalDatabase
{
get => DatabaseName(_tenant, TemplateMinimalDatabase);
}

public string SampleDatabase => throw new NotImplementedException();

public string SandboxNameForKey(string key) => throw new NotImplementedException();

public string KeyFromSandboxName(string sandboxName) => throw new NotImplementedException();

public string TemplateSandboxNameForKey(string sandboxKey) => throw new NotImplementedException();

public string OdsDatabaseName(string? tenant, string databaseName) => DatabaseName(tenant, TemplatePrefix + databaseName);

private string DatabaseName(string? tenant, string databaseName)
{
_tenant = tenant;
return _databaseNameTemplate.Value.IsFormatString()
? string.Format(_databaseNameTemplate.Value, databaseName)
: _databaseNameTemplate.Value;
}
}
}
Loading
Loading