Skip to content
Merged
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
10 changes: 4 additions & 6 deletions ConplementAG.CopsController.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<RootNamespace>ConplementAG.CopsController</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
<PackageReference Include="Serilog.Formatting.Elasticsearch" Version="7.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.5" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
</ItemGroup>
Expand Down
8 changes: 5 additions & 3 deletions Controllers/Sync.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using ConplementAG.CopsController.Services;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using Serilog;
using System;
using System.Net;
using Microsoft.AspNetCore.Mvc;

namespace ConplementAG.CopsController.Controllers
{
Expand All @@ -18,10 +18,12 @@ public ActionResult<string> Get()
}

[HttpPost]
public IActionResult Post([FromBody]Newtonsoft.Json.Linq.JObject value)
public IActionResult Post([FromBody]JObject value)
{
try
{
Log.Verbose("REQUEST===============================" + value.ToString(Newtonsoft.Json.Formatting.Indented));

var copsResource = CopsResourceFactory.Create(value);
var k8sResources = K8sResourceFactory.Create(copsResource);

Expand All @@ -32,7 +34,7 @@ public IActionResult Post([FromBody]Newtonsoft.Json.Linq.JObject value)
}
);

Log.Debug("RESPONSE===============================" + response.ToString());
Log.Verbose("RESPONSE===============================" + response.ToString(Newtonsoft.Json.Formatting.Indented));
return Ok(response);
}
catch (Exception ex)
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-env
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env
WORKDIR /app

COPY *.csproj ./
Expand All @@ -7,7 +7,7 @@ RUN dotnet restore ConplementAG.CopsController.csproj
COPY . ./
RUN dotnet publish ConplementAG.CopsController.csproj -c Release -o out

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2
FROM mcr.microsoft.com/dotnet/aspnet:5.0

RUN useradd -u 8877 donetuser
USER donetuser
Expand Down
12 changes: 8 additions & 4 deletions Startup.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace ConplementAG.CopsController
{
Expand All @@ -18,11 +18,11 @@ public Startup(IConfiguration configuration)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddControllers().AddNewtonsoftJson();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
Expand All @@ -35,7 +35,11 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
}

app.UseHttpsRedirection();
app.UseMvc();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}