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

CDPS-1054: Renamed template project to hmpps-person-integration-api #2

Merged
merged 4 commits into from
Nov 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ sonar-project.properties

#Helm
**/Chart.lock
.java-version
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN addgroup --gid 2000 --system appgroup && \
adduser --uid 2000 --system appuser --gid 2000

WORKDIR /app
COPY --from=builder --chown=appuser:appgroup /app/build/libs/hmpps-template-kotlin*.jar /app/app.jar
COPY --from=builder --chown=appuser:appgroup /app/build/libs/hmpps-person-integration-api*.jar /app/app.jar
COPY --from=builder --chown=appuser:appgroup /app/build/libs/applicationinsights-agent*.jar /app/agent.jar
COPY --from=builder --chown=appuser:appgroup /app/applicationinsights.json /app
COPY --from=builder --chown=appuser:appgroup /app/applicationinsights.dev.json /app
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# hmpps-template-kotlin
# hmpps-person-integration-api

[![repo standards badge](https://img.shields.io/badge/endpoint.svg?&style=flat&logo=github&url=https%3A%2F%2Foperations-engineering-reports.cloud-platform.service.justice.gov.uk%2Fapi%2Fv1%2Fcompliant_public_repositories%2Fhmpps-template-kotlin)](https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/public-report/hmpps-template-kotlin "Link to report")
[![Docker Repository on ghcr](https://img.shields.io/badge/ghcr.io-repository-2496ED.svg?logo=docker)](https://ghcr.io/ministryofjustice/hmpps-template-kotlin)
[![API docs](https://img.shields.io/badge/API_docs_-view-85EA2D.svg?logo=swagger)](https://hmpps-template-kotlin-dev.hmpps.service.justice.gov.uk/webjars/swagger-ui/index.html?configUrl=/v3/api-docs)
[![repo standards badge](https://img.shields.io/badge/endpoint.svg?&style=flat&logo=github&url=https%3A%2F%2Foperations-engineering-reports.cloud-platform.service.justice.gov.uk%2Fapi%2Fv1%2Fcompliant_public_repositories%2Fhmpps-person-integration-api)](https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/public-report/hmpps-person-integration-api "Link to report")
[![Docker Repository on ghcr](https://img.shields.io/badge/ghcr.io-repository-2496ED.svg?logo=docker)](https://ghcr.io/ministryofjustice/hmpps-person-integration-api)
[![API docs](https://img.shields.io/badge/API_docs_-view-85EA2D.svg?logo=swagger)](https://hmpps-person-integration-api-dev.hmpps.service.justice.gov.uk/webjars/swagger-ui/index.html?configUrl=/v3/api-docs)

Template github repo used for new Kotlin based projects.

Expand All @@ -16,20 +16,20 @@ within GitHub.
This project is community managed by the mojdt `#kotlin-dev` slack channel.
Please raise any questions or queries there. Contributions welcome!

Our security policy is located [here](https://github.com/ministryofjustice/hmpps-template-kotlin/security/policy).
Our security policy is located [here](https://github.com/ministryofjustice/hmpps-person-integration-api/security/policy).

Documentation to create new service is located [here](https://tech-docs.hmpps.service.justice.gov.uk/applicationplatform/newservice-GHA/).

## Creating a Cloud Platform namespace

When deploying to a new namespace, you may wish to use the
[templates project namespace](https://github.com/ministryofjustice/cloud-platform-environments/tree/main/namespaces/live.cloud-platform.service.justice.gov.uk/hmpps-templates-dev)
as the basis for your new namespace. This namespace contains both the kotlin and typescript template projects,
as the basis for your new namespace. This namespace contains both the kotlin and typescript template projects,
which is the usual way that projects are setup.

Copy this folder and update all the existing namespace references to correspond to the environment to which you're deploying.

If you only need the kotlin configuration then remove all typescript references and remove the elasticache configuration.
If you only need the kotlin configuration then remove all typescript references and remove the elasticache configuration.

To ensure the correct github teams can approve releases, you will need to make changes to the configuration in `resources/service-account-github` where the appropriate team names will need to be added (based on [lines 98-100](https://github.com/ministryofjustice/cloud-platform-environments/blob/main/namespaces/live.cloud-platform.service.justice.gov.uk/hmpps-templates-dev/resources/serviceaccount-github.tf#L98) and the reference appended to the teams list below [line 112](https://github.com/ministryofjustice/cloud-platform-environments/blob/main/namespaces/live.cloud-platform.service.justice.gov.uk/hmpps-templates-dev/resources/serviceaccount-github.tf#L112)). Note: hmpps-sre is in this list to assist with deployment issues.

Expand Down Expand Up @@ -129,7 +129,7 @@ will build the application and run it and HMPPS Auth within a local docker insta
### Running the application in Intellij

```bash
docker compose pull && docker compose up --scale hmpps-template-kotlin=0
docker compose pull && docker compose up --scale hmpps-person-integration-api=0
```

will just start a docker instance of HMPPS Auth. The application should then be started with a `dev` active profile
Expand Down
2 changes: 1 addition & 1 deletion applicationinsights.dev.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"role": {
"name": "hmpps-template-kotlin"
"name": "hmpps-person-integration-api"
},
"customDimensions": {
"service.version": "${BUILD_NUMBER}"
Expand Down
2 changes: 1 addition & 1 deletion applicationinsights.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"role": {
"name": "hmpps-template-kotlin"
"name": "hmpps-person-integration-api"
},
"customDimensions": {
"service.version": "${BUILD_NUMBER}"
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: "3"
services:
hmpps-template-kotlin:
hmpps-person-integration-api:
build:
context: .
networks:
- hmpps
container_name: hmpps-template-kotlin
container_name: hmpps-person-integration-api
ports:
- "8080:8080"
healthcheck:
Expand All @@ -14,7 +14,7 @@ services:
- SERVER_PORT=8080
- HMPPS_AUTH_URL=http://hmpps-auth:8080/auth
# TODO: Remove this URL and replace with outgoing service URLs
- EXAMPLE_URL=http://hmpps-template-kotlin:8080
- EXAMPLE_URL=http://hmpps-person-integration-api:8080
- SPRING_PROFILES_ACTIVE=dev

hmpps-auth:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
appVersion: '1.0'
description: A Helm chart for Kubernetes
name: hmpps-template-kotlin
name: hmpps-person-integration-api
version: 0.2.0
dependencies:
- name: generic-service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
generic-service:
nameOverride: hmpps-template-kotlin
productId: "UNASSIGNED" # productId for the product that this belongs too, i.e. DPS001, see README.md for details
nameOverride: hmpps-person-integration-api
productId: "HMPPS517" # productId for the product that this belongs too, i.e. DPS001, see README.md for details

replicaCount: 4

image:
repository: ghcr.io/ministryofjustice/hmpps-template-kotlin
repository: ghcr.io/ministryofjustice/hmpps-person-integration-api
tag: app_version # override at deployment time
port: 8080

ingress:
enabled: true
host: app-hostname.local # override per environment
tlsSecretName: hmpps-template-kotlin-cert
tlsSecretName: hmpps-person-integration-api-cert

# Environment variables to load into the deployment
env:
Expand All @@ -27,7 +27,7 @@ generic-service:
# [name of environment variable as seen by app]: [key of kubernetes secret to load]

namespace_secrets:
hmpps-template-kotlin:
hmpps-person-integration-api:
# Example client registration secrets
EXAMPLE_API_CLIENT_ID: "TEMPLATE_KOTLIN_API_CLIENT_ID"
EXAMPLE_API_CLIENT_SECRET: "TEMPLATE_KOTLIN_API_CLIENT_SECRET"
Expand All @@ -39,4 +39,4 @@ generic-service:
- internal

generic-prometheus-alerts:
targetApplication: hmpps-template-kotlin
targetApplication: hmpps-person-integration-api
8 changes: 4 additions & 4 deletions helm_deploy/values-dev.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
# Per environment values which override defaults in hmpps-template-kotlin/values.yaml
# Per environment values which override defaults in hmpps-person-integration-api/values.yaml

generic-service:
replicaCount: 2

ingress:
host: template-kotlin-dev.hmpps.service.justice.gov.uk
host: person-integration-api-dev.hmpps.service.justice.gov.uk

env:
APPLICATIONINSIGHTS_CONFIGURATION_FILE: "applicationinsights.dev.json"
HMPPS_AUTH_URL: "https://sign-in-dev.hmpps.service.justice.gov.uk/auth"
# Template kotlin calls out to itself to provide an example of a service call
# TODO: This should be replaced by a call to a different service, or removed
EXAMPLE_API_URL: "https://template-kotlin-dev.hmpps.service.justice.gov.uk"
EXAMPLE_API_URL: "https://person-integration-api-dev.hmpps.service.justice.gov.uk"

# CloudPlatform AlertManager receiver to route prometheus alerts to slack
# See https://user-guide.cloud-platform.service.justice.gov.uk/documentation/monitoring-an-app/how-to-create-alarms.html#creating-your-own-custom-alerts
generic-prometheus-alerts:
alertSeverity: NON_PROD_ALERTS_SEVERITY_LABEL
alertSeverity: digital-prison-service-dev
Copy link
Contributor

Choose a reason for hiding this comment

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

actually check line 8 above - ingress still template-kotlin-dev.hmpps.service.justice.gov.uk

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good spot, thanks!

8 changes: 4 additions & 4 deletions helm_deploy/values-preprod.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
# Per environment values which override defaults in hmpps-template-kotlin/values.yaml
# Per environment values which override defaults in hmpps-person-integration-api/values.yaml

generic-service:
replicaCount: 2

ingress:
host: template-kotlin-preprod.hmpps.service.justice.gov.uk
host: person-integration-api-preprod.hmpps.service.justice.gov.uk

env:
APPLICATIONINSIGHTS_CONFIGURATION_FILE: "applicationinsights.dev.json"
HMPPS_AUTH_URL: "https://sign-in-preprod.hmpps.service.justice.gov.uk/auth"
# Template kotlin calls out to itself to provide an example of a service call
# TODO: This should be replaced by a call to a different service, or removed
EXAMPLE_API_URL: "https://template-kotlin-preprod.hmpps.service.justice.gov.uk"
EXAMPLE_API_URL: "https://person-integration-api-preprod.hmpps.service.justice.gov.uk"

# CloudPlatform AlertManager receiver to route prometheus alerts to slack
# See https://user-guide.cloud-platform.service.justice.gov.uk/documentation/monitoring-an-app/how-to-create-alarms.html#creating-your-own-custom-alerts
generic-prometheus-alerts:
alertSeverity: NON_PROD_ALERTS_SEVERITY_LABEL
alertSeverity: digital-prison-service-dev
8 changes: 4 additions & 4 deletions helm_deploy/values-prod.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
# Per environment values which override defaults in hmpps-template-kotlin/values.yaml
# Per environment values which override defaults in hmpps-person-integration-api/values.yaml

generic-service:
ingress:
host: template-kotlin.hmpps.service.justice.gov.uk
host: person-integration-api.hmpps.service.justice.gov.uk

env:
HMPPS_AUTH_URL: "https://sign-in.hmpps.service.justice.gov.uk/auth"
# Template kotlin calls out to itself to provide an example of a service call
# TODO: This should be replaced by a call to a different service, or removed
EXAMPLE_API_URL: "https://template-kotlin.hmpps.service.justice.gov.uk"
EXAMPLE_API_URL: "https://person-integration-api.hmpps.service.justice.gov.uk"

# CloudPlatform AlertManager receiver to route prometheus alerts to slack
# See https://user-guide.cloud-platform.service.justice.gov.uk/documentation/monitoring-an-app/how-to-create-alarms.html#creating-your-own-custom-alerts
generic-prometheus-alerts:
alertSeverity: PROD_ALERTS_SEVERITY_LABEL
alertSeverity: digital-prison-service
111 changes: 0 additions & 111 deletions rename-project.bash

This file was deleted.

2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = "hmpps-template-kotlin"
rootProject.name = "hmpps-person-integration-api"
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.springframework.web.servlet.resource.NoResourceFoundException
import uk.gov.justice.hmpps.kotlin.common.ErrorResponse

@RestControllerAdvice
class HmppsTemplateKotlinExceptionHandler {
class HmppsPersonIntegrationApiExceptionHandler {
@ExceptionHandler(ValidationException::class)
fun handleValidationException(e: ValidationException): ResponseEntity<ErrorResponse> = ResponseEntity
.status(BAD_REQUEST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class OpenApiConfiguration(buildProperties: BuildProperties) {
fun customOpenAPI(): OpenAPI = OpenAPI()
.servers(
listOf(
Server().url("https://template-kotlin-dev.hmpps.service.justice.gov.uk").description("Development"),
Server().url("https://template-kotlin-preprod.hmpps.service.justice.gov.uk").description("Pre-Production"),
Server().url("https://template-kotlin.hmpps.service.justice.gov.uk").description("Production"),
Server().url("https://person-integration-api-dev.hmpps.service.justice.gov.uk").description("Development"),
Server().url("https://person-integration-api-preprod.hmpps.service.justice.gov.uk").description("Pre-Production"),
Server().url("https://person-integration-api.hmpps.service.justice.gov.uk").description("Production"),
Server().url("http://localhost:8080").description("Local"),
),
)
Expand All @@ -42,11 +42,11 @@ class OpenApiConfiguration(buildProperties: BuildProperties) {
// service authorisation requirements
.components(
Components().addSecuritySchemes(
"template-kotlin-ui-role",
"person-integration-api-ui-role",
SecurityScheme().addBearerJwtRequirement("ROLE_TEMPLATE_KOTLIN__UI"),
),
)
.addSecurityItem(SecurityRequirement().addList("template-kotlin-ui-role", listOf("read")))
.addSecurityItem(SecurityRequirement().addList("person-integration-api-ui-role", listOf("read")))
}

private fun SecurityScheme.addBearerJwtRequirement(role: String): SecurityScheme =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ExampleResource(private val exampleApiService: ExampleApiService) {
@Operation(
summary = "Retrieve today's date and time",
description = "This is an example endpoint that calls a service to return the current date and time. Requires role ROLE_TEMPLATE_KOTLIN__UI",
security = [SecurityRequirement(name = "template-kotlin-ui-role")],
security = [SecurityRequirement(name = "person-integration-api-ui-role")],
responses = [
ApiResponse(responseCode = "200", description = "today's date and time"),
ApiResponse(
Expand All @@ -53,7 +53,7 @@ class ExampleResource(private val exampleApiService: ExampleApiService) {
It will return a 404 response as the /example-external-api endpoint hasn't been implemented, so we use wiremock
in integration tests to simulate other responses.
Requires role ROLE_TEMPLATE_KOTLIN__UI""",
security = [SecurityRequirement(name = "template-kotlin-ui-role")],
security = [SecurityRequirement(name = "person-integration-api-ui-role")],
responses = [
ApiResponse(responseCode = "200", description = "a message with a parameter"),
ApiResponse(
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info.app:

spring:
application:
name: hmpps-template-kotlin
name: hmpps-person-integration-api
codec:
max-in-memory-size: 10MB

Expand Down
Loading