Skip to content

Commit

Permalink
Elm 2135 reapplied rename project manually (#5)
Browse files Browse the repository at this point in the history
* Automatic rename result

* manual rename result

* Updated banner

* removed rename workflow

* ---Updated: no longer removing unused code, as leaving it in will help me fix the build---

Removed unnecessary (I think) code, and amended some values from template app values. More TODOs to do. (#1)

* Removed unnecessary (I think) code, and amended some values from template app values. More TODOs to do.

* Temporarily commented out the validate task - failing on class naming conventions and some unused imports I can't see in my IDE

* adjusted validate job removal

* Elm 2135 change secret name (#3)

* Removed template secrets from namespace

* Updated deployment to use correct certificate

* Updated readme

* merge from main

* gitSquashed commit of the following:

commit 4bb85fd
Author: jasper.jackson <[email protected]>
Date:   Tue Sep 17 17:40:13 2024 +0100

    merge from main

commit 36663a6
Author: jasper.jackson <[email protected]>
Date:   Tue Sep 17 14:35:22 2024 +0100

    Updated readme

commit 7bb5625
Author: Jasper <[email protected]>
Date:   Tue Sep 17 13:58:09 2024 +0100

    Elm 2135 change secret name (#3)

    * Removed template secrets from namespace

    * Updated deployment to use correct certificate

commit 6bb6198
Author: jasper.jackson <[email protected]>
Date:   Tue Sep 17 17:10:20 2024 +0100

    ---Updated: no longer removing unused code, as leaving it in will help me fix the build---

    Removed unnecessary (I think) code, and amended some values from template app values. More TODOs to do. (#1)

    * Removed unnecessary (I think) code, and amended some values from template app values. More TODOs to do.

    * Temporarily commented out the validate task - failing on class naming conventions and some unused imports I can't see in my IDE

    * adjusted validate job removal

commit 0286cb5
Author: jasper.jackson <[email protected]>
Date:   Thu Sep 12 17:19:31 2024 +0100

    removed rename workflow

commit d6b2c31
Author: jasper.jackson <[email protected]>
Date:   Thu Sep 12 17:11:50 2024 +0100

    Updated banner

commit 53b4590
Author: jasper.jackson <[email protected]>
Date:   Tue Sep 17 16:40:56 2024 +0100

    manual rename result

commit 9b481c1
Author: jasper.jackson <[email protected]>
Date:   Tue Sep 17 16:37:36 2024 +0100

    Automatic rename result
  • Loading branch information
JazJax authored Sep 17, 2024
1 parent 104acf2 commit fda62c9
Show file tree
Hide file tree
Showing 33 changed files with 259 additions and 90 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ workflows:
# pipeline_number: <<pipeline.number>>
# context:
# - hmpps-common-vars
# - hmpps-template-kotlin-preprod
# - hmpps-electronic-monitoring-datastore-api-preprod
# requires:
# - request-preprod-approval
# helm_timeout: 5m
Expand All @@ -100,7 +100,7 @@ workflows:
# slack_channel_name: << pipeline.parameters.releases-slack-channel >>
# context:
# - hmpps-common-vars
# - hmpps-template-kotlin-prod
# - hmpps-electronic-monitoring-datastore-api-prod
# requires:
# - request-prod-approval
# helm_timeout: 5m
Expand Down
4 changes: 2 additions & 2 deletions .circleci/config.yml-z
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ workflows:
# pipeline_number: <<pipeline.number>>
# context:
# - hmpps-common-vars
# - hmpps-template-kotlin-preprod
# - hmpps-electronic-monitoring-datastore-api-preprod
# requires:
# - request-preprod-approval
# helm_timeout: 5m
Expand All @@ -97,7 +97,7 @@ workflows:
# slack_channel_name: << pipeline.parameters.releases-slack-channel >>
# context:
# - hmpps-common-vars
# - hmpps-template-kotlin-prod
# - hmpps-electronic-monitoring-datastore-api-prod
# requires:
# - request-prod-approval
# helm_timeout: 5m
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
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-electronic-monitoring-datastore-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
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Electronic Monitoring Datastore API
# hmpps-electronic-monitoring-datastore-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")
[![CircleCI](https://circleci.com/gh/ministryofjustice/hmpps-template-kotlin/tree/main.svg?style=svg)](https://circleci.com/gh/ministryofjustice/hmpps-template-kotlin)
[![Docker Repository on Quay](https://img.shields.io/badge/quay.io-repository-2496ED.svg?logo=docker)](https://quay.io/repository/hmpps/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-electronic-monitoring-datastore-api)](https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/public-report/hmpps-electronic-monitoring-datastore-api "Link to report")
[![CircleCI](https://circleci.com/gh/ministryofjustice/hmpps-electronic-monitoring-datastore-api/tree/main.svg?style=svg)](https://circleci.com/gh/ministryofjustice/hmpps-electronic-monitoring-datastore-api)
[![Docker Repository on Quay](https://img.shields.io/badge/quay.io-repository-2496ED.svg?logo=docker)](https://quay.io/repository/hmpps/hmpps-electronic-monitoring-datastore-api)
[![API docs](https://img.shields.io/badge/API_docs_-view-85EA2D.svg?logo=swagger)](https://hmpps-electronic-monitoring-datastore-api-dev.hmpps.service.justice.gov.uk/webjars/swagger-ui/index.html?configUrl=/v3/api-docs)

API to access the Electronic Monitoring datastore in the Modernisation Platform.

Expand All @@ -19,6 +19,13 @@ Call http://localhost:8080/health with a browser to get app health info.

### Running with Docker

### Checking the app has started successfully:
If using docker, your app is probably exposed at `localhost:8080`.
Call http://localhost:8080/health with a browser to get app health info.

### Running with Docker


There is also a `docker-compose.yml` that can be used to run a local instance of the template in docker and also an
instance of HMPPS Auth (required if your service calls out to other services using a token).

Expand All @@ -31,7 +38,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-electronic-monitoring-datastore-api=0
```

will just start a docker instance of HMPPS Auth. The application should then be started with a `dev` active profile
Expand All @@ -46,3 +53,13 @@ For the demonstration, rather than introducing a dependency on a different servi
itself. This is only to show a service calling out to another service and is certainly not recommended!


## Note on remaining TODOs and Examples from template app

We have tried to provide some examples of best practice in the application - so there are lots of TODOs in the code
where changes are required to meet your requirements. There is an `ExampleResource` that includes best practice and also
serve as spring security examples. The template typescript project has a demonstration that calls this endpoint as well.

For the demonstration, rather than introducing a dependency on a different service, this application calls out to
itself. This is only to show a service calling out to another service and is certainly not recommended!


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-electronic-monitoring-datastore-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-electronic-monitoring-datastore-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-electronic-monitoring-datastore-api:
build:
context: .
networks:
- hmpps
container_name: hmpps-template-kotlin
container_name: hmpps-electronic-monitoring-datastore-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-electronic-monitoring-datastore-api:8080
- SPRING_PROFILES_ACTIVE=dev

hmpps-auth:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
generic-service:
nameOverride: hmpps-template-kotlin
nameOverride: hmpps-electronic-monitoring-datastore-api
productId: "UNASSIGNED" # productId for the product that this belongs too, i.e. DPS001, see README.md for details

replicaCount: 4

image:
repository: quay.io/hmpps/hmpps-template-kotlin
repository: quay.io/hmpps/hmpps-electronic-monitoring-datastore-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-electronic-monitoring-datastore-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-electronic-monitoring-datastore-api:
APPINSIGHTS_INSTRUMENTATIONKEY: "APPINSIGHTS_INSTRUMENTATIONKEY"
# Example client registration secrets
EXAMPLE_API_CLIENT_ID: "TEMPLATE_KOTLIN_API_CLIENT_ID"
Expand All @@ -38,4 +38,4 @@ generic-service:
- internal

generic-prometheus-alerts:
targetApplication: hmpps-template-kotlin
targetApplication: hmpps-electronic-monitoring-datastore-api
5 changes: 3 additions & 2 deletions helm_deploy/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ generic-service:
env:
APPLICATIONINSIGHTS_CONFIGURATION_FILE: "applicationinsights.dev.json"
HMPPS_AUTH_URL: "https://sign-in-dev.hmpps.service.justice.gov.uk/auth"

# TODO: any external API URLS go here, e.g. "https://template-kotlin-dev.hmpps.service.justice.gov.uk"
# 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"

# 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
Expand Down
6 changes: 3 additions & 3 deletions helm_deploy/values-dev.yaml-z
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
# Per environment values which override defaults in hmpps-template-kotlin/values.yaml
# Per environment values which override defaults in hmpps-electronic-monitoring-datastore-api/values.yaml

generic-service:
replicaCount: 2

ingress:
host: template-kotlin-dev.hmpps.service.justice.gov.uk
host: electronic-monitoring-datastore-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://electronic-monitoring-datastore-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
Expand Down
4 changes: 3 additions & 1 deletion helm_deploy/values-preprod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ generic-service:
env:
APPLICATIONINSIGHTS_CONFIGURATION_FILE: "applicationinsights.dev.json"
HMPPS_AUTH_URL: "https://sign-in-preprod.hmpps.service.justice.gov.uk/auth"
# TODO: any external API URLS go here, e.g. "https://template-kotlin-preprod.hmpps.service.justice.gov.uk"
# 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://electronic-monitoring-datastore-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
Expand Down
6 changes: 3 additions & 3 deletions helm_deploy/values-preprod.yaml-z
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
# Per environment values which override defaults in hmpps-template-kotlin/values.yaml
# Per environment values which override defaults in hmpps-electronic-monitoring-datastore-api/values.yaml

generic-service:
replicaCount: 2

ingress:
host: template-kotlin-preprod.hmpps.service.justice.gov.uk
host: electronic-monitoring-datastore-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://electronic-monitoring-datastore-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
Expand Down
5 changes: 3 additions & 2 deletions helm_deploy/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ generic-service:

env:
HMPPS_AUTH_URL: "https://sign-in.hmpps.service.justice.gov.uk/auth"

# TODO: any external API URLS go here, e.g. "https://template-kotlin.hmpps.service.justice.gov.uk"
# 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://electronic-monitoring-datastore-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
Expand Down
6 changes: 3 additions & 3 deletions helm_deploy/values-prod.yaml-z
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
# Per environment values which override defaults in hmpps-template-kotlin/values.yaml
# Per environment values which override defaults in hmpps-electronic-monitoring-datastore-api/values.yaml

generic-service:
ingress:
host: template-kotlin.hmpps.service.justice.gov.uk
host: electronic-monitoring-datastore-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://electronic-monitoring-datastore-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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package uk.gov.justice.digital.hmpps.templatepackagename
package uk.gov.justice.digital.hmpps.electronicmonitoringdatastoreapi

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication

@SpringBootApplication
class HmppsTemplateKotlin
class HmppsElectronicMonitoringDatastoreApi

fun main(args: Array<String>) {
runApplication<HmppsTemplateKotlin>(*args)
runApplication<HmppsElectronicMonitoringDatastoreApi>(*args)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.justice.digital.hmpps.templatepackagename.config
package uk.gov.justice.digital.hmpps.electronicmonitoringdatastoreapi.config

import jakarta.validation.ValidationException
import org.slf4j.LoggerFactory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.justice.digital.hmpps.templatepackagename.config
package uk.gov.justice.digital.hmpps.electronicmonitoringdatastoreapi.config

import io.swagger.v3.oas.models.Components
import io.swagger.v3.oas.models.OpenAPI
Expand All @@ -7,10 +7,10 @@ import io.swagger.v3.oas.models.info.Info
import io.swagger.v3.oas.models.security.SecurityRequirement
import io.swagger.v3.oas.models.security.SecurityScheme
import io.swagger.v3.oas.models.servers.Server
import io.swagger.v3.oas.models.tags.Tag
import org.springframework.boot.info.BuildProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
// import io.swagger.v3.oas.models.tags.Tag

@Configuration
class OpenApiConfiguration(buildProperties: BuildProperties) {
Expand All @@ -20,33 +20,33 @@ 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://electronic-monitoring-datastore-api-dev.hmpps.service.justice.gov.uk").description("Development"),
Server().url("https://electronic-monitoring-datastore-api-preprod.hmpps.service.justice.gov.uk").description("Pre-Production"),
Server().url("https://electronic-monitoring-datastore-api.hmpps.service.justice.gov.uk").description("Production"),
Server().url("http://localhost:8080").description("Local"),
),
)
// TODO: Add tags for OpenAPI - below are commented out Popular and Examples tags
// .tags(
// listOf(
// Tag().name("Popular")
// .description("The most popular endpoints. Look here first when deciding which endpoint to use."),
// Tag().name("Examples").description("Endpoints for searching for a prisoner within a prison"),
// ),
// )
.tags(
listOf(
// TODO: Remove the Popular and Examples tag and start adding your own tags to group your resources
Tag().name("Popular")
.description("The most popular endpoints. Look here first when deciding which endpoint to use."),
Tag().name("Examples").description("Endpoints for searching for a prisoner within a prison"),
),
)
.info(
Info().title("HMPPS Electronic Monitoring datastore API").version(version)
.contact(Contact().name("Electronic Monitoring").email("hmpps-ems-platform-team@digital.justice.gov.uk")),
Info().title("HMPPS Electronic Monitoring Datastore Api").version(version)
.contact(Contact().name("HMPPS Digital Studio").email("feedback@digital.justice.gov.uk")),
)
// TODO: Remove the default security schema and start adding your own schemas and roles to describe your
// service authorisation requirements
.components(
Components().addSecuritySchemes(
"template-kotlin-ui-role",
"electronic-monitoring-datastore-api-ui-role",
SecurityScheme().addBearerJwtRequirement("ROLE_TEMPLATE_KOTLIN__UI"),
),
)
.addSecurityItem(SecurityRequirement().addList("template-kotlin-ui-role", listOf("read")))
.addSecurityItem(SecurityRequirement().addList("electronic-monitoring-datastore-api-ui-role", listOf("read")))
}

private fun SecurityScheme.addBearerJwtRequirement(role: String): SecurityScheme =
Expand Down
Loading

0 comments on commit fda62c9

Please sign in to comment.