A simple REST service that provides information about Source Code Management (SCM) systems used by different assets.
This service allows you to:
- Retrieve SCM information for a specific asset code
- Add new SCM information for assets
The service stores information about which SCM system (Git, SVN, Mercurial, etc.) is used by each asset, along with the repository URL. It uses Redis for distributed caching and session management, making it scalable in a Kubernetes environment.
- Java 21
- Spring Boot 3.4.0
- Spring Data Redis
- Spring Session
- Maven
- Docker
- Kubernetes
- Helm
- Java 21 or higher
- Maven 3.6 or higher
- Docker and Docker Compose (for containerized deployment)
- Kubernetes cluster (for Kubernetes deployment)
- Helm 3.x (for Helm chart deployment)
-
Clone the repository:
git clone https://github.com/yourusername/scm-service.git cd scm-service -
Build the application:
./mvnw clean package -
Run the application:
./mvnw spring-boot:run -
The service will be available at http://localhost:8080
-
Build and start the services:
docker compose up -d -
The service will be available at http://localhost:8080
-
Build and push the Docker image to your registry:
docker build -t your-registry/scm-service:latest . docker push your-registry/scm-service:latest -
Update the image repository in
helm/scm-service/values.yaml -
Install the Helm chart:
helm install scm-service ./helm/scm-service -
To upgrade an existing release:
helm upgrade scm-service ./helm/scm-service -
To uninstall the release:
helm uninstall scm-service
You can customize the deployment by overriding values in the values.yaml file:
helm install scm-service ./helm/scm-service --set replicaCount=5,image.tag=v1.0.0
Or by providing a custom values file:
helm install scm-service ./helm/scm-service -f custom-values.yaml
The application is designed to be scalable in a Kubernetes environment:
- Redis is used for distributed caching and session management
- Health checks are configured for proper pod lifecycle management
- Resource limits are defined to ensure efficient resource utilization
- Horizontal Pod Autoscaler is configured for automatic scaling
To manually scale the application:
kubectl scale deployment scm-service --replicas=5
Or when using Helm:
helm upgrade scm-service ./helm/scm-service --set replicaCount=5
Endpoint: GET /api/scm/{assetCode}
Example Request:
curl -X GET http://localhost:8080/api/scm/APP001Example Response:
{
"assetCode": "APP001",
"scmType": "Git",
"repositoryUrl": "https://github.com/org/app001"
}Error Response (Asset Not Found):
{
"timestamp": "2024-07-01T12:34:56.789",
"status": 404,
"error": "Not Found",
"message": "Asset not found with assetCode: 'NONEXISTENT'",
"path": "/api/scm/NONEXISTENT"
}Endpoint: POST /api/scm
Example Request:
curl -X POST http://localhost:8080/api/scm \
-H "Content-Type: application/json" \
-d '{"assetCode":"APP004","scmType":"Git","repositoryUrl":"https://github.com/org/app004"}'Example Response:
{
"assetCode": "APP004",
"scmType": "Git",
"repositoryUrl": "https://github.com/org/app004"
}Run the tests with:
./mvnw test
The project includes:
- Unit tests for service and controller layers
- Integration tests for the API endpoints
Note: This project uses Spring Boot 3.4.0, which introduces @MockitoBean as a replacement for the deprecated @MockBean annotation.
scm-service/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/example/scmservice/
│ │ │ ├── controller/
│ │ │ ├── model/
│ │ │ ├── service/
│ │ │ └── ScmServiceApplication.java
│ │ └── resources/
│ └── test/
│ └── java/
│ └── com/example/scmservice/
│ ├── controller/
│ ├── integration/
│ ├── model/
│ ├── service/
│ └── ScmServiceApplicationTests.java
├── .mvn/
├── Dockerfile
├── compose.yaml
├── mvnw
├── mvnw.cmd
├── pom.xml
└── README.md
This project is licensed under the MIT License - see the LICENSE file for details.