Skip to content

Commit

Permalink
Switch to using Microsoft.Data.SqlClient
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-vakil committed Nov 1, 2024
1 parent 9962379 commit eeaedee
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ WORKDIR /app/src/Opserver.Web
RUN dotnet publish -c Release -o publish

# Build runtime image
FROM cr.stackoverflow.software/so-aspnet:6.0-jammy-chiseled AS base
FROM cr.stackoverflow.software/so-aspnet:6.0-jammy-chiseled-extra AS base

USER $APP_UID

Expand Down
4 changes: 2 additions & 2 deletions charts/opserver/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ spec:

{{- if hasKey .Values.opserverSettings "sql" }}
- name: Modules__Sql__defaultConnectionString
value: "Server=$(SQL_EXCEPTIONAL_SERVERNAME);Database=master;User ID=$(SQL_USERNAME);Password=$(SQL_PASSWORD);"
value: "Server=$(SQL_EXCEPTIONAL_SERVERNAME);Database=master;User ID=$(SQL_USERNAME);Password=$(SQL_PASSWORD);TrustServerCertificate=True"
{{- range $i, $instance := .Values.opserverSettings.sql }}
- name: Modules__Sql__instances__{{ $i }}__name
value: "{{ $instance.name }}"
Expand All @@ -165,7 +165,7 @@ spec:
{{- if hasKey .Values.opserverSettings "exceptions" }}
{{- range $i, $instance := .Values.opserverSettings.exceptions }}
- name: Modules__Exceptions__stores__{{ $i }}__connectionString
value: "Server={{ $instance.serverName}};Database={{ $instance.database}};User ID=$(SQL_USERNAME);Password=$(SQL_PASSWORD);"
value: "Server={{ $instance.serverName}};Database={{ $instance.database}};User ID=$(SQL_USERNAME);Password=$(SQL_PASSWORD);TrustServerCertificate=True"
{{- end }}
{{- end }}

Expand Down
2 changes: 1 addition & 1 deletion src/Opserver.Core/Data/SQL/SQLAzureServer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;

namespace Opserver.Data.SQL
{
Expand Down
2 changes: 1 addition & 1 deletion src/Opserver.Core/Data/SQL/SQLInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Opserver.Helpers;
Expand Down
2 changes: 1 addition & 1 deletion src/Opserver.Core/Helpers/Connection.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;
using System.Threading;
using System.Threading.Tasks;
using StackExchange.Profiling;
Expand Down
2 changes: 1 addition & 1 deletion src/Opserver.Core/Opserver.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="Enums.NET" Version="4.0.0" />
<PackageReference Include="Jil" Version="2.17.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
Expand All @@ -20,7 +21,6 @@
<PackageReference Include="StackExchange.Exceptional.Shared" Version="2.2.32" />
<PackageReference Include="StackExchange.Redis" Version="2.6.122" />
<PackageReference Include="StackExchange.Utils.Http" Version="0.3.48" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
<PackageReference Include="System.DirectoryServices" Version="6.0.0" />
<PackageReference Include="System.Management" Version="6.0.0" />
<PackageReference Include="System.Runtime.Caching" Version="6.0.0" />
Expand Down
14 changes: 14 additions & 0 deletions src/Opserver.Web/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Opserver.Data.Elastic;
using Opserver.Data.HAProxy;
using System.Collections.Generic;
using System.Reflection;

namespace Opserver.Controllers
{
Expand Down Expand Up @@ -152,5 +153,18 @@ public ActionResult ErrorTestPage()
throw new NotImplementedException("I AM IMPLEMENTED, I WAS BORN TO THROW ERRORS!");
#pragma warning restore RCS1079 // Throwing of new NotImplementedException.
}

[Route("assemblies")]
public ActionResult Assemblies()
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
var result = new System.Text.StringBuilder();
foreach (Assembly assembly in assemblies)
{
result.AppendLine($"{assembly.FullName} - v{assembly.GetName().Version}");
}

return Content(result.ToString());
}
}
}
3 changes: 2 additions & 1 deletion src/Opserver.Web/Opserver.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<ProjectReference Include="..\Opserver.Core\Opserver.Core.csproj" />
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" PrivateAssets="all" />
<PackageReference Include="BuildWebCompiler" Condition="'$(OS)' == 'Windows_NT'" Version="1.12.405" PrivateAssets="all" />
<PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.2.22" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.15.0" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.35.0" />
<PackageReference Include="Serilog" Version="4.1.0" />
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
Expand Down
15 changes: 9 additions & 6 deletions src/Opserver.Web/opserverSettings.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"ForwardedHeaders": {
"KnownNetworks": ["10.0.0.0/16"],
"KnownNetworks": [ "10.0.0.0/16" ],
"KnownProxies": [],
"ForwardedHeaders": "All"
},
"Security": {
"Provider": "EveryonesAnAdmin"
},
"Modules": {
/* Configuration for the SQL Server dashboard */
"Sql": {
//"defaultConnectionString": "Data Source=$ServerName$;Initial Catalog=master;Integrated Security=SSPI;",
//"refreshIntervalSeconds": 30,
//"instances": [
// { "name": "localhost" }
//]
"defaultConnectionString": "Data Source=$ServerName$;Initial Catalog=master;Integrated Security=SSPI;TrustServerCertificate=True",
"refreshIntervalSeconds": 30,
"instances": [
{ "name": "localhost" }
]
},
/* Configuration for the Redis dashboard */
"Redis": {
Expand Down

0 comments on commit eeaedee

Please sign in to comment.