Skip to content
Open
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
38 changes: 19 additions & 19 deletions azure/azure-build-pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
name: "$(SourceBranchName)+$(BuildID)"

trigger:
branches:
include:
- tags/refs/v*
tags:
include:
- v*
branches:
include:
- tags/refs/v*
tags:
include:
- v*

pr:
branches:
include: ['*']
branches:
include: ['*']

resources:
repositories:
- repository: common
type: github
name: NHSDigital/api-management-utils
ref: refs/heads/edge
endpoint: NHSDigital
repositories:
- repository: common
type: github
name: NHSDigital/api-management-utils
ref: refs/heads/edge
endpoint: NHSDigital

variables:
- template: project.yml
- template: project.yml

extends:
template: azure/common/apigee-build.yml@common
parameters:
service_name: ${{ variables.service_name }}
short_service_name: ${{ variables.short_service_name }}
template: azure/common/apigee-build.yml@common
parameters:
service_name: ${{ variables.service_name }}
short_service_name: ${{ variables.short_service_name }}
47 changes: 26 additions & 21 deletions azure/azure-pr-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,38 @@ trigger: none
pr: none

resources:
repositories:
- repository: common
type: github
name: NHSDigital/api-management-utils
ref: refs/heads/edge
endpoint: NHSDigital
pipelines:
repositories:
- repository: common
type: github
name: NHSDigital/api-management-utils
ref: refs/heads/edge
endpoint: NHSDigital

pipelines:
- pipeline: build_pipeline
source: "Monitoring-Service-Discovery-Build"
trigger:
branches:
exclude:
- master
- refs/heads/master
- refs/tags/v*
branches:
exclude:
- master
- refs/heads/master
- refs/tags/v*

pool:
name: 'AWS-ECS'
name: 'AWS-ECS'

variables:
- template: project.yml
- template: project.yml

extends:
template: azure/common/apigee-deployment.yml@common
parameters:
service_name: ${{ variables.service_name }}
short_service_name: ${{ variables.short_service_name }}
service_base_path: ${{ variables.service_base_path }}
product_display_name: ${{ variables.product_display_name }}
product_description: ${{ variables.product_description }}
template: azure/common/apigee-deployment.yml@common
parameters:
service_name: ${{ variables.service_name }}
service_base_path: ${{ variables.service_base_path }}
short_service_name: ${{ variables.short_service_name }}
product_display_name: ${{ variables.product_display_name }}
product_description: ${{ variables.product_description }}
spec_file: ${{ variables.spec_file }}
apigee_deployments:
- environment: internal-dev
make_spec_visible: false
34 changes: 0 additions & 34 deletions azure/azure-release-pipeline.yml

This file was deleted.

8 changes: 4 additions & 4 deletions azure/project.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
variables:
service_name: monitoring-service-discovery
short_service_name: msd
service_base_path: monitoring-sd
service_base_path: monitoring-service-discovery
short_service_name: monitoring-sd
product_display_name: Monitoring Service Discovery
product_description: Monitors all the things

product_description: Monitoring Service Discovery
spec_file: monitoring-service-discovery.json
6 changes: 6 additions & 0 deletions proxies/live/apiproxy/policies/JS.DeleteServiceEntries.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Javascript async="false" continueOnError="false" enabled="true" timeLimit="200" name="JS.DeleteServiceEntries">
<DisplayName>JS.DeleteServiceEntries</DisplayName>
<Properties/>
<ResourceURL>jsc://delete-service-entries.js</ResourceURL>
</Javascript>
18 changes: 18 additions & 0 deletions proxies/live/apiproxy/proxies/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@
<Response/>
<Condition>(proxy.pathsuffix MatchesPath "/service") and (request.verb = "POST")</Condition>
</Flow>
<Flow name="DELETE service monitoring endpoints">
<Request>
<Step>
<Name>VerifyApiKey</Name>
</Step>
<Step>
<Name>KVM.RetrieveServiceEntries</Name>
</Step>
<Step>
<Name>JS.DeleteServiceEntries</Name>
</Step>
<Step>
<Name>KVM.StoreServiceEntries</Name>
</Step>
</Request>
<Response/>
<Condition>(proxy.pathsuffix MatchesPath "/service") and (request.verb = "DELETE")</Condition>
</Flow>
</Flows>
<PreFlow/>
<HTTPProxyConnection>
Expand Down
43 changes: 43 additions & 0 deletions proxies/live/apiproxy/resources/jsc/delete-service-entries.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
payload = JSON.parse(context.getVariable("request.content"));

rawEntries = context.getVariable("service.entries") || {};
entries = JSON.parse(rawEntries);

serviceNames = Object.keys(payload);

serviceNames.forEach(function (serviceName) {
environments = Object.keys(serviceName);

if (serviceName) {
environments.forEach(function (env) {
dbEndpoints = entries[serviceName][env]
if (dbEndpoints) {
env.forEach(function (endpointToDelete) {
index = dbEndpoints.indexOf(endpointToDelete);
if (index !== -1) {
dbEndpoints.splice(index, 1);
}
});
}
});
}
});

if (!entries[serviceName]) {
dbServiceName = entries[serviceName];

environments = Object.keys(dbServiceName);

endpointsToDelete = [];
environments.forEach(function (env) {
endpointsToDelete.concat(environments[env]);
})

Object.assign(entries, payload);

} else {
serviceEntries = entries[serviceName];
envEntries = payload[serviceName];

Object.assign(serviceEntries, envEntries);
}