Skip to content
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
63 changes: 63 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,69 @@ config:: # Configure development environment (main) @Configuration
precommit: test-unit build test-integration lint ## Pre-commit tasks
python -m this

##################
#### Proxygen ####
##################

retrieve-proxygen-key: # Obtain the 'machine user' credentials from AWS SSM (Development environment)
mkdir -p ~/.proxygen && \
aws ssm get-parameter --name /proxygen/private_key_temp --with-decryption | jq ".Parameter.Value" --raw-output \
> ~/.proxygen/eligibility-signposting-api.pem

setup-proxygen-credentials: # Copy Proxygen templated credentials to where it expected them
cd specification && cp -r .proxygen ~

get-spec: # Get the most recent specification live in proxygen
$(MAKE) setup-proxygen-credentials
proxygen spec get

# Specification

guard-%:
@ if [ "${${*}}" = "" ]; then \
echo "Variable $* not set"; \
exit 1; \
fi

set-target: guard-APIM_ENV
@ TARGET=target-$$APIM_ENV.yaml \
envsubst '$${TARGET}' \
< specification/x-nhsd-apim/target-template.yaml > specification/x-nhsd-apim/target.yaml

set-access: guard-APIM_ENV
@ ACCESS=access-$$APIM_ENV.yaml \
envsubst '$${ACCESS}' \
< specification/x-nhsd-apim/access-template.yaml > specification/x-nhsd-apim/access.yaml

set-security: guard-APIM_ENV
@ SECURITY=security-$$APIM_ENV.yaml \
envsubst '$${SECURITY}' \
< specification/components/security/security-template.yaml > specification/components/security/security.yaml

set-ratelimit: guard-APIM_ENV
@ RATELIMIT=ratelimit-$$APIM_ENV.yaml \
envsubst '$${RATELIMIT}' \
< specification/x-nhsd-apim/ratelimit-template.yaml > specification/x-nhsd-apim/ratelimit.yaml

update-spec-template: guard-APIM_ENV
ifeq ($(APIM_ENV), $(filter $(APIM_ENV), sandbox internal-dev int ref prod ))
@ $(MAKE) set-target APIM_ENV=$$APIM_ENV
@ $(MAKE) set-access APIM_ENV=$$APIM_ENV
@ $(MAKE) set-security APIM_ENV=$$APIM_ENV
@ $(MAKE) set-ratelimit APIM_ENV=$$APIM_ENV
else
@ echo ERROR: $$APIM_ENV is not a valid environment. Please use one of [sandbox, internal-dev, int, ref, prod]
@ exit 1;
endif

construct-spec: guard-APIM_ENV
@ $(MAKE) update-spec-template APIM_ENV=$$APIM_ENV
mkdir -p build/specification && \
npx redocly bundle specification/eligibility-signposting-api.yaml --remove-unused-components --keep-url-references --ext yaml \
> build/specification/eligibility-signposting-api.yaml
ifeq ($(APIM_ENV), sandbox)
@ $(MAKE) publish
endif
SPEC_DIR := $(CURDIR)/specification
POSTMAN_DIR := $(SPEC_DIR)/postman

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The software will only be used for signposting an individual to an appropriate s
- [Usage](#usage)
- [Testing](#testing)
- [Sandbox](#sandbox)
- [Specification](#specification)
- [Conflict with yanai](#conflict-with-yanai)
- [Creating a Postman collection](#creating-a-postman-collection)
- [Design](#design)
Expand Down Expand Up @@ -96,6 +97,11 @@ There are `make` tasks for you to configure to run your tests. Run `make test`

There is a minimalist sandbox environment in `/sandbox` with an accompanying README with instructions on how to run it locally.

## Specification

The OpenAPI specification is stored in `specification`. In that folder, there is an accompanying README with instructions on how to produce an environment-specification specification and publish
it using Proxygen CLI.

## Conflict with yanai

If you have previously built [yanai](https://nhsd-confluence.digital.nhs.uk/pages/viewpage.action?pageId=48826732), which is the platform we use to supply data to this project, that uses an old version of localstack that does not support our Python version. We have pinned the correct version here and yanai have their version pinned as well so it should work fine, but sometimes issues can arise - if so then removing the docker image can solve that, before then rebuilding.
Expand Down
Loading
Loading