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

so much stuff #4

Merged
merged 2 commits into from
Jun 18, 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
30 changes: 30 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
42 changes: 36 additions & 6 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,44 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get tag
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build api image
- name: Build images
run: |
docker build -t zme-api -f Memphis.API/Dockerfile .
docker build -t api -f Memphis.API/Dockerfile .
docker build -t airports-job -f Memphis.Jobs.Airports/Dockerfile .
docker build -t atc-job -f Memphis.Jobs.ATC/Dockerfile .
docker build -t datafeed-job -f Memphis.Jobs.Datafeed/Dockerfile .
docker build -t events-job -f Memphis.Jobs.Events/Dockerfile .
docker build -t roster-job -f Memphis.Jobs.Roster/Dockerfile .
docker build -t solocerts-job -f Memphis.Jobs.SoloCerts/Dockerfile .
- name: Tag images
run: |
docker tag zme-api ghcr.io/memphis-artcc/api:latest
docker tag zme-api ghcr.io/memphis-artcc/api:${{ env.RELEASE_VERSION }}
docker tag api ghcr.io/memphis-artcc/api:latest
docker tag api ghcr.io/memphis-artcc/api:${{ env.RELEASE_VERSION }}
docker tag api ghcr.io/memphis-artcc/airports-job:latest
docker tag api ghcr.io/memphis-artcc/airports-job:${{ env.RELEASE_VERSION }}
docker tag api ghcr.io/memphis-artcc/atc-job:latest
docker tag api ghcr.io/memphis-artcc/atc-job:${{ env.RELEASE_VERSION }}
docker tag api ghcr.io/memphis-artcc/datafeed-job:latest
docker tag api ghcr.io/memphis-artcc/datafeed-job:${{ env.RELEASE_VERSION }}
docker tag api ghcr.io/memphis-artcc/events-job:latest
docker tag api ghcr.io/memphis-artcc/events-job:${{ env.RELEASE_VERSION }}
docker tag api ghcr.io/memphis-artcc/roster-job:latest
docker tag api ghcr.io/memphis-artcc/roster-job:${{ env.RELEASE_VERSION }}
docker tag api ghcr.io/memphis-artcc/solocerts-job:latest
docker tag api ghcr.io/memphis-artcc/solocerts-job:${{ env.RELEASE_VERSION }}
- name: Push images
run: |
docker push ghcr.io/memphis-artcc/api:latest
docker push ghcr.io/memphis-artcc/api:${{ env.RELEASE_VERSION }}
docker push api ghcr.io/memphis-artcc/api:latest
docker push api ghcr.io/memphis-artcc/api:${{ env.RELEASE_VERSION }}
docker push api ghcr.io/memphis-artcc/airports-job:latest
docker push api ghcr.io/memphis-artcc/airports-job:${{ env.RELEASE_VERSION }}
docker push api ghcr.io/memphis-artcc/atc-job:latest
docker push api ghcr.io/memphis-artcc/atc-job:${{ env.RELEASE_VERSION }}
docker push api ghcr.io/memphis-artcc/datafeed-job:latest
docker push api ghcr.io/memphis-artcc/datafeed-job:${{ env.RELEASE_VERSION }}
docker push api ghcr.io/memphis-artcc/events-job:latest
docker push api ghcr.io/memphis-artcc/events-job:${{ env.RELEASE_VERSION }}
docker push api ghcr.io/memphis-artcc/roster-job:latest
docker push api ghcr.io/memphis-artcc/roster-job:${{ env.RELEASE_VERSION }}
docker push api ghcr.io/memphis-artcc/solocerts-job:latest
docker push api ghcr.io/memphis-artcc/solocerts-job:${{ env.RELEASE_VERSION }}
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ jobs:
uses: actions/checkout@v2
- name: Build api image
run: |
docker build -t api -f Memphis.API/Dockerfile .
docker build -t api -f Memphis.API/Dockerfile .
docker build -t airports-job -f Memphis.Jobs.Airports/Dockerfile .
docker build -t atc-job -f Memphis.Jobs.ATC/Dockerfile .
docker build -t datafeed-job -f Memphis.Jobs.Datafeed/Dockerfile .
docker build -t events-job -f Memphis.Jobs.Events/Dockerfile .
docker build -t roster-job -f Memphis.Jobs.Roster/Dockerfile .
docker build -t solocerts-job -f Memphis.Jobs.SoloCerts/Dockerfile .
8 changes: 4 additions & 4 deletions Memphis.API/Controllers/AirportsController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using FluentValidation;
using FluentValidation.Results;
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Dtos;
using Memphis.Shared.Models;
using Memphis.Shared.Utils;
Expand Down Expand Up @@ -54,7 +54,7 @@ public async Task<ActionResult<Response<Airport>>> CreateAirport(AirportDto payl
return StatusCode(401);
}

ValidationResult validation = await _validator.ValidateAsync(payload);
var validation = await _validator.ValidateAsync(payload);
if (!validation.IsValid)
{
return BadRequest(new Response<IList<ValidationFailure>>
Expand All @@ -65,7 +65,7 @@ public async Task<ActionResult<Response<Airport>>> CreateAirport(AirportDto payl
});
}

Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<Airport> result = await _context.Airports.AddAsync(new Airport
var result = await _context.Airports.AddAsync(new Airport
{
Name = payload.Name,
Icao = payload.Icao,
Expand Down Expand Up @@ -95,7 +95,7 @@ public async Task<ActionResult<Response<IList<Airport>>>> GetAirports()
{
try
{
List<Airport> result = await _context.Airports.ToListAsync();
var result = await _context.Airports.ToListAsync();
return Ok(new Response<IList<Airport>>
{
StatusCode = 200,
Expand Down
4 changes: 2 additions & 2 deletions Memphis.API/Controllers/AuthController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Extensions;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Dtos.auth;
using Memphis.Shared.Dtos.Auth;
using Memphis.Shared.Enums;
Expand Down
2 changes: 1 addition & 1 deletion Memphis.API/Controllers/CommentsController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using FluentValidation;
using FluentValidation.Results;
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Dtos;
using Memphis.Shared.Models;
using Memphis.Shared.Utils;
Expand Down
2 changes: 1 addition & 1 deletion Memphis.API/Controllers/EmailLogsController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using FluentValidation;
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Models;
using Memphis.Shared.Utils;
using Microsoft.AspNetCore.Authorization;
Expand Down
2 changes: 1 addition & 1 deletion Memphis.API/Controllers/EventPositionsController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using FluentValidation;
using FluentValidation.Results;
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Dtos;
using Memphis.Shared.Models;
using Memphis.Shared.Utils;
Expand Down
2 changes: 1 addition & 1 deletion Memphis.API/Controllers/EventRegistrationController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using FluentValidation;
using FluentValidation.Results;
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Dtos;
using Memphis.Shared.Enums;
using Memphis.Shared.Models;
Expand Down
2 changes: 1 addition & 1 deletion Memphis.API/Controllers/EventsController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using FluentValidation;
using FluentValidation.Results;
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Dtos;
using Memphis.Shared.Models;
using Memphis.Shared.Utils;
Expand Down
2 changes: 1 addition & 1 deletion Memphis.API/Controllers/FeedbackController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using FluentValidation;
using FluentValidation.Results;
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Dtos;
using Memphis.Shared.Enums;
using Memphis.Shared.Models;
Expand Down
2 changes: 1 addition & 1 deletion Memphis.API/Controllers/FilesController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using FluentValidation;
using FluentValidation.Results;
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Dtos;
using Memphis.Shared.Enums;
using Memphis.Shared.Utils;
Expand Down
4 changes: 2 additions & 2 deletions Memphis.API/Controllers/HoursController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Extensions;
using Memphis.Shared.Data;
using Memphis.Shared.Dtos;
using Memphis.Shared.Utils;
using Microsoft.AspNetCore.Mvc;
Expand Down
4 changes: 2 additions & 2 deletions Memphis.API/Controllers/NotificationsController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Extensions;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Dtos;
using Memphis.Shared.Utils;
using Microsoft.AspNetCore.Authorization;
Expand Down
4 changes: 2 additions & 2 deletions Memphis.API/Controllers/OnlineControllersController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Extensions;
using Memphis.Shared.Data;
using Memphis.Shared.Models;
using Memphis.Shared.Utils;
using Microsoft.AspNetCore.Mvc;
Expand Down
2 changes: 1 addition & 1 deletion Memphis.API/Controllers/OtsController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using FluentValidation.Results;
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Dtos;
using Memphis.Shared.Enums;
using Memphis.Shared.Utils;
Expand Down
4 changes: 2 additions & 2 deletions Memphis.API/Controllers/SessionsController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Extensions;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Utils;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
Expand Down
63 changes: 61 additions & 2 deletions Memphis.API/Controllers/SettingsController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Memphis.API.Data;
using FluentValidation;
using FluentValidation.Results;
using Memphis.API.Extensions;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Models;
using Memphis.Shared.Utils;
using Microsoft.AspNetCore.Authorization;
Expand All @@ -19,17 +21,74 @@ public class SettingsController : ControllerBase
private readonly DatabaseContext _context;
private readonly RedisService _redisService;
private readonly LoggingService _loggingService;
private readonly IValidator<Facility> _validator;
private readonly ISentryClient _sentryHub;
private readonly ILogger<SettingsController> _logger;

public SettingsController(DatabaseContext context, RedisService redisService, LoggingService loggingService,
ISentryClient sentryHub, ILogger<SettingsController> logger)
IValidator<Facility> validator, ISentryClient sentryHub, ILogger<SettingsController> logger)
{
_context = context;
_redisService = redisService;
_loggingService = loggingService;
_sentryHub = sentryHub;
_logger = logger;
_validator = validator;
}

[HttpPost]
[Authorize(Roles = Constants.SeniorStaff)]
[ProducesResponseType(typeof(Response<Airport>), 201)]
[ProducesResponseType(typeof(Response<IList<ValidationFailure>>), 400)]
[ProducesResponseType(401)]
[ProducesResponseType(403)]
[ProducesResponseType(typeof(Response<string?>), 500)]
public async Task<ActionResult<Response<IList<Facility>>>> AddFacility(Facility payload)
{
try
{
if (!await _redisService.ValidateRoles(Request.HttpContext.User, Constants.SeniorStaffList))
{
return StatusCode(401);
}

var validation = await _validator.ValidateAsync(payload);
if (!validation.IsValid)
{
return BadRequest(new Response<IList<ValidationFailure>>
{
StatusCode = 400,
Message = "Validation failure",
Data = validation.Errors
});
}

if (!await _context.Facilities.AnyAsync(x => x.Identifier.Equals(payload.Identifier, StringComparison.OrdinalIgnoreCase)))
{
await _context.Facilities.AddAsync(payload);
await _context.SaveChangesAsync();

await _loggingService.AddWebsiteLog(Request, "Added facility", string.Empty, JsonConvert.SerializeObject(payload));

var facilities = await _context.Facilities.ToListAsync();
return Ok(new Response<IList<Facility>>
{
StatusCode = 200,
Message = "Added facility",
Data = facilities
});
}
return BadRequest(new Response<string?>
{
StatusCode = 400,
Message = "Facility already exists"
});
}
catch (Exception ex)
{
_logger.LogError("AddFacility error '{Message}'\n{StackTrace}", ex.Message, ex.StackTrace);
return _sentryHub.CaptureException(ex).ReturnActionResult();
}
}

[HttpGet]
Expand Down
4 changes: 2 additions & 2 deletions Memphis.API/Controllers/StatsController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Extensions;
using Memphis.Shared.Data;
using Memphis.Shared.Dtos;
using Memphis.Shared.Enums;
using Memphis.Shared.Models;
Expand Down
2 changes: 1 addition & 1 deletion Memphis.API/Controllers/TrainingMilestonesController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using FluentValidation;
using FluentValidation.Results;
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Models;
using Memphis.Shared.Utils;
using Microsoft.AspNetCore.Authorization;
Expand Down
2 changes: 1 addition & 1 deletion Memphis.API/Controllers/TrainingSchedulesController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using FluentValidation;
using FluentValidation.Results;
using Memphis.API.Data;
using Memphis.API.Extensions;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Dtos;
using Memphis.Shared.Models;
using Memphis.Shared.Utils;
Expand Down
4 changes: 2 additions & 2 deletions Memphis.API/Extensions/HttpContextExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Memphis.API.Data;
using Memphis.API.Services;
using Memphis.API.Services;
using Memphis.Shared.Data;
using Memphis.Shared.Models;
using Memphis.Shared.Utils;
using Microsoft.EntityFrameworkCore;
Expand Down
Loading
Loading