Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/update csproj #56

Merged
merged 5 commits into from
May 14, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- "src/*"
- "src/**"
workflow_dispatch:

# defaults:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Publish Image
on:
push:
paths:
- 'src/*'
- 'src/**'
branches:
- main
workflow_dispatch:
Expand Down
19 changes: 9 additions & 10 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# docker-compose -f ../docker/docker-compose.yml up -d --build
# docker-compose -f ../docker/docker-compose.yml down --remove-orphans

version: '3.8'
services:
# cachorro.api:
# hostname: cachorro-api
Expand Down Expand Up @@ -43,15 +42,15 @@ services:
ports:
- 1433:1433

sonarqube:
image: sonarqube:10.4.1-community
hostname: sonar-canal-deploy
container_name: sonar-canal-deploy
restart: always
networks:
- cachorro-net
ports:
- 9044:9000
# sonarqube:
# image: sonarqube:10.4.1-community
# hostname: sonar-canal-deploy
# container_name: sonar-canal-deploy
# restart: always
# networks:
# - cachorro-net
# ports:
# - 9044:9000

networks:
cachorro-net:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
using Azure.Security.KeyVault.Secrets;
using DEPLOY.Cachorro.Api.Extensions.AppConfiguration.Configs;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using Microsoft.FeatureManagement;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;

namespace DEPLOY.Cachorro.Api.Controllers
{
Expand All @@ -13,7 +16,7 @@
[ApiExplorerSettings(IgnoreApi = true)]
[ApiController]
[Route("api/[controller]")]
public class TestsResourcesController : ControllerBase

Check warning on line 19 in src/DEPLOY.Cachorro.Api/Controllers/TestsResourcesController.cs

View workflow job for this annotation

GitHub Actions / build-and-sonar

This controller has multiple responsibilities and could be split into 3 smaller controllers. (https://rules.sonarsource.com/csharp/RSPEC-6960)
{
private readonly SecretClient _secretClient;
private readonly Settings _settings;
Expand All @@ -34,7 +37,7 @@
}

[HttpGet("keyvault/withoptions/{key}")]
public async Task<IActionResult> GetAsync(string key)
public async Task<IActionResult> GetKeyAsync(string key)
{
SecretClientOptions options = new SecretClientOptions()
{
Expand Down
5 changes: 5 additions & 0 deletions src/DEPLOY.Cachorro.Api/Controllers/v1/AdocoesController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
using Asp.Versioning;
using DEPLOY.Cachorro.Application.Interfaces.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace DEPLOY.Cachorro.Api.Controllers.v1
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
using DEPLOY.Cachorro.Application.Dtos;
using DEPLOY.Cachorro.Application.Interfaces.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace DEPLOY.Cachorro.Api.Controllers.v1
{
Expand Down
20 changes: 13 additions & 7 deletions src/DEPLOY.Cachorro.Api/Controllers/v1/TutoresController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
using DEPLOY.Cachorro.Application.Dtos;
using DEPLOY.Cachorro.Application.Interfaces.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace DEPLOY.Cachorro.Api.Controllers.v1
{
Expand Down Expand Up @@ -82,19 +86,21 @@ public async Task<IActionResult> CreateAsync(
CancellationToken cancellationToken = default)
{
var item = await _tutorAppServices.InsertAsync(
tutorDto,
tutorDto,
cancellationToken);

if (item.Erros.Any())
return UnprocessableEntity(item.Erros);

return CreatedAtAction("GetById",
new {
new
{
id = item.Id,
version = new ApiVersion(
1,
0)
.ToString() },
.ToString()
},
item);
}

Expand All @@ -119,11 +125,11 @@ public async Task<IActionResult> UpdateAsync(

var retorned = await _tutorAppServices.UpdateAsync(
id,
tutorDto,
tutorDto,
cancellationToken);

return !retorned.Any() ? NoContent()
: UnprocessableEntity(retorned);
return !retorned.Any() ? NoContent()
: UnprocessableEntity(retorned);
}

[HttpDelete("{id:long}")]
Expand Down
7 changes: 3 additions & 4 deletions src/DEPLOY.Cachorro.Api/DEPLOY.Cachorro.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
<NoWarn>$(NoWarn);1591</NoWarn>
<NoWarn>$(NoWarn);8604</NoWarn>
<NoWarn>$(NoWarn);8603</NoWarn>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>CachorroAPI_Local</UserSecretsId>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);8602</NoWarn>
<UserSecretsId>CachorroAPI_MVP</UserSecretsId>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<ApplicationInsightsResourceId>/subscriptions/f4574f09-7fab-45bd-8eb5-508b8c6aa04a/resourceGroups/rg-canaldeploy-dev/providers/microsoft.insights/components/appi-cachorroapi-dev</ApplicationInsightsResourceId>
<Version>2.3.0</Version>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using DEPLOY.Cachorro.Api.Extensions.AppConfiguration.Configs;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.FeatureManagement;
using System;
using System.Diagnostics.CodeAnalysis;

namespace DEPLOY.Cachorro.Api.Extensions.AppConfiguration
Expand Down
2 changes: 2 additions & 0 deletions src/DEPLOY.Cachorro.Api/Extensions/Auth/AuthExtension.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Azure.Identity;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Extensions.Azure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Identity.Web;
using System.Diagnostics.CodeAnalysis;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using DEPLOY.Cachorro.Infra.Repository;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Diagnostics.CodeAnalysis;

namespace DEPLOY.Cachorro.Api.Extensions.Database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Azure.Identity;
using Microsoft.Extensions.Azure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System.Diagnostics.CodeAnalysis;

namespace DEPLOY.Cachorro.Api.Extensions.KeyVault
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Asp.Versioning;
using Asp.Versioning.ApiExplorer;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text.Json;

namespace DEPLOY.Cachorro.Api.Extensions.Swagger
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
using Asp.Versioning;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Swashbuckle.AspNetCore.SwaggerGen;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;

namespace DEPLOY.Cachorro.Api.Extensions.Swagger
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Microsoft.ApplicationInsights.DependencyCollector;
using Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System.Diagnostics.CodeAnalysis;

namespace DEPLOY.Cachorro.Api.Extensions.Telemetria
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System.Diagnostics.CodeAnalysis;

namespace DEPLOY.Cachorro.Api.Extensions.Telemetria
{
Expand Down
3 changes: 3 additions & 0 deletions src/DEPLOY.Cachorro.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using DEPLOY.Cachorro.Infra.CrossCutting;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
namespace DEPLOY.Cachorro.Api
{
[ExcludeFromCodeCoverage]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
<NoWarn>$(NoWarn);8604</NoWarn>
<NoWarn>$(NoWarn);8603</NoWarn>
<NoWarn>$(NoWarn);8602</NoWarn>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>CachorroAPI_Local</UserSecretsId>
<UserSecretsId>CachorroAPI_MVP</UserSecretsId>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<ApplicationInsightsResourceId>/subscriptions/f4574f09-7fab-45bd-8eb5-508b8c6aa04a/resourceGroups/rg-canaldeploy-dev/providers/microsoft.insights/components/appi-cachorroapi-dev</ApplicationInsightsResourceId>
<Version>1.1.0-MinimalApi</Version>
<Version>1.3.0-MinimalApi</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@
using Azure.Core;
using Azure.Identity;
using Azure.Security.KeyVault.Secrets;
using DEPLOY.Cachorro.Application.Dtos;
using DEPLOY.Cachorro.MinimalApi.Configs;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using Microsoft.FeatureManagement;
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace DEPLOY.Cachorro.MinimalApi.Endpoints
{
Expand All @@ -30,7 +41,7 @@ public static void MapTestResourcesEndpoints(this IEndpointRouteBuilder app)
IConfiguration configuration,
CancellationToken cancellationToken) =>
{
async Task<IResult> GetAsync(
async Task<IResult> GetKeyAsync(
string key)
{
SecretClientOptions options = new SecretClientOptions()
Expand All @@ -56,7 +67,7 @@ async Task<IResult> GetAsync(
return TypedResults.Ok(secretValue);
}

return await GetAsync(key);
return await GetKeyAsync(key);
})
.WithOpenApi(operation => new(operation)
{
Expand Down Expand Up @@ -99,7 +110,7 @@ string key
IOptions<Settings> settings,
CancellationToken cancellationToken) =>
{
async Task<IResult> GetAsync()
async Task<Ok<string>> GetAsync()
{
return TypedResults.Ok(settings.Value.ValorDaMensagem);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
using Asp.Versioning;
using DEPLOY.Cachorro.Application.Interfaces.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace DEPLOY.Cachorro.MinimalApi.Endpoints.v1
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
using Asp.Versioning;
using DEPLOY.Cachorro.Application.Dtos;
using DEPLOY.Cachorro.Application.Interfaces.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Routing;
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace DEPLOY.Cachorro.MinimalApi.Endpoints.v1
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
using Asp.Versioning;
using DEPLOY.Cachorro.Application.Dtos;
using DEPLOY.Cachorro.Application.Interfaces.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace DEPLOY.Cachorro.MinimalApi.Endpoints.v1
{
Expand Down Expand Up @@ -113,7 +121,7 @@ async Task<IResult> CreateTutorAsync()
Description = "Operação para cadastrar tutor",
Tags = new List<OpenApiTag> { new() { Name = "Tutores" } }
});

tutores.MapPut("/{id:long}", async (
long id,
TutorDto tutorDto,
Expand Down
Loading
Loading