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

chore: add kubernetes initial config #62 #63

Merged
merged 1 commit into from
May 16, 2024
Merged

Conversation

italopessoa
Copy link
Member

  • add aggregate root
  • add initial kubernetes configuration
  • refactor mysql docker image
  • add serilog
  • add seq for log collection

- add aggregate root
- add initial kubernetes configuration
- refactor mysql docker image
- add serilog
- add seq for log collection
@italopessoa italopessoa added enhancement New feature or request kubernetes Kubernetes configuration labels May 16, 2024
@italopessoa italopessoa self-assigned this May 16, 2024
Copy link

coderabbitai bot commented May 16, 2024

Walkthrough

The recent updates encompass enhancements across various components of the project. Key changes include the addition of IF NOT EXISTS clauses in SQL table creation scripts, the introduction of Kubernetes configurations for deployment and service management, updates to Docker configurations, and logging improvements with Serilog in the API project. Additionally, new interface implementations were added to domain entities to enforce aggregate root patterns.

Changes

File(s) Change Summary
.docker/setup.sql Added IF NOT EXISTS clauses to CREATE TABLE statements for Customers, Products, Orders, and OrderItems.
FIAP.TechChallenge.ByteMeBurger.sln Added a new project "kubernetes" with various YAML files related to Kubernetes configurations.
database/Dockerfile Updated to use the official MySQL image and added an init.sql script for initialization.
database/init.sql Introduced table creation for Customers, Products, Orders, and OrderItems with IF NOT EXISTS clauses.
docker-compose.yml Added a seq service, renamed database service's container, and updated build configurations.
kubernetes/... Added various Kubernetes configuration files for ConfigMaps, Deployments, Pods, PersistentVolumes, PersistentVolumeClaims, ReplicaSets, and Services.
src/FIAP.TechChallenge.ByteMeBurger.Api/... Added Serilog.Sinks.Seq package, updated logger configuration, added UseSerilog and UseSerilogRequestLogging, and enhanced Swagger setup.
src/FIAP.TechChallenge.ByteMeBurger.Domain/Base/IAggregateRoot.cs Introduced a new public interface IAggregateRoot.
src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/... Updated Customer, Order, and Product classes to implement the IAggregateRoot interface.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Out of diff range and nitpick comments (2)
src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Customer.cs (2)

Line range hint 9-20: Initialize the Cpf property in all constructors.

-  public Customer()
-      : base(Guid.NewGuid())
-  {
-  }
+  public Customer()
+      : base(Guid.NewGuid())
+  {
+      Cpf = new Cpf();
+  }

-  public Customer(Guid id)
-      : base(id)
-  {
-  }
+  public Customer(Guid id)
+      : base(id)
+  {
+      Cpf = new Cpf();
+  }

Line range hint 56-56: Fix the potential null reference issue in ValidateEmail.

-  if (!Regex.IsMatch(email, @"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"))
+  if (email != null && !Regex.IsMatch(email, @"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"))
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 3cefeb0 and 633c280.
Files selected for processing (23)
  • .docker/setup.sql (4 hunks)
  • FIAP.TechChallenge.ByteMeBurger.sln (2 hunks)
  • database/Dockerfile (1 hunks)
  • database/init.sql (1 hunks)
  • docker-compose.yml (3 hunks)
  • kubernetes/configmap-api.yaml (1 hunks)
  • kubernetes/configmap-db.yaml (1 hunks)
  • kubernetes/deployment-api.yaml (1 hunks)
  • kubernetes/pod-api.yaml (1 hunks)
  • kubernetes/pod-mysql.yaml (1 hunks)
  • kubernetes/pv-db.yaml (1 hunks)
  • kubernetes/pvc-db.yaml (1 hunks)
  • kubernetes/replicaset-api.yaml (1 hunks)
  • kubernetes/svc-api-lb.yaml (1 hunks)
  • kubernetes/svc-api.yaml (1 hunks)
  • kubernetes/svc-mysql.yaml (1 hunks)
  • src/FIAP.TechChallenge.ByteMeBurger.Api/FIAP.TechChallenge.ByteMeBurger.Api.csproj (1 hunks)
  • src/FIAP.TechChallenge.ByteMeBurger.Api/Program.cs (3 hunks)
  • src/FIAP.TechChallenge.ByteMeBurger.Api/appsettings.json (2 hunks)
  • src/FIAP.TechChallenge.ByteMeBurger.Domain/Base/IAggregateRoot.cs (1 hunks)
  • src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Customer.cs (2 hunks)
  • src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Order.cs (1 hunks)
  • src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Product.cs (2 hunks)
Files skipped from review due to trivial changes (15)
  • .docker/setup.sql
  • database/Dockerfile
  • kubernetes/configmap-api.yaml
  • kubernetes/configmap-db.yaml
  • kubernetes/deployment-api.yaml
  • kubernetes/pod-api.yaml
  • kubernetes/pod-mysql.yaml
  • kubernetes/pv-db.yaml
  • kubernetes/pvc-db.yaml
  • kubernetes/replicaset-api.yaml
  • kubernetes/svc-api-lb.yaml
  • kubernetes/svc-api.yaml
  • kubernetes/svc-mysql.yaml
  • src/FIAP.TechChallenge.ByteMeBurger.Api/FIAP.TechChallenge.ByteMeBurger.Api.csproj
  • src/FIAP.TechChallenge.ByteMeBurger.Api/appsettings.json
Additional Context Used
GitHub Check Runs (1)
build success (11)

src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Customer.cs: [warning] 15-15:
Non-nullable property 'Cpf' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.


src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Customer.cs: [warning] 20-20:
Non-nullable property 'Cpf' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.


src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Customer.cs: [warning] 56-56:
Possible null reference argument for parameter 'input' in 'bool Regex.IsMatch(string input, string pattern)'.

Path-based Instructions (5)
src/FIAP.TechChallenge.ByteMeBurger.Domain/Base/IAggregateRoot.cs (1)

Pattern **/*.cs: Validate all files and structures against Domain Driven Design principles and Ports & Adapters architecture pattern.

src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Customer.cs (1)

Pattern **/*.cs: Validate all files and structures against Domain Driven Design principles and Ports & Adapters architecture pattern.

src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Product.cs (1)

Pattern **/*.cs: Validate all files and structures against Domain Driven Design principles and Ports & Adapters architecture pattern.

src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Order.cs (1)

Pattern **/*.cs: Validate all files and structures against Domain Driven Design principles and Ports & Adapters architecture pattern.

src/FIAP.TechChallenge.ByteMeBurger.Api/Program.cs (1)

Pattern **/*.cs: Validate all files and structures against Domain Driven Design principles and Ports & Adapters architecture pattern.

Additional comments not posted (10)
src/FIAP.TechChallenge.ByteMeBurger.Domain/Base/IAggregateRoot.cs (1)

1-3: LGTM! The interface IAggregateRoot is correctly defined.

database/init.sql (1)

1-43: LGTM! The SQL scripts correctly use IF NOT EXISTS to prevent errors if tables already exist.

src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Customer.cs (1)

Line range hint 1-7: LGTM! The Customer class correctly implements IAggregateRoot.

docker-compose.yml (1)

67-67: LGTM! The network is correctly defined.

src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Product.cs (1)

6-6: The addition of the IAggregateRoot interface is consistent with Domain Driven Design principles. The rest of the class appears to be well-structured and follows best practices.

src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Order.cs (1)

6-6: The addition of the IAggregateRoot interface is consistent with Domain Driven Design principles. The rest of the class appears to be well-structured and follows best practices.

src/FIAP.TechChallenge.ByteMeBurger.Api/Program.cs (3)

23-24: The Serilog configuration appears to be correctly implemented.


50-71: The Swagger configuration enhancements appear to be correctly implemented.


97-97: The Serilog request logging appears to be correctly implemented.

FIAP.TechChallenge.ByteMeBurger.sln (1)

39-53: The addition of Kubernetes configuration files appears to be correctly implemented.

Comment on lines +31 to +36
container_name: restaurant_db
build:
context: ./database
dockerfile: Dockerfile
tags:
- techchallenge/db
Copy link

@coderabbitai coderabbitai bot May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using mysql_native_password for the database service.

-  command: --default-authentication-plugin=mysql_native_password
+  # command: --default-authentication-plugin=mysql_native_password

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
container_name: restaurant_db
build:
context: ./database
dockerfile: Dockerfile
tags:
- techchallenge/db
container_name: restaurant_db
build:
context: ./database
dockerfile: Dockerfile
tags:
- techchallenge/db
# command: --default-authentication-plugin=mysql_native_password

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for local testing only

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@italopessoa Thank you for the clarification. While it's understandable to use mysql_native_password for local testing, it's important to ensure that this configuration is not used in production environments due to security concerns. If you have any specific reasons for using it locally, please make sure to document them clearly to avoid any accidental usage in production.

If you need any further assistance or have other questions, feel free to ask!

@italopessoa italopessoa merged commit 4e0f9d4 into main May 16, 2024
1 check passed
@italopessoa italopessoa deleted the add_aggregate_root branch May 16, 2024 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request kubernetes Kubernetes configuration
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant