Skip to content

Commit

Permalink
chore: P4ADEV-1612 init (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioT90 authored Dec 4, 2024
1 parent e8e5da4 commit c0a0fc2
Show file tree
Hide file tree
Showing 26 changed files with 133 additions and 178 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Add the repository's code owners here
* @pagopa/p4pa-admins @pagopa/payments-cloud-admin
* @pagopa/p4pa-admins @pagopa/payments-cloud-admin @antocalo @Benedetta-fabbri @LarissaASLeite @RiccardoGiuliani @oleksiybozhykntt @ElisKina-dev
45 changes: 45 additions & 0 deletions .github/terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 21 additions & 5 deletions .github/terraform/00_data.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Github
data "github_organization_teams" "all" {
root_teams_only = true
summary_only = true
}

# KV Core
data "azurerm_key_vault" "key_vault_core" {
name = "${var.prefix}-${var.env_short}-${var.location_short}-core-kv"
Expand All @@ -6,12 +12,22 @@ data "azurerm_key_vault" "key_vault_core" {

# Kv Domain
data "azurerm_key_vault" "key_vault_domain" {
name = "${var.prefix}-${var.env_short}-${var.location_short}-${var.domain}-kv"
name = "${var.prefix}-${var.env_short}-${var.domain}-kv"
resource_group_name = "${var.prefix}-${var.env_short}-${var.location_short}-${var.domain}-sec-rg"
}

# Github
data "github_organization_teams" "all" {
root_teams_only = true
summary_only = true
# Key Vault - Sonar Token
data "azurerm_key_vault_secret" "sonar_token" {
count = var.env_short == "p" ? 1 : 0

key_vault_id = data.azurerm_key_vault.key_vault_core.id
name = "sonar-cloud-token"
}

# Key Vault - Slack webhok
data "azurerm_key_vault_secret" "slack_webhook" {
count = var.env_short == "p" ? 1 : 0

key_vault_id = data.azurerm_key_vault.key_vault_core.id
name = "slack-webhook-url"
}
22 changes: 11 additions & 11 deletions .github/terraform/99_locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ locals {
CreatedBy = "Terraform"
Environment = var.env
Owner = upper(var.prefix)
Source = "" # Repository URL
CostCenter = ""
Source = "https://github.com/pagopa/p4pa-organization" # Repository URL
CostCenter = "TS310 - PAGAMENTI & SERVIZI"
}

# Repo
github = {
org = "pagopa"
repository = "" # Repository Name
repository = "p4pa-organization" # Repository Name
}

env_secrets = {
ENV_SECRET = "data.azurerm_key_vault_secret.CHANGE_ME.value"
}
env_variables = {
ENV_VARIABLE = "ENV_VARIABLE"
}
env_secrets = {}
env_variables = {}

repo_secrets = var.env_short == "p" ? {
SECRET = "SECRET"
SONAR_TOKEN = data.azurerm_key_vault_secret.sonar_token[0].value
SLACK_WEBHOOK_URL = data.azurerm_key_vault_secret.slack_webhook[0].value
} : {}

repo_env = var.env_short == "p" ? {
ENV_VARIABLE = "ENV_VARIABLE"
SONARCLOUD_PROJECT_NAME = "p4pa-organization"
SONARCLOUD_PROJECT_KEY = "pagopa_p4pa-organization"
SONARCLOUD_ORG = "pagopa"
} : {}

map_repo = {
Expand Down
2 changes: 1 addition & 1 deletion .github/terraform/99_variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ variable "github_repository_environment" {
default = {
protected_branches = false
custom_branch_policies = true
reviewers_teams = ["CHANGE_ME"]
reviewers_teams = ["p4pa-admins"]
}
}
1 change: 0 additions & 1 deletion .github/terraform/env/itn-dev/backend.ini

This file was deleted.

4 changes: 0 additions & 4 deletions .github/terraform/env/itn-dev/backend.tfvars

This file was deleted.

4 changes: 0 additions & 4 deletions .github/terraform/env/itn-dev/terraform.tfvars

This file was deleted.

2 changes: 1 addition & 1 deletion .github/terraform/env/itn-prod/backend.ini
Original file line number Diff line number Diff line change
@@ -1 +1 @@
subscription=CHANGE_ME
subscription=PROD-P4PA
4 changes: 2 additions & 2 deletions .github/terraform/env/itn-prod/backend.tfvars
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resource_group_name = "terraform-state-rg"
storage_account_name = "tfappdevCHANGE_ME"
storage_account_name = "tfappprodp4pa"
container_name = "terraform-state"
key = "NAME_OF_REPOSITORY.tfstate"
key = "p4pa-organization"
8 changes: 5 additions & 3 deletions .github/terraform/env/itn-prod/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
prefix = ""
env = "prod"
env_short = "p"
prefix = "p4pa"
env = "prod"
env_short = "p"
domain = "payhub"
location_short = "itn"
1 change: 0 additions & 1 deletion .github/terraform/env/itn-uat/backend.ini

This file was deleted.

4 changes: 0 additions & 4 deletions .github/terraform/env/itn-uat/backend.tfvars

This file was deleted.

3 changes: 0 additions & 3 deletions .github/terraform/env/itn-uat/terraform.tfvars

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/codereview.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: TEMPLATE-PAYMENTS - Code Review
name: p4pa-organization - Code Review

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG CORRETTO_VERSION="21-alpine3.20"
ARG CORRETTO_SHA="8b16834e7fabfc62d4c8faa22de5df97f99627f148058d52718054aaa4ea3674"
ARG GRADLE_VERSION="8.10.2"
ARG GRADLE_DOWNLOAD_SHA256="31c55713e40233a8303827ceb42ca48a47267a0ad4bab9177123121e71524c26"
ARG APPINSIGHTS_VERSION="3.5.2"
ARG APPINSIGHTS_VERSION="3.6.2"

# 🌍 Timezone Configuration
ARG TZ="Europe/Rome"
Expand Down
57 changes: 1 addition & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1 @@
# Example Repository Template

This repository serves as an **example template** to kick-start your projects with pre-configured files and folders for **OpenAPI**, **Helm**, **Gradle**, **Java**, and **JUnit testing**. It is designed to streamline the initial setup of new projects and ensure consistency in project structure.

---

## 📂 Repository Structure

Here is a quick overview of the files and directories included in this repository:

```plaintext
.
├── .devops/ # DevOps pipelines
├── .github/ # GitHub configuration files
├── gradle/ # Gradle wrapper files
├── helm/ # Helm charts for Kubernetes deployments
├── openapi/ # OpenAPI specification files
├── src/ # Source code for the Java application
│ ├── main/
│ └── test/
├── build.gradle.kts # Gradle build file
├── Dockerfile # Docker build file
├── README.md # Project documentation
├── settings.gradle.kts # Gradle settings file
└── .gitignore # Git ignore rules
```

## 🚀 Features

### 📜 OpenAPI
- Example OpenAPI specification file (`template-payments-java-repository.openapi.yaml`) to document your RESTful APIs.
- Compatible with tools like Swagger and Postman.

### ⚙️ Helm
- Template Helm charts for deploying your Java application on Kubernetes.
- Includes `values.yaml` for parameter configuration and pre-defined deployment manifests.

### 🔧 Gradle
- `build.gradle` file with dependencies and plugins for building, testing, and running your Java application.
- Compatible with Java 21+.

### ☕ Java
- Example Java application structure with a simple `HelloWorld` class.

### ✅ JUnit
- Example JUnit test cases under the `test/` directory to help you get started with unit testing.

---

## 🛠️ Getting Started

### Prerequisites
Ensure the following tools are installed on your machine:
1. **Java 21+**
2. **Gradle** (or use the Gradle wrapper included in the repository)
3. **Docker** (for Helm-related tasks, optional)
# p4pa-organization
20 changes: 1 addition & 19 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {

group = "it.gov.pagopa.payhub"
version = "0.0.1"
description = "template-payments-java-repository"
description = "p4pa-organization"

java {
toolchain {
Expand All @@ -30,42 +30,24 @@ repositories {

val springDocOpenApiVersion = "2.6.0"
val openApiToolsVersion = "0.2.6"
val findbugsVersion = "3.0.2"
val javaJwtVersion = "4.4.0"
val jwksRsaVersion = "0.22.1"
val nimbusJoseJwtVersion = "9.47"
val jjwtVersion = "0.12.6"
val wiremockVersion = "3.9.2"
val wiremockSpringBootVersion = "2.1.3"
val micrometerVersion = "1.4.0"

dependencies {
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("io.micrometer:micrometer-tracing-bridge-otel:$micrometerVersion")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:$springDocOpenApiVersion")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
implementation("org.openapitools:jackson-databind-nullable:$openApiToolsVersion")
implementation("com.google.code.findbugs:jsr305:$findbugsVersion")

compileOnly("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")

// validation token jwt
implementation("com.auth0:java-jwt:$javaJwtVersion")
implementation("com.auth0:jwks-rsa:$jwksRsaVersion")
implementation("com.nimbusds:nimbus-jose-jwt:$nimbusJoseJwtVersion")
implementation("io.jsonwebtoken:jjwt-api:$jjwtVersion")

// Testing
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.mockito:mockito-core")
testImplementation ("org.projectlombok:lombok")
testImplementation ("org.wiremock:wiremock-standalone:$wiremockVersion")
testImplementation ("com.maciejwalkowiak.spring:wiremock-spring-boot:$wiremockSpringBootVersion")
}

tasks.withType<Test> {
Expand Down
10 changes: 0 additions & 10 deletions gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
aopalliance:aopalliance:1.0=compileClasspath
ch.qos.logback:logback-classic:1.5.11=compileClasspath
ch.qos.logback:logback-core:1.5.11=compileClasspath
com.auth0:java-jwt:4.4.0=compileClasspath
com.auth0:jwks-rsa:0.22.1=compileClasspath
com.fasterxml.jackson.core:jackson-annotations:2.17.2=compileClasspath
com.fasterxml.jackson.core:jackson-core:2.17.2=compileClasspath
com.fasterxml.jackson.core:jackson-databind:2.17.2=compileClasspath
Expand All @@ -14,9 +12,6 @@ com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.17.2=compileClasspath
com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2=compileClasspath
com.fasterxml.jackson.module:jackson-module-parameter-names:2.17.2=compileClasspath
com.fasterxml.jackson:jackson-bom:2.17.2=compileClasspath
com.google.code.findbugs:jsr305:3.0.2=compileClasspath
com.nimbusds:nimbus-jose-jwt:9.47=compileClasspath
io.jsonwebtoken:jjwt-api:0.12.6=compileClasspath
io.micrometer:context-propagation:1.1.2=compileClasspath
io.micrometer:micrometer-commons:1.13.6=compileClasspath
io.micrometer:micrometer-core:1.13.6=compileClasspath
Expand Down Expand Up @@ -61,15 +56,10 @@ org.springframework.boot:spring-boot-autoconfigure:3.3.5=compileClasspath
org.springframework.boot:spring-boot-starter-actuator:3.3.5=compileClasspath
org.springframework.boot:spring-boot-starter-json:3.3.5=compileClasspath
org.springframework.boot:spring-boot-starter-logging:3.3.5=compileClasspath
org.springframework.boot:spring-boot-starter-security:3.3.5=compileClasspath
org.springframework.boot:spring-boot-starter-tomcat:3.3.5=compileClasspath
org.springframework.boot:spring-boot-starter-web:3.3.5=compileClasspath
org.springframework.boot:spring-boot-starter:3.3.5=compileClasspath
org.springframework.boot:spring-boot:3.3.5=compileClasspath
org.springframework.security:spring-security-config:6.3.4=compileClasspath
org.springframework.security:spring-security-core:6.3.4=compileClasspath
org.springframework.security:spring-security-crypto:6.3.4=compileClasspath
org.springframework.security:spring-security-web:6.3.4=compileClasspath
org.springframework:spring-aop:6.1.14=compileClasspath
org.springframework:spring-beans:6.1.14=compileClasspath
org.springframework:spring-context:6.1.14=compileClasspath
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = "template-payments-java-repository"
rootProject.name = "p4pa-organization"
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package it.gov.pagopa.template;
package it.gov.pagopa.pu.organization;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class TemplateApplication {
public class OrganizationApplication {

public static void main(String[] args) {
SpringApplication.run(TemplateApplication.class, args);
SpringApplication.run(OrganizationApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package it.gov.pagopa.template.config;
package it.gov.pagopa.pu.organization.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
Expand All @@ -14,16 +14,22 @@
public class SwaggerConfig {

/** The title. */
@Value("${swagger.title:${spring.application.name}}")
private String title;
private final String title;

/** The description. */
@Value("${swagger.description:Api and Models}")
private String description;
private final String description;

/** The version. */
@Value("${swagger.version:${spring.application.version}}")
private String version;
private final String version;

public SwaggerConfig(
@Value("${swagger.title:${spring.application.name}}") String title,
@Value("${swagger.description:Api and Models}") String description,
@Value("${swagger.version:${spring.application.version}}") String version) {
this.title = title;
this.description = description;
this.version = version;
}

@Bean
public OpenAPI customOpenAPI() {
Expand Down
Loading

0 comments on commit c0a0fc2

Please sign in to comment.