Core delivery platform Self-Service Ops Node.js Backend.
- Requirements
- Local development
- API endpoints
- Calling API endpoints
- Testing
- Versioning
- Docker º- Licence
For local development you need to provide a GitHub Private Key in the env GITHUB_API_AUTH_APP_PRIVATE_KEY that
allows the creation of pull requests against the various Org infrastructure repositories. For further details see the
Wiki
Please install Node.js >= v20.3.0 and npm >= v9. You will find it
easier to use the Node Version Manager nvm
To use the correct version of Node.js for this application, via nvm:
$ cd cdp-self-service-ops
$ nvm useInstall application dependencies:
$ npm installTo run the application in development mode run:
$ npm run devTo run the application alongside cdp-local-environment docker images,
you need to include env vars from cdp-local-environment files e.g:
AWS_ACCESS_KEY_ID=test
AWS_REGION=eu-west-2
AWS_SECRET_ACCESS_KEY=test
AWS_SECRET_KEY=test
GITHUB_BASE_URL=http://localhost:3939
SQS_GITHUB_QUEUE=http://localhost:4566/000000000000/github-events
USER_SERVICE_BACKEND_URL=http:/localhost:3001
PORTAL_BACKEND_URL=http://localhost:5094
OIDC_WELL_KNOWN_CONFIGURATION_URL=http://cdp.127.0.0.1.sslip.io:3939/6f504113-6b64-43f2-ade9-242e05780007/v2.0/.well-known/openid-configuration
To update dependencies, globally install https://www.npmjs.com/package/npm-check-updates. Then run the below script,
run tests, test the application and commit the altered package.json and package-lock.json files. For more
options around updates check the package docs.
ncu -iTo mimic the application running in production mode locally run:
$ npm startAll available Npm scripts can be seen in package.json To view them in your command line run:
$ npm run| Endpoint | Description |
|---|---|
GET: /queued-events |
query queued events |
PATCH: /queued-events/eventType/repositoryName |
Reset an event and trigger create service infra listener |
| Optional query parameters | Description |
|---|---|
eventType |
Restrict the eventType in response. Currently only service.infra.create is supported |
repositoryName |
Restrict response to a specific repository |
includeProcessed |
Return results that are processed in response (these are not returned by default) |
service.infra.create events:
curl --location 'localhost:3009/queued-events?eventType=service.infra.create'Specific repository:
curl --location 'localhost:3009/queued-events?repositoryName=my-service&eventType=service.infra.create'Include processed events:
curl --location 'localhost:3009/queued-events?eventType=service.infra.create&includeProcessed=true'curl --location --request PATCH 'localhost:3009/queued-events/service.infra.create/my-service'| Endpoint | Description |
|---|---|
GET: /health |
Health |
POST: /create-service |
Create a service |
POST: /deploy-service |
Deploy a service |
GET: /deploy-service/options |
Deploy a service memory and cpu options |
GET: /deploy-service/info/{environment}/{imageName} |
Deploy a service exisiting service info |
Deploy a service:
curl -H "Content-type: application/json" -d '{"imageName": "foo-frontend", "version": "v0.1.0", "environment": "snd",
"cpu": 1024, "memory": 2048, "instanceCount": 1}' 'http://localhost:3009/cdp-self-service-ops/deploy-service'Create a service:
curl -H "Content-type: application/json" -d '{"repositoryName": "foo-backend", "serviceType": "cdp-node-backend-template", "owningTeam": "fisheries"}' 'http://localhost:3009/cdp-self-service-ops/create-service'Retrieve current deployment config for a service in an environment:
curl 'http://localhost:3009/cdp-self-service-ops/deploy-service/info/snd/service-name'Retrieve the allowed cpu and memory configurations
curl 'http://localhost:3009/cdp-self-service-ops/deploy-service/options'To run one test in your cli:
$ npm test -t <test-path-and-filename>The deploy GitHub Actions workflow auto versions a Pull Requests code with a minor
version once it has been merged into the main branch.
All you have to do is commit your code and raise a Pull Request and the pipeline will auto version your code for you.
If you wish to patch or major version your codebase use:
$ npm version <patch|major>Then:
- Push this code with the auto generated commit to your GitHub Repository
- Raise a Pull Request
- Merge your code into the
mainbranch - The GitHub Actions workflow will tag and push your
majororpatchversion tags to your GitHub Repository and release yourmajororpatchversioned code
Build:
docker build --no-cache --tag cdp-self-service-ops .Run:
$ docker run -p 3009:3009 cdp-self-service-opsTHIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:
http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3
The following attribution statement MUST be cited in your products and applications when using this information.
Contains public sector information licensed under the Open Government license v3
The Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable information providers in the public sector to license the use and re-use of their information under a common open licence.
It is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.